diff --git a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml
index b39b25ffc59c..9f2ab7237ea1 100755
--- a/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml
+++ b/eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml
@@ -473,6 +473,7 @@
+
+
+
+
+
+
+
@@ -603,11 +610,11 @@
-
+
-
+
diff --git a/eng/code-quality-reports/src/main/resources/revapi/revapi.json b/eng/code-quality-reports/src/main/resources/revapi/revapi.json
index bc69bcd19c16..c5ead03aa977 100644
--- a/eng/code-quality-reports/src/main/resources/revapi/revapi.json
+++ b/eng/code-quality-reports/src/main/resources/revapi/revapi.json
@@ -235,6 +235,17 @@
"code": "java\\.class\\.externalClassExposedInAPI",
"new": "(interface|class|enum) io\\.opentelemetry.*",
"justification": "Azure Monitor Exporter is allowed to use OpenTelemetry types in public APIs as it implements interfaces defined by OpenTelemetry"
+ },
+ {
+ "code": "java.annotation.attributeAdded",
+ "old": "class com.azure.messaging.eventhubs.EventHubClientBuilder",
+ "new": "class com.azure.messaging.eventhubs.EventHubClientBuilder",
+ "justification": "Setting protocol to AMQP in @ServiceClientBuilder annotation is not a breaking change"
+ },
+ {
+ "code": "java.annotation.added",
+ "new": "class com.azure.storage.blob.models.PageList",
+ "justification": "Annotation required to resolve deserialization bug."
}
]
}
diff --git a/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml b/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml
index 9c83c11e658b..05a4da3620ee 100755
--- a/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml
+++ b/eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml
@@ -1333,6 +1333,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -2441,4 +2458,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/eng/common/README.md b/eng/common/README.md
index e63b74367b74..7bda6ec94208 100644
--- a/eng/common/README.md
+++ b/eng/common/README.md
@@ -20,7 +20,6 @@ The 'Sync eng/common directory' PRs will be created in the language repositories
3. The `azure-sdk-tools - sync - eng-common` pipeline queues test runs for template pipelines in various languages. These help you test your changes in the **Tools PR**.
4. If there are changes in the **Tools PR** that will affect the release stage you should approve the release test pipelines by clicking the approval gate. The test (template) pipeline will automatically release the next eligible version without needing manual intervention for the versioning. Please approve your test releases as quickly as possible. A race condition may occur due to someone else queueing the pipeline and going all the way to release using your version while yours is still waiting. If this occurs manually rerun the pipeline that failed.
5. If you make additional changes to your **Tools PR** repeat steps 1 - 4 until you have completed the necessary testing of your changes. This includes full releases of the template package, if necessary.
-6. Sign off on CreateSyncPRs stage of the sync pipeline using the approval gate. This stage will create the **Sync PRs** in the various language repos with the `auto-merge` label applied. A link to each of the **Sync PRs** will show up in the **Tools PR** for you to click and review.
-7. Go review and approve each of your **Sync PRs**. The merging will happen automatically.
-8. Sign off on VerifyAndMerge stage of the sync pipeline using the approval gate. This stage will merge any remaining open **Sync PRs** and also append `auto-merge` to the **Tools PR** so it will automatically merge once the pipeline finishes.
-7. Sign Off on the VerifyAndMerge stage. This will merge any remaining open **Sync PR** and also append `auto-merge` to the **Tools PR**.
+6. Sign off on CreateSyncPRs stage of the sync pipeline using the approval gate. This stage will create the **Sync PRs** in the various language repos. A link to each of the **Sync PRs** will show up in the **Tools PR** for you to click and review.
+7. Go review and approve each of your **Sync PRs**.
+8. Sign Off on the VerifyAndMerge stage. This will merge any remaining open **Sync PR** and also append `auto-merge` to the **Tools PR**.
diff --git a/eng/common/TestResources/New-TestResources.ps1.md b/eng/common/TestResources/New-TestResources.ps1.md
index 6fc15eefdb49..c41693c87666 100644
--- a/eng/common/TestResources/New-TestResources.ps1.md
+++ b/eng/common/TestResources/New-TestResources.ps1.md
@@ -449,7 +449,7 @@ Accept wildcard characters: False
```
### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
diff --git a/eng/common/TestResources/Remove-TestResources.ps1.md b/eng/common/TestResources/Remove-TestResources.ps1.md
index 18317cec07cc..8c99997e0731 100644
--- a/eng/common/TestResources/Remove-TestResources.ps1.md
+++ b/eng/common/TestResources/Remove-TestResources.ps1.md
@@ -263,7 +263,7 @@ Accept wildcard characters: False
```
### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
diff --git a/eng/common/pipelines/templates/steps/docs-metadata-release.yml b/eng/common/pipelines/templates/steps/docs-metadata-release.yml
index 2b57bcf7f413..45f12580f10e 100644
--- a/eng/common/pipelines/templates/steps/docs-metadata-release.yml
+++ b/eng/common/pipelines/templates/steps/docs-metadata-release.yml
@@ -8,8 +8,8 @@ parameters:
ScriptDirectory: eng/common/scripts
TargetDocRepoName: ''
TargetDocRepoOwner: ''
- PRBranchName: 'smoke-test-rdme'
- SourceBranchName: 'smoke-test'
+ PRBranchName: 'master-rdme'
+ SourceBranchName: 'master'
PRLabels: 'auto-merge'
ArtifactName: ''
Language: ''
diff --git a/eng/common/scripts/Delete-RemoteBranches.ps1 b/eng/common/scripts/Delete-RemoteBranches.ps1
index 0ca7c55be932..77cf7e506461 100644
--- a/eng/common/scripts/Delete-RemoteBranches.ps1
+++ b/eng/common/scripts/Delete-RemoteBranches.ps1
@@ -9,7 +9,7 @@ param(
LogDebug "Operating on Repo [ $RepoName ]"
try{
- $branches = (Get-GitHubSourceReferences -RepoOwner $RepoOwner -RepoName $RepoName -Ref "heads/$BranchPrefix").ref
+ $branches = (Get-GitHubSourceReferences -RepoOwner $RepoOwner -RepoName $RepoName -Ref "heads/$BranchPrefix" -AuthToken $AuthToken).ref
}
catch {
LogError "Get-GitHubSourceReferences failed with exception:`n$_"
@@ -22,7 +22,7 @@ foreach ($branch in $branches)
$branchName = $branch.Replace("refs/heads/","")
$head = "${RepoOwner}/${RepoName}:${branchName}"
LogDebug "Operating on branch [ $branchName ]"
- $pullRequests = Get-GitHubPullRequests -RepoOwner $RepoOwner -RepoName $RepoName -head $head
+ $pullRequests = Get-GitHubPullRequests -RepoOwner $RepoOwner -RepoName $RepoName -State "all" -Head $head -AuthToken $AuthToken
}
catch
{
@@ -30,9 +30,9 @@ foreach ($branch in $branches)
exit 1
}
- if ($pullRequests.Count -eq 0)
+ if ($pullRequests -and (($pullRequests | ? { $_.State -eq "open" }).Count -eq 0))
{
- LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated Pull Request. Deleting Branch"
+ LogDebug "Branch [ $branchName ] in repo [ $RepoName ] has no associated open Pull Request. Deleting Branch"
try{
Remove-GitHubSourceReferences -RepoOwner $RepoOwner -RepoName $RepoName -Ref ($branch.Remove(0,5)) -AuthToken $AuthToken
}
diff --git a/eng/common/scripts/Verify-Links.ps1 b/eng/common/scripts/Verify-Links.ps1
index 9376564e3472..c9991a058894 100644
--- a/eng/common/scripts/Verify-Links.ps1
+++ b/eng/common/scripts/Verify-Links.ps1
@@ -200,6 +200,10 @@ function CheckLink ([System.Uri]$linkUri)
}
if ($checkLinkGuidance) {
+ if ($linkUri.Scheme -eq 'http') {
+ LogWarning "DO NOT use 'http' in $linkUri. Please use secure link with https instead. Check here for more information: https://aka.ms/azsdk/guideline/links"
+ $linkValid = $false
+ }
$link = $linkUri.ToString()
# Check if the url is relative links, suppress the archor link validation.
if (!$linkUri.IsAbsoluteUri -and !$link.StartsWith("#")) {
diff --git a/sdk/communication/azure-communication-administration/pom.xml b/sdk/communication/azure-communication-administration/pom.xml
index 5bda961599a0..951bea5a2777 100644
--- a/sdk/communication/azure-communication-administration/pom.xml
+++ b/sdk/communication/azure-communication-administration/pom.xml
@@ -57,12 +57,6 @@
azure-core1.9.0
-
- com.azure
- azure-core-http-netty
- 1.6.2
- test
- com.azureazure-communication-common
diff --git a/sdk/communication/azure-communication-chat/pom.xml b/sdk/communication/azure-communication-chat/pom.xml
index 2c44b8fc24f5..666eee2cab2d 100644
--- a/sdk/communication/azure-communication-chat/pom.xml
+++ b/sdk/communication/azure-communication-chat/pom.xml
@@ -51,12 +51,6 @@
azure-communication-administration1.0.0-beta.3
-
- com.azure
- azure-core-http-netty
- 1.6.2
- test
- com.azureazure-core-test
diff --git a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTestBase.java b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTestBase.java
index 8f5b5eb87c58..5e158ff24597 100644
--- a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTestBase.java
+++ b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatClientTestBase.java
@@ -11,16 +11,12 @@
import com.azure.communication.chat.models.*;
import com.azure.communication.common.CommunicationUserCredential;
import com.azure.core.exception.HttpResponseException;
-import com.azure.core.http.policy.FixedDelay;
-import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.HttpClient;
import com.azure.core.test.TestBase;
import com.azure.core.test.TestMode;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
-
-import java.time.Duration;
import java.time.ZonedDateTime;
import java.time.LocalDateTime;
import java.time.ZoneId;
@@ -44,8 +40,6 @@ public class ChatClientTestBase extends TestBase {
protected static final String CONNSTRING = Configuration.getGlobalConfiguration()
.get("COMMUNICATION_SERVICES_CONNECTION_STRING", "pw==");
- protected static final FixedDelay RETRY_STRATEGY = new FixedDelay(3, Duration.ofMillis(1000));
-
protected ChatClientBuilder getChatClientBuilder(String token, HttpClient httpClient) {
ChatClientBuilder builder = new ChatClientBuilder();
@@ -60,10 +54,7 @@ protected ChatClientBuilder getChatClientBuilder(String token, HttpClient httpCl
builder.credential(new CommunicationUserCredential(token));
}
- if (interceptorManager.isLiveMode()) {
- builder.addPolicy(new RetryPolicy(RETRY_STRATEGY));
- }
- else {
+ if (getTestMode() == TestMode.RECORD) {
builder.addPolicy(interceptorManager.getRecordPolicy());
}
diff --git a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatThreadAsyncClientTest.java b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatThreadAsyncClientTest.java
index 4de7058cccc6..ecbf507a668b 100644
--- a/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatThreadAsyncClientTest.java
+++ b/sdk/communication/azure-communication-chat/src/test/java/com/azure/communication/chat/ChatThreadAsyncClientTest.java
@@ -5,6 +5,8 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
@@ -176,8 +178,7 @@ public void canAddListAndRemoveMembersWithResponseAsync(HttpClient httpClient) t
}
assertTrue(returnedMembers.size() == 4);
- })
- .verifyComplete();
+ });
for (ChatThreadMember member: options.getMembers()) {
StepVerifier.create(chatThreadClient.removeMemberWithResponse(member.getUser()))
@@ -408,6 +409,9 @@ public void canSendTypingNotificationWithResponse(HttpClient httpClient) {
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
+ @DisabledIfEnvironmentVariable(
+ named = "SKIP_LIVE_TEST",
+ matches = "(?i)(true)")
public void canSendThenListReadReceipts(HttpClient httpClient) throws InterruptedException {
// Arrange
setupTest(httpClient);
@@ -431,16 +435,16 @@ public void canSendThenListReadReceipts(HttpClient httpClient) throws Interrupte
assertEquals(resp.getStatusCode(), 200);
resp.getItems().forEach(item -> returnedReadReceipts.add(item));
});
-
- if (interceptorManager.isPlaybackMode()) {
- assertTrue(returnedReadReceipts.size() > 0);
- checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
- }
+ assertTrue(returnedReadReceipts.size() > 0);
+ checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
});
}
@ParameterizedTest
@MethodSource("com.azure.core.test.TestBase#getHttpClients")
+ @DisabledIfEnvironmentVariable(
+ named = "SKIP_LIVE_TEST",
+ matches = "(?i)(true)")
public void canSendThenListReadReceiptsWithResponse(HttpClient httpClient) throws InterruptedException {
// Arrange
setupTest(httpClient);
@@ -466,12 +470,9 @@ public void canSendThenListReadReceiptsWithResponse(HttpClient httpClient) throw
resp.getItems().forEach(item -> returnedReadReceipts.add(item));
});
- if (interceptorManager.isPlaybackMode()) {
- assertTrue(returnedReadReceipts.size() > 0);
- checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
- }
- })
- .verifyComplete();
+ assertTrue(returnedReadReceipts.size() > 0);
+ checkReadReceiptListContainsMessageId(returnedReadReceipts, messageResponseRef.get().getId());
+ });
}
}
diff --git a/sdk/communication/tests.yml b/sdk/communication/tests.yml
index a35bb4f6fb49..a435579fb140 100644
--- a/sdk/communication/tests.yml
+++ b/sdk/communication/tests.yml
@@ -9,8 +9,10 @@ jobs:
safeName: azurecommunicationadministration
- name: azure-communication-chat
groupId: com.azure
- safeName: azurecommunicationchatclient
+ safeName: azurecommunicationchat
ServiceDirectory: communication
EnvVars:
AZURE_TEST_MODE: LIVE
SKIP_PHONENUMBER_INTEGRATION_TESTS: TRUE
+ SKIP_LIVE_TEST: TRUE
+
diff --git a/sdk/compute/mgmt-v2018_04_01/pom.xml b/sdk/compute/mgmt-v2018_04_01/pom.xml
index 04828ca27096..aa50a52a1b51 100644
--- a/sdk/compute/mgmt-v2018_04_01/pom.xml
+++ b/sdk/compute/mgmt-v2018_04_01/pom.xml
@@ -11,15 +11,15 @@
com.microsoft.azureazure-arm-parent
- 1.2.0
- ../../parents/azure-arm-parent
+ 1.1.0
+ ../../../pom.management.xmlazure-mgmt-compute1.0.0-betajarMicrosoft Azure SDK for Compute ManagementThis package contains Microsoft Compute Management SDK.
- https://github.com/Azure/azure-libraries-for-java
+ https://github.com/Azure/azure-sdk-for-javaThe MIT License (MIT)
@@ -28,8 +28,8 @@
- scm:git:https://github.com/Azure/azure-libraries-for-java
- scm:git:git@github.com:Azure/azure-libraries-for-java.git
+ scm:git:https://github.com/Azure/azure-sdk-for-java
+ scm:git:git@github.com:Azure/azure-sdk-for-java.gitHEAD
@@ -71,6 +71,8 @@
azure-arm-client-runtimetest-jartest
+
+ 1.6.5
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/CreationData.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/CreationData.java
index a87d4de13915..fc7b1af28ba8 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/CreationData.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/CreationData.java
@@ -51,7 +51,7 @@ public class CreationData {
private String sourceResourceId;
/**
- * Get the createOption value.
+ * Get this enumerates the possible sources of a disk's creation. Possible values include: 'Empty', 'Attach', 'FromImage', 'Import', 'Copy', 'Restore'.
*
* @return the createOption value
*/
@@ -60,7 +60,7 @@ public DiskCreateOption createOption() {
}
/**
- * Set the createOption value.
+ * Set this enumerates the possible sources of a disk's creation. Possible values include: 'Empty', 'Attach', 'FromImage', 'Import', 'Copy', 'Restore'.
*
* @param createOption the createOption value to set
* @return the CreationData object itself.
@@ -71,7 +71,7 @@ public CreationData withCreateOption(DiskCreateOption createOption) {
}
/**
- * Get the storageAccountId value.
+ * Get if createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a different subscription.
*
* @return the storageAccountId value
*/
@@ -80,7 +80,7 @@ public String storageAccountId() {
}
/**
- * Set the storageAccountId value.
+ * Set if createOption is Import, the Azure Resource Manager identifier of the storage account containing the blob to import as a disk. Required only if the blob is in a different subscription.
*
* @param storageAccountId the storageAccountId value to set
* @return the CreationData object itself.
@@ -91,7 +91,7 @@ public CreationData withStorageAccountId(String storageAccountId) {
}
/**
- * Get the imageReference value.
+ * Get disk source information.
*
* @return the imageReference value
*/
@@ -100,7 +100,7 @@ public ImageDiskReference imageReference() {
}
/**
- * Set the imageReference value.
+ * Set disk source information.
*
* @param imageReference the imageReference value to set
* @return the CreationData object itself.
@@ -111,7 +111,7 @@ public CreationData withImageReference(ImageDiskReference imageReference) {
}
/**
- * Get the sourceUri value.
+ * Get if createOption is Import, this is the URI of a blob to be imported into a managed disk.
*
* @return the sourceUri value
*/
@@ -120,7 +120,7 @@ public String sourceUri() {
}
/**
- * Set the sourceUri value.
+ * Set if createOption is Import, this is the URI of a blob to be imported into a managed disk.
*
* @param sourceUri the sourceUri value to set
* @return the CreationData object itself.
@@ -131,7 +131,7 @@ public CreationData withSourceUri(String sourceUri) {
}
/**
- * Get the sourceResourceId value.
+ * Get if createOption is Copy, this is the ARM id of the source snapshot or disk.
*
* @return the sourceResourceId value
*/
@@ -140,7 +140,7 @@ public String sourceResourceId() {
}
/**
- * Set the sourceResourceId value.
+ * Set if createOption is Copy, this is the ARM id of the source snapshot or disk.
*
* @param sourceResourceId the sourceResourceId value to set
* @return the CreationData object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Disk.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Disk.java
index 7c48e8958d0f..61e0c60b2797 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Disk.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Disk.java
@@ -10,12 +10,12 @@
import com.microsoft.azure.arm.model.HasInner;
import com.microsoft.azure.arm.resources.models.Resource;
+import com.microsoft.azure.arm.resources.models.GroupableResourceCore;
import com.microsoft.azure.arm.resources.models.HasResourceGroup;
import com.microsoft.azure.arm.model.Refreshable;
import com.microsoft.azure.arm.model.Updatable;
import com.microsoft.azure.arm.model.Appliable;
import com.microsoft.azure.arm.model.Creatable;
-import com.microsoft.azure.arm.resources.models.GroupableResourceCore;
import com.microsoft.azure.arm.resources.models.HasManager;
import com.microsoft.azure.management.compute.v2018_04_01.implementation.ComputeManager;
import java.util.List;
@@ -99,56 +99,68 @@ interface WithGroup extends GroupableResourceCore.DefinitionStages.WithGroup zones);
}
@@ -172,41 +184,49 @@ interface Update extends Appliable, Resource.UpdateWithTags, Updat
*/
interface UpdateStages {
/**
- * The stage of the disk {0} allowing to specify DiskSizeGB.
+ * The stage of the disk update allowing to specify DiskSizeGB.
*/
interface WithDiskSizeGB {
/**
* Specifies diskSizeGB.
+ * @param diskSizeGB If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size
+ * @return the next update stage
*/
Update withDiskSizeGB(Integer diskSizeGB);
}
/**
- * The stage of the disk {0} allowing to specify EncryptionSettings.
+ * The stage of the disk update allowing to specify EncryptionSettings.
*/
interface WithEncryptionSettings {
/**
* Specifies encryptionSettings.
+ * @param encryptionSettings Encryption settings for disk or snapshot
+ * @return the next update stage
*/
Update withEncryptionSettings(EncryptionSettings encryptionSettings);
}
/**
- * The stage of the disk {0} allowing to specify OsType.
+ * The stage of the disk update allowing to specify OsType.
*/
interface WithOsType {
/**
* Specifies osType.
+ * @param osType the Operating System type. Possible values include: 'Windows', 'Linux'
+ * @return the next update stage
*/
Update withOsType(OperatingSystemTypes osType);
}
/**
- * The stage of the disk {0} allowing to specify Sku.
+ * The stage of the disk update allowing to specify Sku.
*/
interface WithSku {
/**
* Specifies sku.
+ * @param sku the sku parameter value
+ * @return the next update stage
*/
Update withSku(DiskSku sku);
}
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskSku.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskSku.java
index 097f3fb3ec28..67754d466609 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskSku.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskSku.java
@@ -11,11 +11,12 @@
import com.fasterxml.jackson.annotation.JsonProperty;
/**
- * The disks sku name. Can be Standard_LRS or Premium_LRS.
+ * The disks sku name. Can be Standard_LRS, Premium_LRS, or StandardSSD_LRS.
*/
public class DiskSku {
/**
- * The sku name. Possible values include: 'Standard_LRS', 'Premium_LRS'.
+ * The sku name. Possible values include: 'Standard_LRS', 'Premium_LRS',
+ * 'StandardSSD_LRS'.
*/
@JsonProperty(value = "name")
private StorageAccountTypes name;
@@ -27,7 +28,7 @@ public class DiskSku {
private String tier;
/**
- * Get the name value.
+ * Get the sku name. Possible values include: 'Standard_LRS', 'Premium_LRS', 'StandardSSD_LRS'.
*
* @return the name value
*/
@@ -36,7 +37,7 @@ public StorageAccountTypes name() {
}
/**
- * Set the name value.
+ * Set the sku name. Possible values include: 'Standard_LRS', 'Premium_LRS', 'StandardSSD_LRS'.
*
* @param name the name value to set
* @return the DiskSku object itself.
@@ -47,7 +48,7 @@ public DiskSku withName(StorageAccountTypes name) {
}
/**
- * Get the tier value.
+ * Get the sku tier.
*
* @return the tier value
*/
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskUpdate.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskUpdate.java
index f5602037c9d5..feb7386edaa1 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskUpdate.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/DiskUpdate.java
@@ -52,7 +52,7 @@ public class DiskUpdate {
private DiskSku sku;
/**
- * Get the osType value.
+ * Get the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @return the osType value
*/
@@ -61,7 +61,7 @@ public OperatingSystemTypes osType() {
}
/**
- * Set the osType value.
+ * Set the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @param osType the osType value to set
* @return the DiskUpdate object itself.
@@ -72,7 +72,7 @@ public DiskUpdate withOsType(OperatingSystemTypes osType) {
}
/**
- * Get the diskSizeGB value.
+ * Get if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @return the diskSizeGB value
*/
@@ -81,7 +81,7 @@ public Integer diskSizeGB() {
}
/**
- * Set the diskSizeGB value.
+ * Set if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @param diskSizeGB the diskSizeGB value to set
* @return the DiskUpdate object itself.
@@ -92,7 +92,7 @@ public DiskUpdate withDiskSizeGB(Integer diskSizeGB) {
}
/**
- * Get the encryptionSettings value.
+ * Get encryption settings for disk or snapshot.
*
* @return the encryptionSettings value
*/
@@ -101,7 +101,7 @@ public EncryptionSettings encryptionSettings() {
}
/**
- * Set the encryptionSettings value.
+ * Set encryption settings for disk or snapshot.
*
* @param encryptionSettings the encryptionSettings value to set
* @return the DiskUpdate object itself.
@@ -112,7 +112,7 @@ public DiskUpdate withEncryptionSettings(EncryptionSettings encryptionSettings)
}
/**
- * Get the tags value.
+ * Get resource tags.
*
* @return the tags value
*/
@@ -121,7 +121,7 @@ public Map tags() {
}
/**
- * Set the tags value.
+ * Set resource tags.
*
* @param tags the tags value to set
* @return the DiskUpdate object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/EncryptionSettings.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/EncryptionSettings.java
index a5241ab8fc1c..fc35f8a0efdb 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/EncryptionSettings.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/EncryptionSettings.java
@@ -37,7 +37,7 @@ public class EncryptionSettings {
private KeyVaultAndKeyReference keyEncryptionKey;
/**
- * Get the enabled value.
+ * Get set this flag to true and provide DiskEncryptionKey and optional KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, the existing settings remain unchanged.
*
* @return the enabled value
*/
@@ -46,7 +46,7 @@ public Boolean enabled() {
}
/**
- * Set the enabled value.
+ * Set set this flag to true and provide DiskEncryptionKey and optional KeyEncryptionKey to enable encryption. Set this flag to false and remove DiskEncryptionKey and KeyEncryptionKey to disable encryption. If EncryptionSettings is null in the request object, the existing settings remain unchanged.
*
* @param enabled the enabled value to set
* @return the EncryptionSettings object itself.
@@ -57,7 +57,7 @@ public EncryptionSettings withEnabled(Boolean enabled) {
}
/**
- * Get the diskEncryptionKey value.
+ * Get key Vault Secret Url and vault id of the disk encryption key.
*
* @return the diskEncryptionKey value
*/
@@ -66,7 +66,7 @@ public KeyVaultAndSecretReference diskEncryptionKey() {
}
/**
- * Set the diskEncryptionKey value.
+ * Set key Vault Secret Url and vault id of the disk encryption key.
*
* @param diskEncryptionKey the diskEncryptionKey value to set
* @return the EncryptionSettings object itself.
@@ -77,7 +77,7 @@ public EncryptionSettings withDiskEncryptionKey(KeyVaultAndSecretReference diskE
}
/**
- * Get the keyEncryptionKey value.
+ * Get key Vault Key Url and vault id of the key encryption key.
*
* @return the keyEncryptionKey value
*/
@@ -86,7 +86,7 @@ public KeyVaultAndKeyReference keyEncryptionKey() {
}
/**
- * Set the keyEncryptionKey value.
+ * Set key Vault Key Url and vault id of the key encryption key.
*
* @param keyEncryptionKey the keyEncryptionKey value to set
* @return the EncryptionSettings object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/GrantAccessData.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/GrantAccessData.java
index 2acd3f446e0b..9900d5d6e582 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/GrantAccessData.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/GrantAccessData.java
@@ -27,7 +27,7 @@ public class GrantAccessData {
private int durationInSeconds;
/**
- * Get the access value.
+ * Get possible values include: 'None', 'Read'.
*
* @return the access value
*/
@@ -36,7 +36,7 @@ public AccessLevel access() {
}
/**
- * Set the access value.
+ * Set possible values include: 'None', 'Read'.
*
* @param access the access value to set
* @return the GrantAccessData object itself.
@@ -47,7 +47,7 @@ public GrantAccessData withAccess(AccessLevel access) {
}
/**
- * Get the durationInSeconds value.
+ * Get time duration in seconds until the SAS access expires.
*
* @return the durationInSeconds value
*/
@@ -56,7 +56,7 @@ public int durationInSeconds() {
}
/**
- * Set the durationInSeconds value.
+ * Set time duration in seconds until the SAS access expires.
*
* @param durationInSeconds the durationInSeconds value to set
* @return the GrantAccessData object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/ImageDiskReference.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/ImageDiskReference.java
index cc8e4681e2e8..8bf454e778a6 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/ImageDiskReference.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/ImageDiskReference.java
@@ -15,7 +15,7 @@
*/
public class ImageDiskReference {
/**
- * A relative uri containing either a Platform Imgage Repository or user
+ * A relative uri containing either a Platform Image Repository or user
* image reference.
*/
@JsonProperty(value = "id", required = true)
@@ -30,7 +30,7 @@ public class ImageDiskReference {
private Integer lun;
/**
- * Get the id value.
+ * Get a relative uri containing either a Platform Image Repository or user image reference.
*
* @return the id value
*/
@@ -39,7 +39,7 @@ public String id() {
}
/**
- * Set the id value.
+ * Set a relative uri containing either a Platform Image Repository or user image reference.
*
* @param id the id value to set
* @return the ImageDiskReference object itself.
@@ -50,7 +50,7 @@ public ImageDiskReference withId(String id) {
}
/**
- * Get the lun value.
+ * Get if the disk is created from an image's data disk, this is an index that indicates which of the data disks in the image to use. For OS disks, this field is null.
*
* @return the lun value
*/
@@ -59,7 +59,7 @@ public Integer lun() {
}
/**
- * Set the lun value.
+ * Set if the disk is created from an image's data disk, this is an index that indicates which of the data disks in the image to use. For OS disks, this field is null.
*
* @param lun the lun value to set
* @return the ImageDiskReference object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndKeyReference.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndKeyReference.java
index 90267cab5b20..1c6f73aa511c 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndKeyReference.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndKeyReference.java
@@ -28,7 +28,7 @@ public class KeyVaultAndKeyReference {
private String keyUrl;
/**
- * Get the sourceVault value.
+ * Get resource id of the KeyVault containing the key or secret.
*
* @return the sourceVault value
*/
@@ -37,7 +37,7 @@ public SourceVault sourceVault() {
}
/**
- * Set the sourceVault value.
+ * Set resource id of the KeyVault containing the key or secret.
*
* @param sourceVault the sourceVault value to set
* @return the KeyVaultAndKeyReference object itself.
@@ -48,7 +48,7 @@ public KeyVaultAndKeyReference withSourceVault(SourceVault sourceVault) {
}
/**
- * Get the keyUrl value.
+ * Get url pointing to a key or secret in KeyVault.
*
* @return the keyUrl value
*/
@@ -57,7 +57,7 @@ public String keyUrl() {
}
/**
- * Set the keyUrl value.
+ * Set url pointing to a key or secret in KeyVault.
*
* @param keyUrl the keyUrl value to set
* @return the KeyVaultAndKeyReference object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndSecretReference.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndSecretReference.java
index 6c10230ace1e..7401445d48ae 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndSecretReference.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/KeyVaultAndSecretReference.java
@@ -27,7 +27,7 @@ public class KeyVaultAndSecretReference {
private String secretUrl;
/**
- * Get the sourceVault value.
+ * Get resource id of the KeyVault containing the key or secret.
*
* @return the sourceVault value
*/
@@ -36,7 +36,7 @@ public SourceVault sourceVault() {
}
/**
- * Set the sourceVault value.
+ * Set resource id of the KeyVault containing the key or secret.
*
* @param sourceVault the sourceVault value to set
* @return the KeyVaultAndSecretReference object itself.
@@ -47,7 +47,7 @@ public KeyVaultAndSecretReference withSourceVault(SourceVault sourceVault) {
}
/**
- * Get the secretUrl value.
+ * Get url pointing to a key or secret in KeyVault.
*
* @return the secretUrl value
*/
@@ -56,7 +56,7 @@ public String secretUrl() {
}
/**
- * Set the secretUrl value.
+ * Set url pointing to a key or secret in KeyVault.
*
* @param secretUrl the secretUrl value to set
* @return the KeyVaultAndSecretReference object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Snapshot.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Snapshot.java
index 92adc4673818..545fed5986ea 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Snapshot.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/Snapshot.java
@@ -10,12 +10,12 @@
import com.microsoft.azure.arm.model.HasInner;
import com.microsoft.azure.arm.resources.models.Resource;
+import com.microsoft.azure.arm.resources.models.GroupableResourceCore;
import com.microsoft.azure.arm.resources.models.HasResourceGroup;
import com.microsoft.azure.arm.model.Refreshable;
import com.microsoft.azure.arm.model.Updatable;
import com.microsoft.azure.arm.model.Appliable;
import com.microsoft.azure.arm.model.Creatable;
-import com.microsoft.azure.arm.resources.models.GroupableResourceCore;
import com.microsoft.azure.arm.resources.models.HasManager;
import com.microsoft.azure.management.compute.v2018_04_01.implementation.ComputeManager;
import org.joda.time.DateTime;
@@ -93,46 +93,56 @@ interface WithGroup extends GroupableResourceCore.DefinitionStages.WithGroup, Resource.UpdateWithTags, U
*/
interface UpdateStages {
/**
- * The stage of the snapshot {0} allowing to specify DiskSizeGB.
+ * The stage of the snapshot update allowing to specify DiskSizeGB.
*/
interface WithDiskSizeGB {
/**
* Specifies diskSizeGB.
+ * @param diskSizeGB If creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size
+ * @return the next update stage
*/
Update withDiskSizeGB(Integer diskSizeGB);
}
/**
- * The stage of the snapshot {0} allowing to specify EncryptionSettings.
+ * The stage of the snapshot update allowing to specify EncryptionSettings.
*/
interface WithEncryptionSettings {
/**
* Specifies encryptionSettings.
+ * @param encryptionSettings Encryption settings for disk or snapshot
+ * @return the next update stage
*/
Update withEncryptionSettings(EncryptionSettings encryptionSettings);
}
/**
- * The stage of the snapshot {0} allowing to specify OsType.
+ * The stage of the snapshot update allowing to specify OsType.
*/
interface WithOsType {
/**
* Specifies osType.
+ * @param osType the Operating System type. Possible values include: 'Windows', 'Linux'
+ * @return the next update stage
*/
Update withOsType(OperatingSystemTypes osType);
}
/**
- * The stage of the snapshot {0} allowing to specify Sku.
+ * The stage of the snapshot update allowing to specify Sku.
*/
interface WithSku {
/**
* Specifies sku.
+ * @param sku the sku parameter value
+ * @return the next update stage
*/
Update withSku(SnapshotSku sku);
}
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotSku.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotSku.java
index bc818ea5a01d..22d99739aba3 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotSku.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotSku.java
@@ -28,7 +28,7 @@ public class SnapshotSku {
private String tier;
/**
- * Get the name value.
+ * Get the sku name. Possible values include: 'Standard_LRS', 'Premium_LRS', 'Standard_ZRS'.
*
* @return the name value
*/
@@ -37,7 +37,7 @@ public SnapshotStorageAccountTypes name() {
}
/**
- * Set the name value.
+ * Set the sku name. Possible values include: 'Standard_LRS', 'Premium_LRS', 'Standard_ZRS'.
*
* @param name the name value to set
* @return the SnapshotSku object itself.
@@ -48,7 +48,7 @@ public SnapshotSku withName(SnapshotStorageAccountTypes name) {
}
/**
- * Get the tier value.
+ * Get the sku tier.
*
* @return the tier value
*/
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotUpdate.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotUpdate.java
index 12720526308c..49b4e929c422 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotUpdate.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SnapshotUpdate.java
@@ -52,7 +52,7 @@ public class SnapshotUpdate {
private SnapshotSku sku;
/**
- * Get the osType value.
+ * Get the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @return the osType value
*/
@@ -61,7 +61,7 @@ public OperatingSystemTypes osType() {
}
/**
- * Set the osType value.
+ * Set the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @param osType the osType value to set
* @return the SnapshotUpdate object itself.
@@ -72,7 +72,7 @@ public SnapshotUpdate withOsType(OperatingSystemTypes osType) {
}
/**
- * Get the diskSizeGB value.
+ * Get if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @return the diskSizeGB value
*/
@@ -81,7 +81,7 @@ public Integer diskSizeGB() {
}
/**
- * Set the diskSizeGB value.
+ * Set if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @param diskSizeGB the diskSizeGB value to set
* @return the SnapshotUpdate object itself.
@@ -92,7 +92,7 @@ public SnapshotUpdate withDiskSizeGB(Integer diskSizeGB) {
}
/**
- * Get the encryptionSettings value.
+ * Get encryption settings for disk or snapshot.
*
* @return the encryptionSettings value
*/
@@ -101,7 +101,7 @@ public EncryptionSettings encryptionSettings() {
}
/**
- * Set the encryptionSettings value.
+ * Set encryption settings for disk or snapshot.
*
* @param encryptionSettings the encryptionSettings value to set
* @return the SnapshotUpdate object itself.
@@ -112,7 +112,7 @@ public SnapshotUpdate withEncryptionSettings(EncryptionSettings encryptionSettin
}
/**
- * Get the tags value.
+ * Get resource tags.
*
* @return the tags value
*/
@@ -121,7 +121,7 @@ public Map tags() {
}
/**
- * Set the tags value.
+ * Set resource tags.
*
* @param tags the tags value to set
* @return the SnapshotUpdate object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SourceVault.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SourceVault.java
index d75a766895de..f9b619ffa113 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SourceVault.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/SourceVault.java
@@ -11,7 +11,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
/**
- * The vault id is an Azure Resource Manager Resoure id in the form
+ * The vault id is an Azure Resource Manager Resource id in the form
* /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}.
*/
public class SourceVault {
@@ -22,7 +22,7 @@ public class SourceVault {
private String id;
/**
- * Get the id value.
+ * Get resource Id.
*
* @return the id value
*/
@@ -31,7 +31,7 @@ public String id() {
}
/**
- * Set the id value.
+ * Set resource Id.
*
* @param id the id value to set
* @return the SourceVault object itself.
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/StorageAccountTypes.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/StorageAccountTypes.java
index 495a8e5b9ece..08086adbdf0f 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/StorageAccountTypes.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/StorageAccountTypes.java
@@ -22,6 +22,9 @@ public final class StorageAccountTypes extends ExpandableStringEnum zones() {
}
/**
- * Set the zones value.
+ * Set the Logical zone list for Disk.
*
* @param zones the zones value to set
* @return the DiskInner object itself.
@@ -132,7 +132,7 @@ public DiskInner withZones(List zones) {
}
/**
- * Get the timeCreated value.
+ * Get the time when the disk was created.
*
* @return the timeCreated value
*/
@@ -141,7 +141,7 @@ public DateTime timeCreated() {
}
/**
- * Get the osType value.
+ * Get the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @return the osType value
*/
@@ -150,7 +150,7 @@ public OperatingSystemTypes osType() {
}
/**
- * Set the osType value.
+ * Set the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @param osType the osType value to set
* @return the DiskInner object itself.
@@ -161,7 +161,7 @@ public DiskInner withOsType(OperatingSystemTypes osType) {
}
/**
- * Get the creationData value.
+ * Get disk source information. CreationData information cannot be changed after the disk has been created.
*
* @return the creationData value
*/
@@ -170,7 +170,7 @@ public CreationData creationData() {
}
/**
- * Set the creationData value.
+ * Set disk source information. CreationData information cannot be changed after the disk has been created.
*
* @param creationData the creationData value to set
* @return the DiskInner object itself.
@@ -181,7 +181,7 @@ public DiskInner withCreationData(CreationData creationData) {
}
/**
- * Get the diskSizeGB value.
+ * Get if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @return the diskSizeGB value
*/
@@ -190,7 +190,7 @@ public Integer diskSizeGB() {
}
/**
- * Set the diskSizeGB value.
+ * Set if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @param diskSizeGB the diskSizeGB value to set
* @return the DiskInner object itself.
@@ -201,7 +201,7 @@ public DiskInner withDiskSizeGB(Integer diskSizeGB) {
}
/**
- * Get the encryptionSettings value.
+ * Get encryption settings for disk or snapshot.
*
* @return the encryptionSettings value
*/
@@ -210,7 +210,7 @@ public EncryptionSettings encryptionSettings() {
}
/**
- * Set the encryptionSettings value.
+ * Set encryption settings for disk or snapshot.
*
* @param encryptionSettings the encryptionSettings value to set
* @return the DiskInner object itself.
@@ -221,7 +221,7 @@ public DiskInner withEncryptionSettings(EncryptionSettings encryptionSettings) {
}
/**
- * Get the provisioningState value.
+ * Get the disk provisioning state.
*
* @return the provisioningState value
*/
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java
index 0bcf0a550ee6..5060f7a90944 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/DisksInner.java
@@ -41,6 +41,8 @@
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;
+import com.microsoft.azure.LongRunningFinalState;
+import com.microsoft.azure.LongRunningOperationOptions;
/**
* An instance of this class provides access to all the operations defined
@@ -1011,7 +1013,7 @@ public Observable> grantAccessWithServiceRespons
}
Validator.validate(grantAccessData);
Observable> observable = service.grantAccess(this.client.subscriptionId(), resourceGroupName, diskName, this.client.apiVersion(), grantAccessData, this.client.acceptLanguage(), this.client.userAgent());
- return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType());
+ return client.getAzureClient().getPostOrDeleteResultAsync(observable, new LongRunningOperationOptions().withFinalStateVia(LongRunningFinalState.LOCATION), new TypeToken() { }.getType());
}
/**
@@ -1174,7 +1176,7 @@ public Observable> revokeAccessWithServiceResponseAsync(St
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Observable> observable = service.revokeAccess(this.client.subscriptionId(), resourceGroupName, diskName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
- return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType());
+ return client.getAzureClient().getPostOrDeleteResultAsync(observable, new LongRunningOperationOptions().withFinalStateVia(LongRunningFinalState.LOCATION), new TypeToken() { }.getType());
}
/**
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotInner.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotInner.java
index 572638ea16d6..f2c3f31f7b07 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotInner.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotInner.java
@@ -76,7 +76,7 @@ public class SnapshotInner extends Resource {
private String provisioningState;
/**
- * Get the managedBy value.
+ * Get unused. Always Null.
*
* @return the managedBy value
*/
@@ -105,7 +105,7 @@ public SnapshotInner withSku(SnapshotSku sku) {
}
/**
- * Get the timeCreated value.
+ * Get the time when the disk was created.
*
* @return the timeCreated value
*/
@@ -114,7 +114,7 @@ public DateTime timeCreated() {
}
/**
- * Get the osType value.
+ * Get the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @return the osType value
*/
@@ -123,7 +123,7 @@ public OperatingSystemTypes osType() {
}
/**
- * Set the osType value.
+ * Set the Operating System type. Possible values include: 'Windows', 'Linux'.
*
* @param osType the osType value to set
* @return the SnapshotInner object itself.
@@ -134,7 +134,7 @@ public SnapshotInner withOsType(OperatingSystemTypes osType) {
}
/**
- * Get the creationData value.
+ * Get disk source information. CreationData information cannot be changed after the disk has been created.
*
* @return the creationData value
*/
@@ -143,7 +143,7 @@ public CreationData creationData() {
}
/**
- * Set the creationData value.
+ * Set disk source information. CreationData information cannot be changed after the disk has been created.
*
* @param creationData the creationData value to set
* @return the SnapshotInner object itself.
@@ -154,7 +154,7 @@ public SnapshotInner withCreationData(CreationData creationData) {
}
/**
- * Get the diskSizeGB value.
+ * Get if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @return the diskSizeGB value
*/
@@ -163,7 +163,7 @@ public Integer diskSizeGB() {
}
/**
- * Set the diskSizeGB value.
+ * Set if creationData.createOption is Empty, this field is mandatory and it indicates the size of the VHD to create. If this field is present for updates or creation with other options, it indicates a resize. Resizes are only allowed if the disk is not attached to a running VM, and can only increase the disk's size.
*
* @param diskSizeGB the diskSizeGB value to set
* @return the SnapshotInner object itself.
@@ -174,7 +174,7 @@ public SnapshotInner withDiskSizeGB(Integer diskSizeGB) {
}
/**
- * Get the encryptionSettings value.
+ * Get encryption settings for disk or snapshot.
*
* @return the encryptionSettings value
*/
@@ -183,7 +183,7 @@ public EncryptionSettings encryptionSettings() {
}
/**
- * Set the encryptionSettings value.
+ * Set encryption settings for disk or snapshot.
*
* @param encryptionSettings the encryptionSettings value to set
* @return the SnapshotInner object itself.
@@ -194,7 +194,7 @@ public SnapshotInner withEncryptionSettings(EncryptionSettings encryptionSetting
}
/**
- * Get the provisioningState value.
+ * Get the disk provisioning state.
*
* @return the provisioningState value
*/
diff --git a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotsInner.java b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotsInner.java
index 3b792dc6a90c..2018d522be49 100644
--- a/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotsInner.java
+++ b/sdk/compute/mgmt-v2018_04_01/src/main/java/com/microsoft/azure/management/compute/v2018_04_01/implementation/SnapshotsInner.java
@@ -41,6 +41,8 @@
import retrofit2.Response;
import rx.functions.Func1;
import rx.Observable;
+import com.microsoft.azure.LongRunningFinalState;
+import com.microsoft.azure.LongRunningOperationOptions;
/**
* An instance of this class provides access to all the operations defined
@@ -1011,7 +1013,7 @@ public Observable> grantAccessWithServiceRespons
}
Validator.validate(grantAccessData);
Observable> observable = service.grantAccess(this.client.subscriptionId(), resourceGroupName, snapshotName, this.client.apiVersion(), grantAccessData, this.client.acceptLanguage(), this.client.userAgent());
- return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType());
+ return client.getAzureClient().getPostOrDeleteResultAsync(observable, new LongRunningOperationOptions().withFinalStateVia(LongRunningFinalState.LOCATION), new TypeToken() { }.getType());
}
/**
@@ -1174,7 +1176,7 @@ public Observable> revokeAccessWithServiceResponseAsync(St
throw new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null.");
}
Observable> observable = service.revokeAccess(this.client.subscriptionId(), resourceGroupName, snapshotName, this.client.apiVersion(), this.client.acceptLanguage(), this.client.userAgent());
- return client.getAzureClient().getPostOrDeleteResultAsync(observable, new TypeToken() { }.getType());
+ return client.getAzureClient().getPostOrDeleteResultAsync(observable, new LongRunningOperationOptions().withFinalStateVia(LongRunningFinalState.LOCATION), new TypeToken() { }.getType());
}
/**
diff --git a/sdk/core/azure-core-experimental/CHANGELOG.md b/sdk/core/azure-core-experimental/CHANGELOG.md
index 369cd8bcefe5..9ed249c7810f 100644
--- a/sdk/core/azure-core-experimental/CHANGELOG.md
+++ b/sdk/core/azure-core-experimental/CHANGELOG.md
@@ -2,6 +2,7 @@
## 1.0.0-beta.7 (2020-10-08)
+- Added API `fromObject()` in `BinaryData` which uses `JsonSerializer` present in the classpath.
- Added APIs to `JsonPatchDocument` which accept pre-serialized JSON.
- Updated `azure-core` dependency to released version.
diff --git a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/util/BinaryData.java b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/util/BinaryData.java
index 2979599d21ca..060cda67f27b 100644
--- a/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/util/BinaryData.java
+++ b/sdk/core/azure-core-experimental/src/main/java/com/azure/core/experimental/util/BinaryData.java
@@ -5,7 +5,9 @@
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.serializer.JsonSerializerProviders;
import com.azure.core.util.serializer.ObjectSerializer;
+import com.azure.core.util.serializer.JsonSerializer;
import com.azure.core.util.serializer.TypeReference;
import static com.azure.core.util.FluxUtil.monoError;
@@ -18,18 +20,20 @@
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Objects;
/**
* This class is an abstraction over many different ways that binary data can be represented. The {@link BinaryData}
- * can be created from {@link InputStream}, {@link Flux} of {@link ByteBuffer}, {@link String}, {@link Object} and byte
- * array. The data is collected from provided sources and stored into a byte array.
+ * can be created from {@link InputStream}, {@link Flux} of {@link ByteBuffer}, {@link String}, {@link Object}, or byte
+ * array.
+ *
Immutable data
+ * {@link BinaryData} is constructed by copying the given data. Once {@link BinaryData} is instantiated, it can not be
+ * changed. It provides various convenient APIs to get data out of {@link BinaryData}, they all start with the 'to'
+ * prefix, for example {@link BinaryData#toBytes()}.
*
- * It also provides a way to serialize and deserialize an {@link Object} into {@link BinaryData} given an
- * {@link ObjectSerializer}. Code samples are explained below.
+ * Code samples are presented below.
*
*
+ * {@codesnippet com.azure.core.experimental.util.BinaryDocument.from#Object}
+ *
* @see ObjectSerializer
+ * @see JsonSerializer
+ * @see More about serialization
*/
public final class BinaryData {
private static final ClientLogger LOGGER = new ClientLogger(BinaryData.class);
- private final byte[] data;
+ private static final BinaryData EMPTY_DATA = new BinaryData(new byte[0]);
- /**
- * Create instance of {@link BinaryData} given the data.
- * @param data to represent as bytes.
- * @throws NullPointerException If {@code data} is null.
- */
- BinaryData(byte[] data) {
- Objects.requireNonNull(data, "'data' cannot be null.");
- this.data = Arrays.copyOf(data, data.length);
- }
+ private static final Object LOCK = new Object();
- /**
- * Provides {@link InputStream} for the data represented by this {@link BinaryData} object.
- *
- *
Get InputStream from BinaryData
- * {@codesnippet com.azure.core.experimental.util.BinaryDocument.to#Stream}
- *
- * @return {@link InputStream} representing the binary data.
- */
- public InputStream toStream() {
- return new ByteArrayInputStream(this.data);
- }
+ private final byte[] data;
+
+ private static volatile JsonSerializer defaultJsonSerializer;
/**
- * Provides {@link Mono} of {@link InputStream} for the data represented by this {@link BinaryData} object.
+ * Create an instance of {@link BinaryData} from the given data.
*
- * @return {@link InputStream} representation of the {@link BinaryData}.
+ * @param data to represent as bytes.
*/
- public Mono toStreamAsync() {
- return Mono.fromCallable(() -> toStream());
+ BinaryData(byte[] data) {
+ this.data = data;
}
/**
- * Create {@link BinaryData} instance with given {@link InputStream} as source of data. The {@link InputStream} is
- * not closed by this function.
+ * Creates a {@link BinaryData} instance with given {@link InputStream} as source of data. The {@link InputStream}
+ * is not closed by this function.
*
*
Create an instance from InputStream
* {@codesnippet com.azure.core.experimental.util.BinaryDocument.from#Stream}
*
* @param inputStream to read bytes from.
* @throws UncheckedIOException If any error in reading from {@link InputStream}.
- * @throws NullPointerException if {@code inputStream} is null.
+ * @throws NullPointerException If {@code inputStream} is null.
* @return {@link BinaryData} representing the binary data.
*/
public static BinaryData fromStream(InputStream inputStream) {
- Objects.requireNonNull(inputStream, "'inputStream' cannot be null.");
+ if (Objects.isNull(inputStream)) {
+ return EMPTY_DATA;
+ }
final int bufferSize = 1024;
try {
@@ -103,98 +98,125 @@ public static BinaryData fromStream(InputStream inputStream) {
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
dataOutputBuffer.write(data, 0, nRead);
}
+ dataOutputBuffer.flush();
+
+ return new BinaryData(dataOutputBuffer.toByteArray());
- return fromBytes(dataOutputBuffer.toByteArray());
} catch (IOException ex) {
throw LOGGER.logExceptionAsError(new UncheckedIOException(ex));
}
}
/**
- * Asynchronously create {@link BinaryData} instance with given {@link InputStream} as source of data. The
- * {@link InputStream} is not closed by this function.
+ * Asynchronously creates a {@link BinaryData} instance with the given {@link InputStream} as source of data. The
+ * {@link InputStream} is not closed by this function. If the {@link InputStream} is {@code null}, an empty
+ * {@link BinaryData} will be returned.
*
* @param inputStream to read bytes from.
- * @throws NullPointerException if {@code inputStream} is null.
* @return {@link Mono} of {@link BinaryData} representing the binary data.
*/
public static Mono fromStreamAsync(InputStream inputStream) {
- Objects.requireNonNull(inputStream, "'inputStream' cannot be null.");
-
return Mono.fromCallable(() -> fromStream(inputStream));
}
/**
- * Create {@link BinaryData} instance with given {@link Flux} of {@link ByteBuffer} as source of data. It will
- * collect all the bytes from {@link ByteBuffer} into {@link BinaryData}.
+ * Creates a {@link BinaryData} instance with given {@link Flux} of {@link ByteBuffer} as source of data. It will
+ * collect all the bytes from {@link ByteBuffer} into {@link BinaryData}. If the {@link Flux} is {@code null}, an
+ * empty {@link BinaryData} will be returned.
*
*
Create an instance from String
* {@codesnippet com.azure.core.experimental.util.BinaryDocument.from#Flux}
*
* @param data to use.
- * @throws NullPointerException if {@code inputStream} is null.
* @return {@link Mono} of {@link BinaryData} representing binary data.
*/
public static Mono fromFlux(Flux data) {
if (Objects.isNull(data)) {
- return monoError(LOGGER, new NullPointerException("'data' cannot be null."));
+ return Mono.just(EMPTY_DATA);
}
return FluxUtil.collectBytesInByteBufferStream(data)
- .flatMap(bytes -> Mono.just(fromBytes(bytes)));
+ .flatMap(bytes -> Mono.just(new BinaryData(bytes)));
}
/**
- * Create {@link BinaryData} instance with given data and character set.
- *
- *
Create an instance from String
- * {@codesnippet com.azure.core.experimental.util.BinaryDocument.from#String}
+ * Creates a {@link BinaryData} instance with given data. The {@link String} is converted into bytes using UTF_8
+ * character set. If the String is {@code null}, an empty {@link BinaryData} will be returned.
*
* @param data to use.
- * @param charSet to use.
- * @throws NullPointerException if {@code inputStream} is null.
- * @return {@link BinaryData} representing the binary data.
+ * @return {@link BinaryData} representing binary data.
*/
- public static BinaryData fromString(String data, Charset charSet) {
- Objects.requireNonNull(data, "'data' cannot be null.");
+ public static BinaryData fromString(String data) {
+ if (Objects.isNull(data) || data.length() == 0) {
+ return EMPTY_DATA;
+ }
- return new BinaryData(data.getBytes(charSet));
+ return new BinaryData(data.getBytes(StandardCharsets.UTF_8));
}
/**
- * Create {@link BinaryData} instance with given data. The {@link String} is converted into bytes using
- * {@link StandardCharsets#UTF_8} character set.
+ * Creates a {@link BinaryData} instance with given byte array data. If the byte array is {@code null}, an empty
+ * {@link BinaryData} will be returned.
*
* @param data to use.
- * @throws NullPointerException if {@code inputStream} is null.
- * @return {@link BinaryData} representing binary data.
+ * @return {@link BinaryData} representing the binary data.
*/
- public static BinaryData fromString(String data) {
- Objects.requireNonNull(data, "'data' cannot be null.");
+ public static BinaryData fromBytes(byte[] data) {
+ if (Objects.isNull(data) || data.length == 0) {
+ return EMPTY_DATA;
+ }
- return new BinaryData(data.getBytes(StandardCharsets.UTF_8));
+ return new BinaryData(Arrays.copyOf(data, data.length));
}
/**
- * Create {@link BinaryData} instance with given byte array data.
+ * Serialize the given {@link Object} into {@link BinaryData} using json serializer which is available on classpath.
+ * The serializer on classpath must implement {@link JsonSerializer} interface. If the given Object is {@code null},
+ * an empty {@link BinaryData} will be returned.
+ *
Code sample
+ * {@codesnippet com.azure.core.experimental.util.BinaryDocument.from.default.serializer#Object}
+
+ * @param data The {@link Object} which needs to be serialized into bytes.
+ * @throws IllegalStateException If a {@link JsonSerializer} cannot be found on the classpath.
+ * @return {@link BinaryData} representing the JSON serialized object.
*
- * @param data to use.
- * @return {@link BinaryData} representing the binary data.
+ * @see JsonSerializer
+ * @see More about serialization
*/
- public static BinaryData fromBytes(byte[] data) {
- return new BinaryData(data);
+ public static BinaryData fromObject(Object data) {
+ if (Objects.isNull(data)) {
+ return EMPTY_DATA;
+ }
+ final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ getDefaultSerializer().serialize(outputStream, data);
+
+ return new BinaryData(outputStream.toByteArray());
}
/**
* Serialize the given {@link Object} into {@link BinaryData} using the provided {@link ObjectSerializer}.
+ * If the Object is {@code null}, an empty {@link BinaryData} will be returned.
+ *
You can provide your custom implementation of {@link ObjectSerializer} interface or use one provided in azure
+ * sdk by adding them as dependency. These implementations could be found at
+ * Json Jackson serializer
+ * and Gson based serializer.
+ *
+ *
Create an instance from Object
+ * {@codesnippet com.azure.core.experimental.util.BinaryDocument.from#Object}
*
* @param data The {@link Object} which needs to be serialized into bytes.
* @param serializer to use for serializing the object.
- * @throws NullPointerException if {@code inputStream} or {@code serializer} is null.
+ * @throws NullPointerException If {@code serializer} is null.
* @return {@link BinaryData} representing binary data.
+ * @see ObjectSerializer
+ * @see JsonSerializer
+ * @see More about serialization
*/
public static BinaryData fromObject(Object data, ObjectSerializer serializer) {
- Objects.requireNonNull(data, "'data' cannot be null.");
+ if (Objects.isNull(data)) {
+ return EMPTY_DATA;
+ }
+
Objects.requireNonNull(serializer, "'serializer' cannot be null.");
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
@@ -204,19 +226,25 @@ public static BinaryData fromObject(Object data, ObjectSerializer serializer) {
/**
* Serialize the given {@link Object} into {@link Mono} {@link BinaryData} using the provided
- * {@link ObjectSerializer}.
+ * {@link ObjectSerializer}. If the Object is {@code null}, an empty {@link BinaryData} will be returned.
+ *
+ *
You can provide your custom implementation of {@link ObjectSerializer} interface or use one provided in azure
+ * sdk by adding them as dependency. These implementations could be found at
+ * Json Jackson serializer
+ * and Gson based serializer.
*
* @param data The {@link Object} which needs to be serialized into bytes.
* @param serializer to use for serializing the object.
- * @throws NullPointerException if {@code inputStream} or {@code serializer} is null.
+ * @throws NullPointerException If {@code serializer} is null.
* @return {@link Mono} of {@link BinaryData} representing the binary data.
+ * @see ObjectSerializer
+ * @see More about serialization
*/
public static Mono fromObjectAsync(Object data, ObjectSerializer serializer) {
- Objects.requireNonNull(data, "'data' cannot be null.");
- Objects.requireNonNull(serializer, "'serializer' cannot be null.");
-
+ if (Objects.isNull(serializer)) {
+ return monoError(LOGGER, new NullPointerException("'serializer' cannot be null."));
+ }
return Mono.fromCallable(() -> fromObject(data, serializer));
-
}
/**
@@ -230,7 +258,7 @@ public byte[] toBytes() {
/**
* Provides {@link String} representation of this {@link BinaryData} object. The bytes are converted into
- * {@link String} using {@link StandardCharsets#UTF_8} character set.
+ * {@link String} using the UTF-8 character set.
*
* @return {@link String} representation of the data.
*/
@@ -238,23 +266,21 @@ public String toString() {
return new String(this.data, StandardCharsets.UTF_8);
}
- /**
- * Provides {@link String} representation of this {@link BinaryData} object given a character set.
- *
- * @param charSet to use to convert bytes into {@link String}.
- * @return {@link String} representation of the the binary data.
- */
- public String toString(Charset charSet) {
- return new String(this.data, charSet);
- }
-
/**
* Deserialize the bytes into the {@link Object} of given type by applying the provided {@link ObjectSerializer} on
* the data.
*
+ *
You can provide your custom implementation of {@link ObjectSerializer} interface or use one provided in azure
+ * sdk by adding them as dependency. These implementations could be found at
+ * Json Jackson serializer
+ * and Gson based serializer.
+ *
+ *
Code sample
+ * {@codesnippet com.azure.core.experimental.util.BinaryDocument.to#Object}
* @param clazz representing the type of the Object.
* @param serializer to use deserialize data into type.
* @param Generic type that the data is deserialized into.
+ * @throws NullPointerException If {@code serializer} or {@code clazz} is null.
* @return The {@link Object} of given type after deserializing the bytes.
*/
public T toObject(Class clazz, ObjectSerializer serializer) {
@@ -267,8 +293,13 @@ public T toObject(Class clazz, ObjectSerializer serializer) {
}
/**
- * Return a {@link Mono} by deserialize the bytes into the {@link Object} of given type after applying the provided
- * {@link ObjectSerializer} on the {@link BinaryData}.
+ * Return a {@link Mono} by deserializing the bytes into the {@link Object} of given type after applying the
+ * provided {@link ObjectSerializer} on the {@link BinaryData}.
+ *
+ *
You can provide your custom implementation of {@link ObjectSerializer} interface or use one provided in azure
+ * sdk by adding them as dependency. These implementations could be found at
+ * Json Jackson serializer
+ * and Gson based serializer.
*
*
Gets the specified object
* {@codesnippet com.azure.core.experimental.util.BinaryDocument.to#ObjectAsync}
@@ -276,10 +307,77 @@ public T toObject(Class clazz, ObjectSerializer serializer) {
* @param clazz representing the type of the Object.
* @param serializer to use deserialize data into type.
* @param Generic type that the data is deserialized into.
- * @throws NullPointerException if {@code clazz} or {@code serializer} is null.
+ * @throws NullPointerException If {@code clazz} or {@code serializer} is null.
* @return The {@link Object} of given type after deserializing the bytes.
*/
public Mono toObjectAsync(Class clazz, ObjectSerializer serializer) {
+
+ if (Objects.isNull(clazz)) {
+ return monoError(LOGGER, new NullPointerException("'clazz' cannot be null."));
+ } else if (Objects.isNull(serializer)) {
+ return monoError(LOGGER, new NullPointerException("'serializer' cannot be null."));
+ }
return Mono.fromCallable(() -> toObject(clazz, serializer));
}
+
+ /**
+ * Deserialize the bytes into the {@link Object} of given type by using json serializer which is available in
+ * classpath. The serializer must implement {@link JsonSerializer} interface. A singleton instance of
+ * {@link JsonSerializer} is kept for this class to use.
+ *
+ * @param clazz representing the type of the Object.
+ * @param Generic type that the data is deserialized into.
+ * @throws NullPointerException If {@code clazz} is null.
+ * @return The {@link Object} of given type after deserializing the bytes.
+ */
+ public T toObject(Class clazz) {
+ Objects.requireNonNull(clazz, "'clazz' cannot be null.");
+
+ TypeReference ref = TypeReference.createInstance(clazz);
+ InputStream jsonStream = new ByteArrayInputStream(this.data);
+ return getDefaultSerializer().deserialize(jsonStream, ref);
+ }
+
+ /**
+ * Return a {@link Mono} by deserializing the bytes into the {@link Object} of given type after applying the Json
+ * serializer found on classpath.
+ *
+ *
Gets the specified object
+ * {@codesnippet com.azure.core.experimental.util.BinaryDocument.to#ObjectAsync}
+ *
+ * @param clazz representing the type of the Object.
+ * @param Generic type that the data is deserialized into.
+ * @throws NullPointerException If {@code clazz} is null.
+ * @return The {@link Object} of given type after deserializing the bytes.
+ */
+ public Mono toObjectAsync(Class clazz) {
+ if (Objects.isNull(clazz)) {
+ return monoError(LOGGER, new NullPointerException("'clazz' cannot be null."));
+ }
+ return Mono.fromCallable(() -> toObject(clazz));
+ }
+
+ /**
+ * Provides {@link InputStream} for the data represented by this {@link BinaryData} object.
+ *
+ *
Get InputStream from BinaryData
+ * {@codesnippet com.azure.core.experimental.util.BinaryDocument.to#Stream}
+ *
+ * @return {@link InputStream} representing the binary data.
+ */
+ public InputStream toStream() {
+ return new ByteArrayInputStream(this.data);
+ }
+
+ /* This will ensure lazy instantiation to avoid hard dependency on Json Serializer. */
+ private static JsonSerializer getDefaultSerializer() {
+ if (defaultJsonSerializer == null) {
+ synchronized (LOCK) {
+ if (defaultJsonSerializer == null) {
+ defaultJsonSerializer = JsonSerializerProviders.createInstance();
+ }
+ }
+ }
+ return defaultJsonSerializer;
+ }
}
diff --git a/sdk/core/azure-core-experimental/src/samples/java/com/azure/core/experimental/util/BinaryDateJavaDocCodeSnippet.java b/sdk/core/azure-core-experimental/src/samples/java/com/azure/core/experimental/util/BinaryDateJavaDocCodeSnippet.java
index d4999b654cf2..a7211d27ca89 100644
--- a/sdk/core/azure-core-experimental/src/samples/java/com/azure/core/experimental/util/BinaryDateJavaDocCodeSnippet.java
+++ b/sdk/core/azure-core-experimental/src/samples/java/com/azure/core/experimental/util/BinaryDateJavaDocCodeSnippet.java
@@ -58,8 +58,8 @@ public void createFromString() {
*/
public void createFromStream() {
// BEGIN: com.azure.core.experimental.util.BinaryDocument.from#Stream
- final byte[] data = "Some Data".getBytes(StandardCharsets.UTF_8);
- BinaryData binaryData = BinaryData.fromStream(new ByteArrayInputStream(data));
+ final ByteArrayInputStream inputStream = new ByteArrayInputStream("Some Data".getBytes(StandardCharsets.UTF_8));
+ BinaryData binaryData = BinaryData.fromStream(inputStream);
System.out.println(binaryData.toString());
// END: com.azure.core.experimental.util.BinaryDocument.from#Stream
}
@@ -88,6 +88,40 @@ public void createFromFlux() throws InterruptedException {
// END: com.azure.core.experimental.util.BinaryDocument.from#Flux
}
+ /**
+ * Codesnippets for {@link BinaryData#fromObject(Object, ObjectSerializer)}.
+ */
+ public void createFromObject() {
+ // BEGIN: com.azure.core.experimental.util.BinaryDocument.from#Object
+ // Lets say we have Person object which could be serialized into json.
+ class Person {
+ @JsonProperty
+ private String name;
+
+ @JsonSetter
+ public Person setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @JsonGetter
+ public String getName() {
+ return name;
+ }
+ }
+ final Person data = new Person().setName("John");
+
+ // Provide your custom serializer or use Azure provided serializers.
+ // https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-jackson or
+ // https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-gson
+
+ final ObjectSerializer serializer =
+ new MyJsonSerializer(); // Replace this with your Serializer or from above libraries.
+ BinaryData binaryData = BinaryData.fromObject(data, serializer);
+ System.out.println(binaryData.toString());
+ // END: com.azure.core.experimental.util.BinaryDocument.from#Object
+ }
+
/**
* Codesnippets for {@link BinaryData#toStream()}.
*/
@@ -124,8 +158,7 @@ public String getName() {
}
final Person data = new Person().setName("John");
- // Ensure your classpath have the Serializer to use to serialize object. For example you can use one of
- // following library.
+ // Provide your custom serializer or use Azure provided serializers.
// https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-jackson or
// https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-gson
@@ -133,7 +166,6 @@ public String getName() {
new MyJsonSerializer(); // Replace this with your Serializer
BinaryData binaryData = BinaryData.fromObject(data, serializer);
- // Lets print the value of BinaryData
Disposable subscriber = binaryData
.toObjectAsync(Person.class, serializer)
.map(person -> {
@@ -148,6 +180,78 @@ public String getName() {
// END: com.azure.core.experimental.util.BinaryDocument.to#ObjectAsync
}
+ /**
+ * Codesnippets for {@link BinaryData#toObject(Class, ObjectSerializer)}.
+ */
+ public void createToObject() {
+ // BEGIN: com.azure.core.experimental.util.BinaryDocument.to#Object
+ // Lets say we have Person object which could be serialized into json.
+ class Person {
+ @JsonProperty
+ private String name;
+
+ @JsonSetter
+ public Person setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @JsonGetter
+ public String getName() {
+ return name;
+ }
+ }
+ final Person data = new Person().setName("John");
+
+ // Provide your custom serializer or use Azure provided serializers.
+ // https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-jackson or
+ // https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-gson
+
+ final ObjectSerializer serializer =
+ new MyJsonSerializer(); // Replace this with your Serializer
+ BinaryData binaryData = BinaryData.fromObject(data, serializer);
+
+ Person person = binaryData.toObject(Person.class, serializer);
+ // Lets print the name
+ System.out.println("Name : " + person.getName());
+
+ // END: com.azure.core.experimental.util.BinaryDocument.to#Object
+ }
+
+ /**
+ * Codesnippets for {@link BinaryData#fromObject(Object)}.
+ */
+ public void createFromObjectDefaultSerializer() {
+ // BEGIN: com.azure.core.experimental.util.BinaryDocument.from.default.serializer#Object
+ // Lets say we have Person object which could be serialized into json.
+ class Person {
+ @JsonProperty
+ private String name;
+
+ @JsonSetter
+ public Person setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ @JsonGetter
+ public String getName() {
+ return name;
+ }
+ }
+ final Person data = new Person().setName("John");
+
+ // Ensure your classpath have the Serializer to serialize the object which implement implement
+ // com.azure.core.util.serializer.JsonSerializer interface.
+ // Or use Azure provided libraries for this.
+ // https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-jackson or
+ // https://mvnrepository.com/artifact/com.azure/azure-core-serializer-json-gson
+
+ BinaryData binaryData = BinaryData.fromObject(data);
+ System.out.println(binaryData.toString());
+ // END: com.azure.core.experimental.util.BinaryDocument.from.default.serializer#Object
+ }
+
public static class MyJsonSerializer implements JsonSerializer {
private final ClientLogger logger = new ClientLogger(BinaryDataTest.MyJsonSerializer.class);
private final ObjectMapper mapper;
@@ -192,4 +296,3 @@ public Mono serializeAsync(OutputStream stream, Object value) {
}
}
}
-
diff --git a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/util/BinaryDataTest.java b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/util/BinaryDataTest.java
index e0afe19e16d3..157b7d8ea094 100644
--- a/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/util/BinaryDataTest.java
+++ b/sdk/core/azure-core-experimental/src/test/java/com/azure/core/experimental/util/BinaryDataTest.java
@@ -85,34 +85,75 @@ public void createFromString() {
}
@Test
- public void createFromStringCharSet() {
+ public void createFromByteArray() {
// Arrange
- final String expected = "Doe";
+ final byte[] expected = "Doe".getBytes(StandardCharsets.UTF_8);
// Act
- final BinaryData data = BinaryData.fromString(expected, StandardCharsets.UTF_8);
+ final BinaryData data = new BinaryData(expected);
// Assert
- assertArrayEquals(expected.getBytes(), data.toBytes());
- assertEquals(expected, data.toString(StandardCharsets.UTF_8));
+ assertArrayEquals(expected, data.toBytes());
}
@Test
- public void createFromByteArray() {
+ public void createFromNullStream() throws IOException {
// Arrange
- final byte[] expected = "Doe".getBytes(StandardCharsets.UTF_8);
+ final byte[] expected = new byte[0];
// Act
- final BinaryData data = new BinaryData(expected);
+ BinaryData data = BinaryData.fromStream(null);
+ final byte[] actual = new byte[0];
+ (data.toStream()).read(actual, 0, expected.length);
// Assert
assertArrayEquals(expected, data.toBytes());
+ assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void createFromNullByteArray() {
+ // Arrange
+ final byte[] expected = new byte[0];
+
+ // Act
+ BinaryData actual = BinaryData.fromBytes(null);
+
+ // Assert
+ assertArrayEquals(expected, actual.toBytes());
+ }
+
+ @Test
+ public void createFromNullObject() {
+ // Arrange
+ final byte[] expected = new byte[0];
+
+ // Act
+ BinaryData actual = BinaryData.fromObject(null);
+
+ // Assert
+ assertArrayEquals(expected, actual.toBytes());
}
@Test
public void createFromStream() throws IOException {
// Arrange
final byte[] expected = "Doe".getBytes(StandardCharsets.UTF_8);
+
+ // Act
+ BinaryData data = BinaryData.fromStream(new ByteArrayInputStream(expected));
+ final byte[] actual = new byte[expected.length];
+ (data.toStream()).read(actual, 0, expected.length);
+
+ // Assert
+ assertArrayEquals(expected, data.toBytes());
+ assertArrayEquals(expected, actual);
+ }
+
+ @Test
+ public void createFromEmptyStream() throws IOException {
+ // Arrange
+ final byte[] expected = "".getBytes();
final byte[] actual = new byte[expected.length];
// Act
@@ -140,7 +181,7 @@ public void createFromFlux() {
}
@Test
- public void createFromStreamAsync() throws IOException {
+ public void createFromStreamAsync() {
// Arrange
final byte[] expected = "Doe".getBytes(StandardCharsets.UTF_8);
@@ -152,27 +193,6 @@ public void createFromStreamAsync() throws IOException {
.verifyComplete();
}
- @Test
- public void createToStreamAsync() {
- // Arrange
- final byte[] expected = "Doe".getBytes(StandardCharsets.UTF_8);
- final BinaryData actual = BinaryData.fromStreamAsync(new ByteArrayInputStream(expected)).block();
- // Act & Assert
- StepVerifier.create(actual.toStreamAsync())
- .assertNext(inutStream -> {
- byte[] actualBytes = new byte[expected.length];
-
- // Act
- try {
- inutStream.read(actualBytes, 0, expected.length);
- } catch (IOException e) {
- e.printStackTrace();
- }
- Assertions.assertArrayEquals(expected, actualBytes);
- })
- .verifyComplete();
- }
-
@Test
public void createFromObjectAsync() {
// Arrange
@@ -189,6 +209,58 @@ public void createFromObjectAsync() {
.verifyComplete();
}
+
+ @Test
+ public void createFromEmptyString() {
+ // Arrange
+ final String expected = "";
+
+ // Act
+ final BinaryData data = BinaryData.fromString(expected);
+
+ // Assert
+ assertArrayEquals(expected.getBytes(), data.toBytes());
+ assertEquals(expected, data.toString());
+ }
+
+ @Test
+ public void createFromEmptyByteArray() {
+ // Arrange
+ final byte[] expected = new byte[0];
+
+ // Act
+ final BinaryData data = BinaryData.fromBytes(expected);
+
+ // Assert
+ assertArrayEquals(expected, data.toBytes());
+ }
+
+ @Test
+ public void createFromNullString() {
+ // Arrange
+ final String expected = null;
+
+ // Arrange & Act
+ final BinaryData data = BinaryData.fromString(expected);
+
+ // Assert
+ assertArrayEquals(new byte[0], data.toBytes());
+ assertEquals("", data.toString());
+ }
+
+ @Test
+ public void createFromNullByte() {
+ // Arrange
+ final byte[] expected = null;
+
+ // Arrange & Act
+ final BinaryData data = BinaryData.fromBytes(expected);
+
+ // Assert
+ assertArrayEquals(new byte[0], data.toBytes());
+ assertEquals("", data.toString());
+ }
+
public static class MyJsonSerializer implements JsonSerializer {
private final ClientLogger logger = new ClientLogger(MyJsonSerializer.class);
private final ObjectMapper mapper;
diff --git a/sdk/core/azure-core/pom.xml b/sdk/core/azure-core/pom.xml
index 62533be9e2e8..82714f23f444 100644
--- a/sdk/core/azure-core/pom.xml
+++ b/sdk/core/azure-core/pom.xml
@@ -183,6 +183,23 @@
+
+
+
+ com.github.spotbugs
+ spotbugs-maven-plugin
+ 3.1.12.2
+
+
+
+ com.h3xstream.findsecbugs
+ findsecbugs-plugin
+ 1.9.0
+
+
+
+
+
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/HttpClientProviders.java b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/HttpClientProviders.java
index 96b3d24120c8..fe826da4c305 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/HttpClientProviders.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/implementation/http/HttpClientProviders.java
@@ -13,8 +13,11 @@
*/
public final class HttpClientProviders {
private static HttpClientProvider defaultProvider;
- private static final String CANNOT_FIND_HTTP_CLIENT =
- "Cannot find any HttpClient provider on the classpath - unable to create a default HttpClient instance";
+ private static final String CANNOT_FIND_HTTP_CLIENT = "A request was made to load the default HttpClient provider "
+ + "but one could not be found on the classpath. If you are using a dependency manager, consider including a "
+ + "dependency on azure-core-http-netty or azure-core-http-okhttp. Depending on your existing dependencies, you "
+ + "have the choice of Netty or OkHttp implementations. Additionally, refer to "
+ + "https://aka.ms/azsdk/java/docs/custom-httpclient to learn about writing your own implementation.";
static {
ServiceLoader serviceLoader = ServiceLoader.load(HttpClientProvider.class);
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocument.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocument.java
index 2fd4f3d7a7f9..7cdb9feff4f1 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocument.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocument.java
@@ -7,8 +7,7 @@
import com.azure.core.util.serializer.JacksonAdapter;
import com.azure.core.util.serializer.JsonSerializer;
import com.azure.core.util.serializer.JsonSerializerProviders;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonValue;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -20,19 +19,15 @@
/**
* Represents a JSON Patch document.
*/
-//@JsonSerialize(using = JsonPatchDocumentSerializer.class)
-public class JsonPatchDocument {
+@JsonSerialize(using = JsonPatchDocumentSerializer.class)
+public final class JsonPatchDocument {
private static final Object SERIALIZER_INSTANTIATION_SYNCHRONIZER = new Object();
private static volatile JsonSerializer defaultSerializer;
- @JsonIgnore
private final ClientLogger logger = new ClientLogger(JsonPatchDocument.class);
- @JsonValue
- private final List operations;
-
- @JsonIgnore
private final JsonSerializer serializer;
+ private final List operations;
/**
* Creates a new JSON Patch document.
@@ -53,7 +48,14 @@ public JsonPatchDocument(JsonSerializer serializer) {
this.serializer = serializer;
}
- List getOperations() {
+ /**
+ * Gets a representation of the {@link JsonPatchOperation JSON patch operations} in this JSON patch document.
+ *
+ * Modifications to the returned list won't mutate the operations in the document.
+ *
+ * @return The JSON patch operations in this JSON patch document.
+ */
+ public List getOperations() {
return new ArrayList<>(operations);
}
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocumentSerializer.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocumentSerializer.java
index 31eba6abd7d2..08e0ff8b4a92 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocumentSerializer.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchDocumentSerializer.java
@@ -13,7 +13,7 @@
/**
* Handles serialization of a {@link JsonPatchDocument}.
*/
-class JsonPatchDocumentSerializer extends JsonSerializer {
+final class JsonPatchDocumentSerializer extends JsonSerializer {
@Override
public void serialize(JsonPatchDocument value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperation.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperation.java
index cab3bd1528db..f9c6d9d18cf4 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperation.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperation.java
@@ -3,6 +3,7 @@
package com.azure.core.util;
+import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.Objects;
@@ -11,8 +12,9 @@
/**
* Represents a JSON Patch operation.
*/
+@Immutable
@JsonSerialize(using = JsonPatchOperationSerializer.class)
-final class JsonPatchOperation {
+public final class JsonPatchOperation {
private final JsonPatchOperationKind op;
private final String from;
private final String path;
@@ -41,7 +43,7 @@ final class JsonPatchOperation {
*
* @return The kind of operation.
*/
- JsonPatchOperationKind getOp() {
+ public JsonPatchOperationKind getOp() {
return op;
}
@@ -50,7 +52,7 @@ JsonPatchOperationKind getOp() {
*
* @return The operation from target path.
*/
- String getFrom() {
+ public String getFrom() {
return from;
}
@@ -59,16 +61,18 @@ String getFrom() {
*
* @return The operation target path.
*/
- String getPath() {
+ public String getPath() {
return path;
}
/**
* Gets the operation value.
+ *
+ * If the operation doesn't take a value {@link Option#uninitialized()} will be returned.
*
* @return The operation value.
*/
- Option getValue() {
+ public Option getValue() {
return value;
}
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationKind.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationKind.java
index 57fe594f7bc5..2520e1f15572 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationKind.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationKind.java
@@ -8,7 +8,7 @@
/**
* Represents the JSON Patch operation kind.
*/
-enum JsonPatchOperationKind {
+public enum JsonPatchOperationKind {
/**
* Add operation.
*/
@@ -45,6 +45,11 @@ enum JsonPatchOperationKind {
this.op = op;
}
+ /**
+ * Gets the string representation of the JSON patch operation kind.
+ *
+ * @return The string representation of the JSON patch operation kind.
+ */
@JsonValue
public String toString() {
return op;
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationSerializer.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationSerializer.java
index acc60d4dee84..38ae5b5439a4 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationSerializer.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/JsonPatchOperationSerializer.java
@@ -12,7 +12,7 @@
/**
* Handles serialization of a {@link JsonPatchOperation}.
*/
-class JsonPatchOperationSerializer extends JsonSerializer {
+final class JsonPatchOperationSerializer extends JsonSerializer {
@Override
public void serialize(JsonPatchOperation value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
index 090072a409e1..eb390c706729 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java
@@ -12,6 +12,7 @@
import java.util.Arrays;
import java.util.Objects;
+import java.util.regex.Pattern;
/**
* This is a fluent logger helper class that wraps a pluggable {@link Logger}.
@@ -35,6 +36,7 @@
* @see Configuration
*/
public class ClientLogger {
+ private static final Pattern CRLF_PATTERN = Pattern.compile("[\r\n]");
private final Logger logger;
/**
@@ -70,7 +72,7 @@ public ClientLogger(String className) {
*/
public void verbose(String message) {
if (logger.isDebugEnabled()) {
- logger.debug(message);
+ logger.debug(sanitizeLogMessageInput(message));
}
}
@@ -106,7 +108,7 @@ public void verbose(String format, Object... args) {
*/
public void info(String message) {
if (logger.isInfoEnabled()) {
- logger.info(message);
+ logger.info(sanitizeLogMessageInput(message));
}
}
@@ -142,7 +144,7 @@ public void info(String format, Object... args) {
*/
public void warning(String message) {
if (logger.isWarnEnabled()) {
- logger.warn(message);
+ logger.warn(sanitizeLogMessageInput(message));
}
}
@@ -178,7 +180,7 @@ public void warning(String format, Object... args) {
*/
public void error(String message) {
if (logger.isErrorEnabled()) {
- logger.error(message);
+ logger.error(sanitizeLogMessageInput(message));
}
}
@@ -327,6 +329,7 @@ private void performLogging(LogLevel logLevel, boolean isExceptionLogging, Strin
}
}
+ sanitizeLogMessageInput(format);
switch (logLevel) {
case VERBOSE:
logger.debug(format, args);
@@ -401,4 +404,14 @@ private boolean doesArgsHaveThrowable(Object... args) {
private Object[] removeThrowable(Object... args) {
return Arrays.copyOf(args, args.length - 1);
}
+
+ /**
+ * Removes CRLF pattern in the {@code logMessage}.
+ *
+ * @param logMessage The log message to sanitize.
+ * @return The updated logMessage.
+ */
+ private static String sanitizeLogMessageInput(String logMessage) {
+ return CRLF_PATTERN.matcher(logMessage).replaceAll("");
+ }
}
diff --git a/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JsonSerializerProviders.java b/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JsonSerializerProviders.java
index f080043d7799..82131dd5b04a 100644
--- a/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JsonSerializerProviders.java
+++ b/sdk/core/azure-core/src/main/java/com/azure/core/util/serializer/JsonSerializerProviders.java
@@ -10,8 +10,12 @@
* This class is a proxy for using a {@link JsonSerializerProvider} loaded from the classpath.
*/
public final class JsonSerializerProviders {
- private static final String CANNOT_FIND_JSON_SERIALIZER_PROVIDER =
- "Cannot find any JSON serializer provider on the classpath.";
+ private static final String CANNOT_FIND_JSON_SERIALIZER_PROVIDER = "A request was made to load the default JSON "
+ + "serializer provider but one could not be found on the classpath. If you are using a dependency manager, "
+ + "consider including a dependency on azure-core-serializer-json-jackson or azure-core-serializer-json-gson. "
+ + "Depending on your existing dependencies, you have the choice of Jackson or GSON implementations. "
+ + "Additionally, refer to https://aka.ms/azsdk/java/docs/custom-jsonserializer to learn about writing your own "
+ + "implementation.";
private static JsonSerializerProvider defaultProvider;
private static boolean attemptedLoad;
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/JsonPatchDocumentTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/JsonPatchDocumentTests.java
index 96e31e26bb4c..e530bd35731e 100644
--- a/sdk/core/azure-core/src/test/java/com/azure/core/util/JsonPatchDocumentTests.java
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/JsonPatchDocumentTests.java
@@ -42,6 +42,13 @@ public void jsonifyDocument(JsonPatchDocument document, String expected) throws
assertEquals(expected, SERIALIZER.serialize(document, SerializerEncoding.JSON).replace(" ", ""));
}
+ @ParameterizedTest
+ @MethodSource("formattingSupplier")
+ public void jsonifyOperations(JsonPatchDocument document, String expected) throws IOException {
+ assertEquals(expected, SERIALIZER.serialize(document.getOperations(), SerializerEncoding.JSON)
+ .replace(" ", ""));
+ }
+
private static Stream formattingSupplier() {
JsonPatchDocument complexDocument = newDocument()
.appendTest("/a/b/c", "foo")
diff --git a/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java b/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java
index 91b4c78d6845..11d6a8a804da 100644
--- a/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java
+++ b/sdk/core/azure-core/src/test/java/com/azure/core/util/logging/ClientLoggerTests.java
@@ -80,6 +80,30 @@ public void logSimpleMessage(LogLevel logLevelToConfigure, LogLevel logLevelToUs
assertEquals(logContainsMessage, logValues.contains(logMessage));
}
+ /**
+ * Test whether a log will be captured when the ClientLogger and message are configured to the passed log levels.
+ */
+ @ParameterizedTest
+ @MethodSource("logMaliciousErrorSupplier")
+ @ResourceLock("SYSTEM_OUT")
+ public void logMaliciousMessage(LogLevel logLevelToConfigure, LogLevel logLevelToUse)
+ throws UnsupportedEncodingException {
+ String logMessage = "You have successfully authenticated, \r\n[INFO] User dummy was not"
+ + " successfully authenticated.";
+
+ String expectedMessage = "You have successfully authenticated, [INFO] User dummy was not"
+ + " successfully authenticated.";
+
+ String originalLogLevel = setupLogLevel(logLevelToConfigure.getLogLevel());
+ logMessage(new ClientLogger(ClientLoggerTests.class), logLevelToUse, logMessage);
+
+ setPropertyToOriginalOrClear(originalLogLevel);
+
+ String logValues = logCaptureStream.toString("UTF-8");
+ System.out.println(logValues);
+ assertEquals(true, logValues.contains(expectedMessage));
+ }
+
@ParameterizedTest
@MethodSource("singleLevelCheckSupplier")
@ResourceLock("SYSTEM_OUT")
@@ -461,6 +485,41 @@ private static Stream multiLevelCheckSupplier() {
);
}
+ private static Stream logMaliciousErrorSupplier() {
+ return Stream.of(
+ // Supported logging level set to VERBOSE.
+ // Checking VERBOSE.
+ Arguments.of(LogLevel.VERBOSE, LogLevel.VERBOSE, true),
+
+ // Checking INFORMATIONAL.
+ Arguments.of(LogLevel.VERBOSE, LogLevel.INFORMATIONAL, true),
+
+ // Checking WARNING.
+ Arguments.of(LogLevel.VERBOSE, LogLevel.WARNING, true),
+
+ // Checking ERROR.
+ Arguments.of(LogLevel.VERBOSE, LogLevel.ERROR, true),
+
+ // Checking INFORMATIONAL.
+ Arguments.of(LogLevel.INFORMATIONAL, LogLevel.INFORMATIONAL, true),
+
+ // Checking WARNING.
+ Arguments.of(LogLevel.INFORMATIONAL, LogLevel.WARNING, true),
+
+ // Checking ERROR.
+ Arguments.of(LogLevel.INFORMATIONAL, LogLevel.ERROR, true),
+
+ // Checking WARNING.
+ Arguments.of(LogLevel.WARNING, LogLevel.WARNING, true),
+
+ // Checking ERROR.
+ Arguments.of(LogLevel.WARNING, LogLevel.ERROR, true),
+
+ // Checking ERROR.
+ Arguments.of(LogLevel.ERROR, LogLevel.ERROR, true)
+ );
+ }
+
private static Stream logExceptionAsWarningSupplier() {
return Stream.of(
Arguments.of(LogLevel.VERBOSE, true, true),
diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentProducer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentProducer.java
index d7bd9a56153b..7f3622d00374 100644
--- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentProducer.java
+++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/query/DocumentProducer.java
@@ -147,7 +147,9 @@ public DocumentProducer(
this.correlatedActivityId = correlatedActivityId;
- this.cosmosQueryRequestOptions = cosmosQueryRequestOptions != null ? cosmosQueryRequestOptions : new CosmosQueryRequestOptions();
+ this.cosmosQueryRequestOptions = cosmosQueryRequestOptions != null ?
+ ModelBridgeInternal.createQueryRequestOptions(cosmosQueryRequestOptions)
+ : new CosmosQueryRequestOptions();
ModelBridgeInternal.setQueryRequestOptionsContinuationToken(this.cosmosQueryRequestOptions, initialContinuationToken);
this.lastResponseContinuationToken = initialContinuationToken;
this.resourceType = resourceType;
diff --git a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java
index 1f7374d2502d..84949cab3a39 100644
--- a/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java
+++ b/sdk/digitaltwins/azure-digitaltwins-core/src/main/java/com/azure/digitaltwins/core/DigitalTwinsAsyncClient.java
@@ -741,13 +741,13 @@ Mono> listIncomingRelationshipsNextSinglePag
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createModels#Iterable}
*
- * @param models The list of models to create. Each string corresponds to exactly one model.
+ * @param dtdlModels The list of models to create. Each string corresponds to exactly one model.
* @return A List of created models. Each {@link DigitalTwinsModelData} instance in this list
* will contain metadata about the created model, but will not contain the model itself.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
- public Mono> createModels(Iterable models) {
- return createModelsWithResponse(models, null)
+ public Mono> createModels(Iterable dtdlModels) {
+ return createModelsWithResponse(dtdlModels, null)
.map(Response::getValue);
}
@@ -758,19 +758,19 @@ public Mono> createModels(Iterable model
*
* {@codesnippet com.azure.digitaltwins.core.asyncClient.createModelsWithResponse#Iterable-Options}
*
- * @param models The list of models to create. Each string corresponds to exactly one model.
+ * @param dtdlModels The list of models to create. Each string corresponds to exactly one model.
* @param options The optional parameters for this request. If null, the default option values will be used.
* @return A {@link Response} containing the list of created models. Each {@link DigitalTwinsModelData} instance in this list
* will contain metadata about the created model, but will not contain the model itself.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
- public Mono>> createModelsWithResponse(Iterable models, CreateModelsOptions options) {
- return withContext(context -> createModelsWithResponse(models, options, context));
+ public Mono>> createModelsWithResponse(Iterable dtdlModels, CreateModelsOptions options) {
+ return withContext(context -> createModelsWithResponse(dtdlModels, options, context));
}
- Mono>> createModelsWithResponse(Iterable models, CreateModelsOptions options, Context context) {
+ Mono>> createModelsWithResponse(Iterable dtdlModels, CreateModelsOptions options, Context context) {
List