Skip to content

Commit

Permalink
adding timeout parameter for new apis (#41887)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrandes authored Sep 17, 2024
1 parent 43ff155 commit 1b99978
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion sdk/storage/azure-storage-file-share/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/storage/azure-storage-file-share",
"Tag": "java/storage/azure-storage-file-share_0ba84ce27c"
"Tag": "java/storage/azure-storage-file-share_4152d3ba84"
}
Original file line number Diff line number Diff line change
Expand Up @@ -1946,7 +1946,7 @@ public String createPermission(String filePermission) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public String createPermission(ShareFilePermission filePermission) {
return createPermissionWithResponse(filePermission, Context.NONE).getValue();
return createPermissionWithResponse(filePermission, null, Context.NONE).getValue();
}

/**
Expand Down Expand Up @@ -1986,23 +1986,27 @@ public Response<String> createPermissionWithResponse(String filePermission, Cont
* <pre>
* ShareFilePermission permission = new ShareFilePermission&#40;&#41;.setPermission&#40;&quot;filePermission&quot;&#41;
* .setPermissionFormat&#40;FilePermissionFormat.BINARY&#41;;
* Response&lt;String&gt; response1 = shareClient.createPermissionWithResponse&#40;permission, Context.NONE&#41;;
* Response&lt;String&gt; response1 = shareClient.createPermissionWithResponse&#40;permission, null, Context.NONE&#41;;
* System.out.printf&#40;&quot;The file permission key is %s&quot;, response1.getValue&#40;&#41;&#41;;
* </pre>
* <!-- end com.azure.storage.file.share.ShareClient.createPermissionWithResponse#ShareFilePermission-context -->
*
* @param filePermission The file permission to get/create.
* @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 that contains the file permission key associated with the file permission.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<String> createPermissionWithResponse(ShareFilePermission filePermission, Context context) {
public Response<String> createPermissionWithResponse(ShareFilePermission filePermission, Duration timeout, Context context) {
Context finalContext = context == null ? Context.NONE : context;
SharePermission sharePermission = new SharePermission().setPermission(filePermission.getPermission())
.setFormat(filePermission.getPermissionFormat());
ResponseBase<SharesCreatePermissionHeaders, Void> response = this.azureFileStorageClient.getShares()

Callable<ResponseBase<SharesCreatePermissionHeaders, Void>> operation = () -> this.azureFileStorageClient.getShares()
.createPermissionWithResponse(shareName, sharePermission, null, finalContext);

ResponseBase<SharesCreatePermissionHeaders, Void> response = sendRequest(operation, timeout, ShareStorageException.class);

return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsFilePermissionKey());
}

Expand Down Expand Up @@ -2048,7 +2052,7 @@ public String getPermission(String filePermissionKey) {
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public String getPermission(String filePermissionKey, FilePermissionFormat filePermissionFormat) {
return getPermissionWithResponse(filePermissionKey, filePermissionFormat, Context.NONE).getValue();
return getPermissionWithResponse(filePermissionKey, filePermissionFormat, null, Context.NONE).getValue();
}

/**
Expand Down Expand Up @@ -2085,7 +2089,7 @@ public Response<String> getPermissionWithResponse(String filePermissionKey, Cont
* <pre>
* FilePermissionFormat filePermissionFormat = FilePermissionFormat.BINARY;
* Response&lt;String&gt; response1 = shareClient.getPermissionWithResponse&#40;&quot;filePermissionKey&quot;,
* filePermissionFormat, Context.NONE&#41;;
* filePermissionFormat, null, Context.NONE&#41;;
* System.out.printf&#40;&quot;The file permission is %s&quot;, response1.getValue&#40;&#41;&#41;;
* </pre>
* <!-- end com.azure.storage.file.share.ShareClient.getPermissionWithResponse#string-FilePermissionFormat-context -->
Expand All @@ -2095,15 +2099,21 @@ public Response<String> getPermissionWithResponse(String filePermissionKey, Cont
* the permission is returned. If filePermissionFormat is unspecified or explicitly set to SDDL, the permission will
* be returned in SSDL format. If filePermissionFormat is explicity set to binary, the permission is returned as a
* base64 string representing the binary encoding of the permission in self-relative format.
* @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 that contains th file permission associated with the file permission key.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<String> getPermissionWithResponse(String filePermissionKey, FilePermissionFormat filePermissionFormat, Context context) {
public Response<String> getPermissionWithResponse(String filePermissionKey, FilePermissionFormat filePermissionFormat,
Duration timeout, Context context) {
Context finalContext = context == null ? Context.NONE : context;
ResponseBase<SharesGetPermissionHeaders, SharePermission> response = this.azureFileStorageClient.getShares()

Callable<ResponseBase<SharesGetPermissionHeaders, SharePermission>> operation = () -> this.azureFileStorageClient.getShares()
.getPermissionWithResponse(shareName, filePermissionKey, filePermissionFormat, null, finalContext);

ResponseBase<SharesGetPermissionHeaders, SharePermission> response = sendRequest(operation, timeout,
ShareStorageException.class);

return new SimpleResponse<>(response, response.getValue().getPermission());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ public void createPermissionAsync() {

/**
* Generates a code sample for using {@link ShareClient#createPermissionWithResponse(String, Context)} and
* {@link ShareClient#createPermissionWithResponse(ShareFilePermission, Context)}
* {@link ShareClient#createPermissionWithResponse(ShareFilePermission, Duration, Context)}
*/
public void createPermissionWithResponse() {
ShareClient shareClient = createClientWithSASToken();
Expand All @@ -683,7 +683,7 @@ public void createPermissionWithResponse() {
// BEGIN: com.azure.storage.file.share.ShareClient.createPermissionWithResponse#ShareFilePermission-context
ShareFilePermission permission = new ShareFilePermission().setPermission("filePermission")
.setPermissionFormat(FilePermissionFormat.BINARY);
Response<String> response1 = shareClient.createPermissionWithResponse(permission, Context.NONE);
Response<String> response1 = shareClient.createPermissionWithResponse(permission, null, Context.NONE);
System.out.printf("The file permission key is %s", response1.getValue());
// END: com.azure.storage.file.share.ShareClient.createPermissionWithResponse#ShareFilePermission-context
}
Expand All @@ -708,7 +708,7 @@ public void getPermission() {

/**
* Generates a code sample for using {@link ShareClient#getPermissionWithResponse(String, Context)} and
* {@link ShareClient#getPermissionWithResponse(String, FilePermissionFormat, Context)}
* {@link ShareClient#getPermissionWithResponse(String, FilePermissionFormat, Duration, Context)}
*/
public void getPermissionWithResponse() {
ShareClient shareClient = createClientWithSASToken();
Expand All @@ -720,11 +720,9 @@ public void getPermissionWithResponse() {
// BEGIN: com.azure.storage.file.share.ShareClient.getPermissionWithResponse#string-FilePermissionFormat-context
FilePermissionFormat filePermissionFormat = FilePermissionFormat.BINARY;
Response<String> response1 = shareClient.getPermissionWithResponse("filePermissionKey",
filePermissionFormat, Context.NONE);
filePermissionFormat, null, Context.NONE);
System.out.printf("The file permission is %s", response1.getValue());
// END: com.azure.storage.file.share.ShareClient.getPermissionWithResponse#string-FilePermissionFormat-context


}

/**
Expand Down

0 comments on commit 1b99978

Please sign in to comment.