Skip to content

Commit 1b99978

Browse files
authored
adding timeout parameter for new apis (#41887)
1 parent 43ff155 commit 1b99978

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

sdk/storage/azure-storage-file-share/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "java",
44
"TagPrefix": "java/storage/azure-storage-file-share",
5-
"Tag": "java/storage/azure-storage-file-share_0ba84ce27c"
5+
"Tag": "java/storage/azure-storage-file-share_4152d3ba84"
66
}

sdk/storage/azure-storage-file-share/src/main/java/com/azure/storage/file/share/ShareClient.java

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ public String createPermission(String filePermission) {
19461946
*/
19471947
@ServiceMethod(returns = ReturnType.SINGLE)
19481948
public String createPermission(ShareFilePermission filePermission) {
1949-
return createPermissionWithResponse(filePermission, Context.NONE).getValue();
1949+
return createPermissionWithResponse(filePermission, null, Context.NONE).getValue();
19501950
}
19511951

19521952
/**
@@ -1986,23 +1986,27 @@ public Response<String> createPermissionWithResponse(String filePermission, Cont
19861986
* <pre>
19871987
* ShareFilePermission permission = new ShareFilePermission&#40;&#41;.setPermission&#40;&quot;filePermission&quot;&#41;
19881988
* .setPermissionFormat&#40;FilePermissionFormat.BINARY&#41;;
1989-
* Response&lt;String&gt; response1 = shareClient.createPermissionWithResponse&#40;permission, Context.NONE&#41;;
1989+
* Response&lt;String&gt; response1 = shareClient.createPermissionWithResponse&#40;permission, null, Context.NONE&#41;;
19901990
* System.out.printf&#40;&quot;The file permission key is %s&quot;, response1.getValue&#40;&#41;&#41;;
19911991
* </pre>
19921992
* <!-- end com.azure.storage.file.share.ShareClient.createPermissionWithResponse#ShareFilePermission-context -->
19931993
*
19941994
* @param filePermission The file permission to get/create.
1995+
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
19951996
* @param context Additional context that is passed through the Http pipeline during the service call.
19961997
* @return A response that contains the file permission key associated with the file permission.
19971998
*/
19981999
@ServiceMethod(returns = ReturnType.SINGLE)
1999-
public Response<String> createPermissionWithResponse(ShareFilePermission filePermission, Context context) {
2000+
public Response<String> createPermissionWithResponse(ShareFilePermission filePermission, Duration timeout, Context context) {
20002001
Context finalContext = context == null ? Context.NONE : context;
20012002
SharePermission sharePermission = new SharePermission().setPermission(filePermission.getPermission())
20022003
.setFormat(filePermission.getPermissionFormat());
2003-
ResponseBase<SharesCreatePermissionHeaders, Void> response = this.azureFileStorageClient.getShares()
2004+
2005+
Callable<ResponseBase<SharesCreatePermissionHeaders, Void>> operation = () -> this.azureFileStorageClient.getShares()
20042006
.createPermissionWithResponse(shareName, sharePermission, null, finalContext);
20052007

2008+
ResponseBase<SharesCreatePermissionHeaders, Void> response = sendRequest(operation, timeout, ShareStorageException.class);
2009+
20062010
return new SimpleResponse<>(response, response.getDeserializedHeaders().getXMsFilePermissionKey());
20072011
}
20082012

@@ -2048,7 +2052,7 @@ public String getPermission(String filePermissionKey) {
20482052
*/
20492053
@ServiceMethod(returns = ReturnType.SINGLE)
20502054
public String getPermission(String filePermissionKey, FilePermissionFormat filePermissionFormat) {
2051-
return getPermissionWithResponse(filePermissionKey, filePermissionFormat, Context.NONE).getValue();
2055+
return getPermissionWithResponse(filePermissionKey, filePermissionFormat, null, Context.NONE).getValue();
20522056
}
20532057

20542058
/**
@@ -2085,7 +2089,7 @@ public Response<String> getPermissionWithResponse(String filePermissionKey, Cont
20852089
* <pre>
20862090
* FilePermissionFormat filePermissionFormat = FilePermissionFormat.BINARY;
20872091
* Response&lt;String&gt; response1 = shareClient.getPermissionWithResponse&#40;&quot;filePermissionKey&quot;,
2088-
* filePermissionFormat, Context.NONE&#41;;
2092+
* filePermissionFormat, null, Context.NONE&#41;;
20892093
* System.out.printf&#40;&quot;The file permission is %s&quot;, response1.getValue&#40;&#41;&#41;;
20902094
* </pre>
20912095
* <!-- end com.azure.storage.file.share.ShareClient.getPermissionWithResponse#string-FilePermissionFormat-context -->
@@ -2095,15 +2099,21 @@ public Response<String> getPermissionWithResponse(String filePermissionKey, Cont
20952099
* the permission is returned. If filePermissionFormat is unspecified or explicitly set to SDDL, the permission will
20962100
* be returned in SSDL format. If filePermissionFormat is explicity set to binary, the permission is returned as a
20972101
* base64 string representing the binary encoding of the permission in self-relative format.
2102+
* @param timeout An optional timeout value beyond which a {@link RuntimeException} will be raised.
20982103
* @param context Additional context that is passed through the Http pipeline during the service call.
20992104
* @return A response that contains th file permission associated with the file permission key.
21002105
*/
21012106
@ServiceMethod(returns = ReturnType.SINGLE)
2102-
public Response<String> getPermissionWithResponse(String filePermissionKey, FilePermissionFormat filePermissionFormat, Context context) {
2107+
public Response<String> getPermissionWithResponse(String filePermissionKey, FilePermissionFormat filePermissionFormat,
2108+
Duration timeout, Context context) {
21032109
Context finalContext = context == null ? Context.NONE : context;
2104-
ResponseBase<SharesGetPermissionHeaders, SharePermission> response = this.azureFileStorageClient.getShares()
2110+
2111+
Callable<ResponseBase<SharesGetPermissionHeaders, SharePermission>> operation = () -> this.azureFileStorageClient.getShares()
21052112
.getPermissionWithResponse(shareName, filePermissionKey, filePermissionFormat, null, finalContext);
21062113

2114+
ResponseBase<SharesGetPermissionHeaders, SharePermission> response = sendRequest(operation, timeout,
2115+
ShareStorageException.class);
2116+
21072117
return new SimpleResponse<>(response, response.getValue().getPermission());
21082118
}
21092119

sdk/storage/azure-storage-file-share/src/samples/java/com/azure/storage/file/share/ShareJavaDocCodeSamples.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -671,7 +671,7 @@ public void createPermissionAsync() {
671671

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

709709
/**
710710
* Generates a code sample for using {@link ShareClient#getPermissionWithResponse(String, Context)} and
711-
* {@link ShareClient#getPermissionWithResponse(String, FilePermissionFormat, Context)}
711+
* {@link ShareClient#getPermissionWithResponse(String, FilePermissionFormat, Duration, Context)}
712712
*/
713713
public void getPermissionWithResponse() {
714714
ShareClient shareClient = createClientWithSASToken();
@@ -720,11 +720,9 @@ public void getPermissionWithResponse() {
720720
// BEGIN: com.azure.storage.file.share.ShareClient.getPermissionWithResponse#string-FilePermissionFormat-context
721721
FilePermissionFormat filePermissionFormat = FilePermissionFormat.BINARY;
722722
Response<String> response1 = shareClient.getPermissionWithResponse("filePermissionKey",
723-
filePermissionFormat, Context.NONE);
723+
filePermissionFormat, null, Context.NONE);
724724
System.out.printf("The file permission is %s", response1.getValue());
725725
// END: com.azure.storage.file.share.ShareClient.getPermissionWithResponse#string-FilePermissionFormat-context
726-
727-
728726
}
729727

730728
/**

0 commit comments

Comments
 (0)