Skip to content

Commit

Permalink
[storage]Added createdOn in BlobDownloadResponseParsed and FileReadRe…
Browse files Browse the repository at this point in the history
…sponse in datalake package (#24934)

1. Added createdOn in BlobDownloadResponseParsed and FileReadResponse in
datalake package
2. Renamed new added option `leaseDuration` to `leaseDurationInSeconds`
3. Expose `KnownEncryptionAlgorithmType` to describe extendable enum
type `EncryptionAlgorithmType`'s available value.

### Packages impacted by this PR


### Issues associated with this PR


### Describe the problem that is addressed by this PR


### What are the possible designs available to address the problem? If
there are more than one possible design, why was the one in this PR
chosen?


### Are there test cases added in this PR? _(If not, why?)_


### Provide a list of related PRs _(if any)_


### Command used to generate this PR:**_(Applicable only to SDK release
request PRs)_

### Checklists
- [ ] Added impacted package name to the issue description
- [ ] Does this PR needs any fixes in the SDK Generator?** _(If so,
create an Issue in the
[Autorest/typescript](https://github.com/Azure/autorest.typescript)
repository and link it here)_
- [ ] Added a changelog (if necessary)
  • Loading branch information
EmmaZhu authored Feb 22, 2023
1 parent 45f2077 commit 0ce3065
Show file tree
Hide file tree
Showing 13 changed files with 64 additions and 11 deletions.
6 changes: 6 additions & 0 deletions sdk/storage/storage-blob/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release History

## 12.13.0 (Unreleased)

### Features Added

- Added BlobDownloadHeaders.createdOn property for interface BlobClient.Download().

## 12.13.0-beta.1 (2023-02-09)

### Features Added
Expand Down
7 changes: 7 additions & 0 deletions sdk/storage/storage-blob/review/storage-blob.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ export interface BlobDownloadHeaders {
copySource?: string;
copyStatus?: CopyStatusType;
copyStatusDescription?: string;
createdOn?: Date;
date?: Date;
encryptionKeySha256?: string;
encryptionScope?: string;
Expand Down Expand Up @@ -2311,6 +2312,12 @@ export { IHttpClient }
// @public
export function isPipelineLike(pipeline: unknown): pipeline is PipelineLike;

// @public
export enum KnownEncryptionAlgorithmType {
// (undocumented)
AES256 = "AES256"
}

// @public
export interface Lease {
date?: Date;
Expand Down
9 changes: 9 additions & 0 deletions sdk/storage/storage-blob/src/BlobDownloadResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,15 @@ export class BlobDownloadResponse implements BlobDownloadResponseParsed {
return this.originalResponse.lastAccessed;
}

/**
* Returns the date and time the blob was created.
*
* @readonly
*/
public get createdOn(): Date | undefined {
return this.originalResponse.createdOn;
}

/**
* A name-value pair
* to associate with a file storage object.
Expand Down
2 changes: 2 additions & 0 deletions sdk/storage/storage-blob/src/generated/src/models/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions sdk/storage/storage-blob/src/generated/src/models/mappers.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions sdk/storage/storage-blob/src/generatedModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,8 @@ export interface PageRangeInfo {
end: number;
isClear: boolean;
}

/** Known values of {@link EncryptionAlgorithmType} that the service accepts. */
export enum KnownEncryptionAlgorithmType {
AES256 = "AES256",
}
2 changes: 1 addition & 1 deletion sdk/storage/storage-blob/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enable-xml: true
generate-metadata: false
license-header: MICROSOFT_MIT_NO_VERSION
output-folder: ../src/generated
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/080b332b7572514a2e100dd2fa1fb86cb8edcb08/specification/storage/data-plane/Microsoft.BlobStorage/preview/2021-12-02/blob.json
input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/3e6f238a1f74d77ba6970f297c77995a9f1f374e/specification/storage/data-plane/Microsoft.BlobStorage/preview/2021-12-02/blob.json
model-date-time-as-string: true
optional-response-headers: true
v3: true
Expand Down
1 change: 1 addition & 0 deletions sdk/storage/storage-blob/test/blobclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ describe("BlobClient", () => {
it("download with with default parameters", async () => {
const result = await blobClient.download();
assert.deepStrictEqual(await bodyToString(result, content.length), content);
assert.exists(result.createdOn);
});

it("download with progress report", async () => {
Expand Down
10 changes: 10 additions & 0 deletions sdk/storage/storage-file-datalake/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Release History

## 12.12.0 (Unreleased)

### Features Added

- Added FileReadHeaders.CreatedOn property for interface DataLakeFileClient.read().

### Bugs Fixed

- Renamed option 'leaseDuration' to 'leaseDurationInSeconds' in methods DataLakeFileClient.append() and flush(), the option was added in 12.12.0-beta.1.

## 12.12.0-beta.1 (2023-02-09)

### Features Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export interface FileAppendOptions extends CommonOptions {
flush?: boolean;
// Warning: (ae-forgotten-export) The symbol "LeaseAction" needs to be exported by the entry point index.d.ts
leaseAction?: LeaseAction;
leaseDuration?: number;
leaseDurationInSeconds?: number;
// (undocumented)
onProgress?: (progress: TransferProgressEvent) => void;
proposedLeaseId?: string;
Expand Down Expand Up @@ -568,7 +568,7 @@ export interface FileFlushOptions extends CommonOptions {
conditions?: DataLakeRequestConditions;
customerProvidedKey?: CpkInfo;
leaseAction?: LeaseAction;
leaseDuration?: number;
leaseDurationInSeconds?: number;
// (undocumented)
pathHttpHeaders?: PathHttpHeaders;
proposedLeaseId?: string;
Expand Down Expand Up @@ -676,6 +676,7 @@ export interface FileReadHeaders {
copyStatus?: CopyStatusType;
// (undocumented)
copyStatusDescription?: string;
createdOn?: Date;
// (undocumented)
date?: Date;
// (undocumented)
Expand Down
4 changes: 2 additions & 2 deletions sdk/storage/storage-file-datalake/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,7 @@ export class DataLakeFileClient extends DataLakePathClient {
cpkInfo: options.customerProvidedKey,
flush: options.flush,
proposedLeaseId: options.proposedLeaseId,
leaseDuration: options.leaseDuration,
leaseDuration: options.leaseDurationInSeconds,
leaseAction: options.leaseAction,
...convertTracingToRequestOptionsBase(updatedOptions),
});
Expand Down Expand Up @@ -1451,7 +1451,7 @@ export class DataLakeFileClient extends DataLakePathClient {
modifiedAccessConditions: options.conditions,
cpkInfo: options.customerProvidedKey,
proposedLeaseId: options.proposedLeaseId,
leaseDuration: options.leaseDuration,
leaseDuration: options.leaseDurationInSeconds,
leaseAction: options.leaseAction,
...convertTracingToRequestOptionsBase(updatedOptions),
});
Expand Down
8 changes: 6 additions & 2 deletions sdk/storage/storage-file-datalake/src/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,10 @@ export interface FileReadOptions extends CommonOptions {

export interface FileReadHeaders {
lastModified?: Date;
/**
* Returns the date and time the file was created.
*/
createdOn?: Date;
metadata?: Metadata;
contentLength?: number;
contentType?: string;
Expand Down Expand Up @@ -1229,7 +1233,7 @@ export interface FileAppendOptions extends CommonOptions {
/**
* The lease duration is required to acquire a lease, and specifies the duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 for infinite lease.
* */
leaseDuration?: number;
leaseDurationInSeconds?: number;
/**
* Optional. If "acquire" it will acquire the lease. If "auto-renew" it will renew the lease. If "release" it will release the lease only on flush. If "acquire-release" it will acquire & complete the operation & release the lease once operation is done.
* */
Expand All @@ -1253,7 +1257,7 @@ export interface FileFlushOptions extends CommonOptions {
/**
* The lease duration is required to acquire a lease, and specifies the duration of the lease in seconds. The lease duration must be between 15 and 60 seconds or -1 for infinite lease.
*/
leaseDuration?: number;
leaseDurationInSeconds?: number;
/**
* Optional. If "acquire" it will acquire the lease. If "auto-renew" it will renew the lease. If "release" it will release the lease only on flush. If "acquire-release" it will acquire & complete the operation & release the lease once operation is done.
*/
Expand Down
9 changes: 5 additions & 4 deletions sdk/storage/storage-file-datalake/test/pathclient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ describe("DataLakePathClient", () => {
it("read with with default parameters", async () => {
const result = await fileClient.read();
assert.deepStrictEqual(await bodyToString(result, content.length), content);
assert.exists(result.createdOn);
});

it("read should not have aborted error after read finishes", async () => {
Expand Down Expand Up @@ -809,7 +810,7 @@ describe("DataLakePathClient", () => {

await tempFileClient.append(body, 0, body.length, {
proposedLeaseId: leaseId,
leaseDuration: 15,
leaseDurationInSeconds: 15,
leaseAction: "acquire",
});

Expand Down Expand Up @@ -870,7 +871,7 @@ describe("DataLakePathClient", () => {
}
await tempFileClient.append(body, 0, body.length, {
conditions: { leaseId: leaseId },
leaseDuration: 15,
leaseDurationInSeconds: 15,
leaseAction: "auto-renew",
});

Expand Down Expand Up @@ -939,7 +940,7 @@ describe("DataLakePathClient", () => {

await tempFileClient.flush(body.length * 2, {
proposedLeaseId: leaseId,
leaseDuration: 15,
leaseDurationInSeconds: 15,
leaseAction: "acquire",
});

Expand Down Expand Up @@ -994,7 +995,7 @@ describe("DataLakePathClient", () => {

await tempFileClient.flush(body.length * 2, {
conditions: { leaseId: leaseId },
leaseDuration: 15,
leaseDurationInSeconds: 15,
leaseAction: "auto-renew",
});

Expand Down

0 comments on commit 0ce3065

Please sign in to comment.