Skip to content

Commit

Permalink
Fix missing response fields using transforms (#5440)
Browse files Browse the repository at this point in the history
  • Loading branch information
alzimmermsft authored Sep 23, 2019
1 parent 63af760 commit 84abfdf
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ Mono<Response<AppendBlobItem>> appendBlockFromUrlWithResponse(URL sourceURL, Blo
destAccessConditions.getLeaseAccessConditions(),
destAccessConditions.getAppendPositionAccessConditions(),
destAccessConditions.getModifiedAccessConditions(), sourceAccessConditions, context))
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.getDeserializedHeaders(),
rb.getHeaders().getValue("x-ms-request-server-encrypted"))));
.map(rb -> new SimpleResponse<>(rb, new AppendBlobItem(rb.getDeserializedHeaders())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,7 @@ Mono<Response<PageBlobItem>> uploadPagesFromURLWithResponse(PageRange range, URL
null, null, sourceURL, sourceRangeString, 0, rangeString, sourceContentMD5, null, null, null, cpk,
destAccessConditions.getLeaseAccessConditions(), destAccessConditions.getSequenceNumberAccessConditions(),
destAccessConditions.getModifiedAccessConditions(), sourceAccessConditions, context))
.map(rb -> new SimpleResponse<>(rb, new PageBlobItem(rb.getDeserializedHeaders(),
rb.getHeaders().getValue("x-ms-encryption-key-sha256"))));
.map(rb -> new SimpleResponse<>(rb, new PageBlobItem(rb.getDeserializedHeaders())));
}

/**
Expand Down Expand Up @@ -354,9 +353,7 @@ Mono<Response<PageBlobItem>> clearPagesWithResponse(PageRange pageRange,
pageBlobAccessConditions.getLeaseAccessConditions(), cpk,
pageBlobAccessConditions.getSequenceNumberAccessConditions(),
pageBlobAccessConditions.getModifiedAccessConditions(), context))
.map(rb -> new SimpleResponse<>(rb, new PageBlobItem(rb.getDeserializedHeaders(),
rb.getHeaders().getValue("x-ms-request-server-encrypted"),
rb.getHeaders().getValue("x-ms-encryption-key-sha256"))));
.map(rb -> new SimpleResponse<>(rb, new PageBlobItem(rb.getDeserializedHeaders())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ public final class AppendBlobAppendBlockFromUrlHeaders {
@JsonProperty(value = "x-ms-encryption-key-sha256")
private String encryptionKeySha256;

/*
* 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.
*/
@JsonProperty(value = "x-ms-request-server-encrypted")
private Boolean isServerEncrypted;

/*
* The errorCode property.
*/
Expand Down Expand Up @@ -351,6 +359,30 @@ public AppendBlobAppendBlockFromUrlHeaders setEncryptionKeySha256(String encrypt
return this;
}

/**
* Get the isServerEncrypted property: 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.
*
* @return the isServerEncrypted value.
*/
public Boolean isServerEncrypted() {
return this.isServerEncrypted;
}

/**
* Set the isServerEncrypted property: 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.
*
* @param isServerEncrypted the isServerEncrypted value to set.
* @return the AppendBlobAppendBlockFromUrlHeaders object itself.
*/
public AppendBlobAppendBlockFromUrlHeaders setIsServerEncrypted(Boolean isServerEncrypted) {
this.isServerEncrypted = isServerEncrypted;
return this;
}

/**
* Get the errorCode property: The errorCode property.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ public AppendBlobItem(AppendBlobAppendBlockHeaders generatedHeaders) {
this.blobCommittedBlockCount = generatedHeaders.getBlobCommittedBlockCount();
}

public AppendBlobItem(AppendBlobAppendBlockFromUrlHeaders generatedHeaders, String isServerEncryptedHeader) {
public AppendBlobItem(AppendBlobAppendBlockFromUrlHeaders generatedHeaders) {
this.eTag = generatedHeaders.getETag();
this.lastModified = generatedHeaders.getLastModified();
this.contentMD5 = generatedHeaders.getContentMD5();
this.isServerEncrypted = Boolean.parseBoolean(isServerEncryptedHeader);
this.isServerEncrypted = generatedHeaders.isServerEncrypted();
this.encryptionKeySha256 = generatedHeaders.getEncryptionKeySha256();
this.blobAppendOffset = generatedHeaders.getBlobAppendOffset();
this.blobCommittedBlockCount = generatedHeaders.getBlobCommittedBlockCount();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,22 @@ public final class PageBlobClearPagesHeaders {
@JsonProperty(value = "Date")
private DateTimeRfc1123 dateProperty;

/*
* 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.
*/
@JsonProperty(value = "x-ms-request-server-encrypted")
private Boolean isServerEncrypted;

/*
* 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.
*/
@JsonProperty(value = "x-ms-encryption-key-sha256")
private String encryptionKeySha256;

/*
* The errorCode property.
*/
Expand Down Expand Up @@ -318,6 +334,54 @@ public PageBlobClearPagesHeaders setDateProperty(OffsetDateTime dateProperty) {
return this;
}

/**
* Get the isServerEncrypted property: 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.
*
* @return the isServerEncrypted value.
*/
public Boolean isServerEncrypted() {
return this.isServerEncrypted;
}

/**
* Set the isServerEncrypted property: 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.
*
* @param isServerEncrypted the isServerEncrypted value to set.
* @return the PageBlobClearPagesHeaders object itself.
*/
public PageBlobClearPagesHeaders setIsServerEncrypted(Boolean isServerEncrypted) {
this.isServerEncrypted = isServerEncrypted;
return this;
}

/**
* Get the encryptionKeySha256 property: 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.
*
* @return the encryptionKeySha256 value.
*/
public String getEncryptionKeySha256() {
return this.encryptionKeySha256;
}

/**
* Set the encryptionKeySha256 property: 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.
*
* @param encryptionKeySha256 the encryptionKeySha256 value to set.
* @return the PageBlobClearPagesHeaders object itself.
*/
public PageBlobClearPagesHeaders setEncryptionKeySha256(String encryptionKeySha256) {
this.encryptionKeySha256 = encryptionKeySha256;
return this;
}

/**
* Get the errorCode property: The errorCode property.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,21 @@ public PageBlobItem(PageBlobUploadPagesHeaders generatedHeaders) {
this.blobSequenceNumber = generatedHeaders.getBlobSequenceNumber();
}

public PageBlobItem(PageBlobUploadPagesFromURLHeaders generatedHeaders, String encryptionKeySha256Header) {
public PageBlobItem(PageBlobUploadPagesFromURLHeaders generatedHeaders) {
this.eTag = generatedHeaders.getETag();
this.lastModified = generatedHeaders.getLastModified();
this.contentMD5 = generatedHeaders.getContentMD5();
this.isServerEncrypted = generatedHeaders.isServerEncrypted();
this.encryptionKeySha256 = encryptionKeySha256Header;
this.encryptionKeySha256 = generatedHeaders.getEncryptionKeySha256();
this.blobSequenceNumber = generatedHeaders.getBlobSequenceNumber();
}

public PageBlobItem(PageBlobClearPagesHeaders generatedHeaders, String isServerEncryptedHeader,
String encryptionKeySha256Header) {
public PageBlobItem(PageBlobClearPagesHeaders generatedHeaders) {
this.eTag = generatedHeaders.getETag();
this.lastModified = generatedHeaders.getLastModified();
this.contentMD5 = generatedHeaders.getContentMD5();
this.isServerEncrypted = Boolean.parseBoolean(isServerEncryptedHeader);
this.encryptionKeySha256 = encryptionKeySha256Header;
this.isServerEncrypted = generatedHeaders.isServerEncrypted();
this.encryptionKeySha256 = generatedHeaders.getEncryptionKeySha256();
this.blobSequenceNumber = generatedHeaders.getBlobSequenceNumber();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ public final class PageBlobUploadPagesFromURLHeaders {
@JsonProperty(value = "x-ms-request-server-encrypted")
private Boolean isServerEncrypted;

/*
* 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.
*/
@JsonProperty(value = "x-ms-encryption-key-sha256")
private String encryptionKeySha256;

/*
* The errorCode property.
*/
Expand Down Expand Up @@ -319,6 +327,30 @@ public PageBlobUploadPagesFromURLHeaders setIsServerEncrypted(Boolean isServerEn
return this;
}

/**
* Get the encryptionKeySha256 property: 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.
*
* @return the encryptionKeySha256 value.
*/
public String getEncryptionKeySha256() {
return this.encryptionKeySha256;
}

/**
* Set the encryptionKeySha256 property: 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.
*
* @param encryptionKeySha256 the encryptionKeySha256 value to set.
* @return the PageBlobUploadPagesFromURLHeaders object itself.
*/
public PageBlobUploadPagesFromURLHeaders setEncryptionKeySha256(String encryptionKeySha256) {
this.encryptionKeySha256 = encryptionKeySha256;
return this;
}

/**
* Get the errorCode property: The errorCode property.
*
Expand Down
51 changes: 51 additions & 0 deletions sdk/storage/azure-storage-blob/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -882,3 +882,54 @@ directive:
"@JsonDeserialize(using = CustomHierarchicalListingDeserializer.class)\npublic final class BlobHierarchyListSegment {");
```
### 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."
};
}
```

0 comments on commit 84abfdf

Please sign in to comment.