[^0-9][^\s]+))?" $SDIST_PACKAGE_REGEX = "^(?.*)\-(? $VERSION_REGEX$)" diff --git a/eng/common/scripts/git-branch-push.ps1 b/eng/common/scripts/git-branch-push.ps1 index 8be1cd1f30b2..4f2b5d771373 100644 --- a/eng/common/scripts/git-branch-push.ps1 +++ b/eng/common/scripts/git-branch-push.ps1 @@ -28,7 +28,7 @@ param( [string] $PushArgs = "" ) -Write-Host $MyInvocation.Line +Write-Host "> $PSCommandPath $args" # This is necessay because of the janky git command output writing to stderr. # Without explicitly setting the ErrorActionPreference to continue the script diff --git a/eng/jacoco-test-coverage/pom.xml b/eng/jacoco-test-coverage/pom.xml index 352563cddc96..97c09f1e53ef 100644 --- a/eng/jacoco-test-coverage/pom.xml +++ b/eng/jacoco-test-coverage/pom.xml @@ -39,7 +39,7 @@ com.azure azure-ai-formrecognizer -1.0.0-beta.2 +1.0.0-beta.3 com.azure @@ -99,7 +99,7 @@com.azure azure-identity -1.1.0-beta.4 +1.1.0-beta.5 com.azure @@ -119,12 +119,12 @@com.azure azure-messaging-eventhubs -5.1.0-beta.1 +5.2.0-beta.1 com.azure azure-messaging-eventhubs-checkpointstore-blob -1.1.0-beta.1 +1.2.0-beta.1 com.azure @@ -175,7 +175,7 @@com.azure azure-search-documents -1.0.0-beta.3 +1.0.0-beta.4 com.azure diff --git a/eng/mgmt/api-specs.json b/eng/mgmt/api-specs.json index 171cf72329f2..e75afdddce60 100644 --- a/eng/mgmt/api-specs.json +++ b/eng/mgmt/api-specs.json @@ -102,6 +102,10 @@ "source": "specification/datamigration/resource-manager/readme.md", "args": "--multiapi --fluent" }, + "datashare/resource-manager": { + "source": "specification/datashare/resource-manager/readme.md", + "args": "--multiapi --fluent" + }, "devtestlabs/resource-manager" : { "source": "specification/devtestlabs/resource-manager/readme.md", "args": "--multiapi --fluent" @@ -323,6 +327,10 @@ "\"moduleName\"": "\"StreamAnalytics\"" } }, + "subscription/resource-manager": { + "source": "specification/subscription/resource-manager/readme.md", + "args": "--multiapi --fluent" + }, "support/resource-manager": { "source": "specification/support/resource-manager/readme.md", "args": "--multiapi --fluent" diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt index cb9b5c4e0298..8881dde9edfd 100644 --- a/eng/versioning/external_dependencies.txt +++ b/eng/versioning/external_dependencies.txt @@ -69,7 +69,7 @@ org.springframework.security:spring-security-web;5.2.0.RELEASE org.springframework.security:spring-security-oauth2-client;5.2.0.RELEASE org.springframework.security:spring-security-oauth2-core;5.2.0.RELEASE org.springframework.security:spring-security-oauth2-jose;5.2.0.RELEASE -org.springframework:spring-web;5.2.0.RELEASE +org.springframework:spring-web;5.2.5.RELEASE pl.pragmatists:JUnitParams;1.1.1 ## Test dependency versions diff --git a/eng/versioning/pom_file_version_scanner.ps1 b/eng/versioning/pom_file_version_scanner.ps1 index 08b91364e6a4..48f925433eed 100644 --- a/eng/versioning/pom_file_version_scanner.ps1 +++ b/eng/versioning/pom_file_version_scanner.ps1 @@ -293,14 +293,13 @@ Get-ChildItem -Path $Path -Filter pom*.xml -Recurse -File | ForEach-Object { Write-Error-With-Color "Error:is not allowed. Every dependency must have its own version and version update tag" } + $xmlNsManager = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $xmlPomFile.NameTable + $xmlNsManager.AddNamespace("ns", $xmlPomFile.DocumentElement.NamespaceURI) + # Ensure that the project has a version tag with the exception of projects under the eng directory which # aren't releasing libraries but still need to have their dependencies checked if ($pomFile.Split([IO.Path]::DirectorySeparatorChar) -notcontains "eng") { - - $xmlNsManager = New-Object -TypeName "Xml.XmlNamespaceManager" -ArgumentList $xmlPomFile.NameTable - $xmlNsManager.AddNamespace("ns", $xmlPomFile.DocumentElement.NamespaceURI) - $versionNode = $xmlPomFile.SelectSingleNode("/ns:project/ns:version", $xmlNsManager) if ($xmlPomFile.project.version -and $versionNode) { diff --git a/eng/versioning/scan_for_unreleased_dependencies.ps1 b/eng/versioning/scan_for_unreleased_dependencies.ps1 index 4727f0d4f182..b890bd913cc4 100644 --- a/eng/versioning/scan_for_unreleased_dependencies.ps1 +++ b/eng/versioning/scan_for_unreleased_dependencies.ps1 @@ -87,6 +87,21 @@ Get-ChildItem -Path $serviceDirectory -Filter pom*.xml -Recurse -File | ForEach- Write-Error-With-Color "Error: Cannot release non-beta libraries with beta_ dependencies. dependency=$($versionUpdateTag)" } continue + } else { + # If this is an external dependency then continue + if ($versionUpdateTag -match "external_dependency}") { + continue + } + # If this isn't an external dependency then ensure that if the dependency + # version is beta, that we're releasing a beta, otherwise fail + if ($versionNode.InnerText -like '*-beta.*') + { + if (!$libraryIsBeta) + { + $script:FoundError = $true + Write-Error-With-Color "Error: Cannot release non-beta libraries with beta dependencies. dependency=$($versionUpdateTag), version=$($versionNode.InnerText.Trim())" + } + } } } else @@ -106,8 +121,7 @@ if (-Not $script:FoundPomFile) { exit(1) } if ($script:FoundError) { - Write-Error-With-Color "Libaries with unreleased dependencies cannot be released." exit(1) } -Write-Host "$($inputGroupId):$($inputArtifactId) looks goood to release" -ForegroundColor Green \ No newline at end of file +Write-Host "$($inputGroupId):$($inputArtifactId) looks good to release" -ForegroundColor Green \ No newline at end of file diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 15fbf70c17bb..f5f67245c982 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -4,10 +4,10 @@ com.azure:azure-sdk-all;1.0.0;1.0.0 com.azure:azure-sdk-parent;1.6.0;1.6.0 com.azure:azure-client-sdk-parent;1.7.0;1.7.0 -com.azure:azure-ai-formrecognizer;1.0.0-beta.1;1.0.0-beta.2 +com.azure:azure-ai-formrecognizer;1.0.0-beta.2;1.0.0-beta.3 com.azure:azure-ai-textanalytics;1.0.0-beta.4;1.0.0-beta.5 com.azure:azure-core;1.5.0;1.6.0-beta.1 -com.azure:azure-core-amqp;1.1.0;1.2.0-beta.1 +com.azure:azure-core-amqp;1.1.2;1.2.0-beta.1 com.azure:azure-core-http-jdk-httpclient;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-core-http-netty;1.5.1;1.6.0-beta.1 com.azure:azure-core-http-okhttp;1.2.2;1.3.0-beta.1 @@ -21,25 +21,25 @@ com.azure:azure-cosmos-examples;4.0.1-beta.1;4.0.1-beta.1 com.azure:azure-cosmos-benchmark;4.0.1-beta.1;4.0.1-beta.1 com.azure:azure-data-appconfiguration;1.1.1;1.2.0-beta.1 com.azure:azure-e2e;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-identity;1.0.5;1.1.0-beta.4 +com.azure:azure-identity;1.0.6;1.1.0-beta.5 com.azure:azure-identity-perf;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-messaging-eventhubs;5.0.3;5.1.0-beta.1 -com.azure:azure-messaging-eventhubs-checkpointstore-blob;1.0.3;1.1.0-beta.1 +com.azure:azure-messaging-eventhubs;5.1.0;5.2.0-beta.1 +com.azure:azure-messaging-eventhubs-checkpointstore-blob;1.1.0;1.2.0-beta.1 com.azure:azure-messaging-servicebus;7.0.0-beta.1;7.0.0-beta.2 -com.azure:azure-search-documents;1.0.0-beta.2;1.0.0-beta.3 +com.azure:azure-search-documents;1.0.0-beta.3;1.0.0-beta.4 com.azure:azure-security-keyvault-certificates;4.1.0-beta.2;4.1.0-beta.3 com.azure:azure-security-keyvault-keys;4.2.0-beta.3;4.2.0-beta.4 com.azure:azure-security-keyvault-secrets;4.2.0-beta.2;4.2.0-beta.3 com.azure:azure-sdk-template;1.0.4-beta.12;1.0.4-beta.13 -com.azure:azure-storage-blob;12.6.0;12.7.0-beta.1 -com.azure:azure-storage-blob-batch;12.5.0;12.6.0-beta.1 -com.azure:azure-storage-blob-cryptography;12.6.0;12.7.0-beta.1 +com.azure:azure-storage-blob;12.6.1;12.7.0-beta.1 +com.azure:azure-storage-blob-batch;12.5.1;12.6.0-beta.1 +com.azure:azure-storage-blob-cryptography;12.6.1;12.7.0-beta.1 com.azure:azure-storage-blob-nio;12.0.0-beta.1;12.0.0-beta.1 -com.azure:azure-storage-common;12.6.0;12.7.0-beta.1 -com.azure:azure-storage-file-share;12.4.0;12.5.0-beta.1 -com.azure:azure-storage-file-datalake;12.1.0;12.2.0-beta.1 +com.azure:azure-storage-common;12.6.1;12.7.0-beta.1 +com.azure:azure-storage-file-share;12.4.1;12.5.0-beta.1 +com.azure:azure-storage-file-datalake;12.1.1;12.2.0-beta.1 com.azure:azure-storage-perf;1.0.0-beta.1;1.0.0-beta.1 -com.azure:azure-storage-queue;12.5.0;12.6.0-beta.1 +com.azure:azure-storage-queue;12.5.1;12.6.0-beta.1 com.azure:perf-test-core;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-test-watcher;1.0.0-beta.1;1.0.0-beta.1 @@ -48,7 +48,6 @@ com.azure:azure-test-watcher;1.0.0-beta.1;1.0.0-beta.1 # Format; # unreleased_ : ;dependency-version # note: The unreleased dependencies will not be manipulated with the automatic PR creation code. -unreleased_com.azure:azure-core-amqp;1.1.0 # Released Beta dependencies: Copy the entry from above, prepend "beta_", remove the current # version and set the version to the released beta. Released beta dependencies are only valid diff --git a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml index bc2c323cb329..1deabb0ad5e0 100644 --- a/sdk/appconfiguration/azure-data-appconfiguration/pom.xml +++ b/sdk/appconfiguration/azure-data-appconfiguration/pom.xml @@ -90,7 +90,7 @@ com.azure azure-identity -1.0.5 +1.0.6 test diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ApiManagementConfig.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ApiManagementConfig.java index b90e5bc19a18..8a65c85c89e0 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ApiManagementConfig.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ApiManagementConfig.java @@ -21,7 +21,7 @@ public final class ApiManagementConfig { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ArmIdWrapper.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ArmIdWrapper.java index e93ba466aedc..65e9f1bd86bb 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ArmIdWrapper.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ArmIdWrapper.java @@ -21,7 +21,7 @@ public final class ArmIdWrapper { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ContainerInfo.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ContainerInfo.java index 3f098a4aeea1..1957e719e2f2 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ContainerInfo.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/ContainerInfo.java @@ -184,7 +184,7 @@ public ContainerInfo withName(String name) { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/HostingEnvironmentProfile.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/HostingEnvironmentProfile.java index c18bff1665ad..34dda75edc33 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/HostingEnvironmentProfile.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/HostingEnvironmentProfile.java @@ -33,7 +33,7 @@ public final class HostingEnvironmentProfile { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/PrivateLinkResource.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/PrivateLinkResource.java index c8367b8a0f50..c8b9aed395d0 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/PrivateLinkResource.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/PrivateLinkResource.java @@ -39,7 +39,7 @@ public final class PrivateLinkResource { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/SnapshotRecoverySource.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/SnapshotRecoverySource.java index 683278fd7f6b..219a4fd7f42c 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/SnapshotRecoverySource.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/SnapshotRecoverySource.java @@ -57,7 +57,7 @@ public SnapshotRecoverySource withLocation(String location) { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/Solution.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/Solution.java index baaa1c264d38..56047b8b4ea9 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/Solution.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/Solution.java @@ -58,7 +58,7 @@ public final class Solution { * * @return the id value. */ - public Double getId() { + public Double id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/VirtualNetworkProfile.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/VirtualNetworkProfile.java index 938763bc9d63..f47ab37cec29 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/VirtualNetworkProfile.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/VirtualNetworkProfile.java @@ -39,7 +39,7 @@ public final class VirtualNetworkProfile { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateKeyVaultBindingImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateKeyVaultBindingImpl.java index 879f67f2c2bb..24678dee88fd 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateKeyVaultBindingImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateKeyVaultBindingImpl.java @@ -25,13 +25,13 @@ class AppServiceCertificateKeyVaultBindingImpl AppServiceCertificateKeyVaultBindingImpl( AppServiceCertificateResourceInner innerObject, AppServiceCertificateOrderImpl parent) { - super(innerObject.getName(), innerObject, (parent != null) ? parent.manager() : null); + super(innerObject.name(), innerObject, (parent != null) ? parent.manager() : null); this.parent = parent; } @Override public String id() { - return inner().getId(); + return inner().id(); } @Override diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrderImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrderImpl.java index 82044d379f85..8c659fa58b55 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrderImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrderImpl.java @@ -152,7 +152,7 @@ public AppServiceCertificateKeyVaultBinding createKeyVaultBinding(String certifi @Override public Mono createKeyVaultBindingAsync(String certificateName, Vault vault) { AppServiceCertificateResourceInner certInner = new AppServiceCertificateResourceInner(); - certInner.setLocation(vault.regionName()); + certInner.withLocation(vault.regionName()); certInner.withKeyVaultId(vault.id()); certInner.withKeyVaultSecretName(certificateName); return this diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrdersImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrdersImpl.java index 4f5a870e86a9..c0d98486630a 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrdersImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificateOrdersImpl.java @@ -34,7 +34,7 @@ protected AppServiceCertificateOrderImpl wrapModel(AppServiceCertificateOrderInn if (inner == null) { return null; } - return new AppServiceCertificateOrderImpl(inner.getName(), inner, this.manager()); + return new AppServiceCertificateOrderImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificatesImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificatesImpl.java index 622e831941e5..e4b322d21ea5 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificatesImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceCertificatesImpl.java @@ -52,7 +52,7 @@ protected AppServiceCertificateImpl wrapModel(CertificateInner inner) { if (inner == null) { return null; } - return new AppServiceCertificateImpl(inner.getName(), inner, this.manager()); + return new AppServiceCertificateImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainImpl.java index 76797561a5ad..178ac1dfd671 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainImpl.java @@ -34,7 +34,7 @@ class AppServiceDomainImpl AppServiceDomainImpl(String name, DomainInner innerObject, AppServiceManager manager) { super(name, innerObject, manager); - inner().setLocation("global"); + inner().withLocation("global"); if (inner().managedHostNames() != null) { this.hostNameMap = inner().managedHostNames().stream().collect(Collectors.toMap(HostName::name, Function.identity())); diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainsImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainsImpl.java index 93005685a36e..4169bac6bb60 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainsImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServiceDomainsImpl.java @@ -32,7 +32,7 @@ protected AppServiceDomainImpl wrapModel(DomainInner inner) { if (inner == null) { return null; } - return new AppServiceDomainImpl(inner.getName(), inner, this.manager()); + return new AppServiceDomainImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServicePlansImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServicePlansImpl.java index 5089d2648b0f..727727ecbb2d 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServicePlansImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/AppServicePlansImpl.java @@ -29,7 +29,7 @@ protected AppServicePlanImpl wrapModel(AppServicePlanInner inner) { if (inner == null) { return null; } - return new AppServicePlanImpl(inner.getName(), inner, this.manager()); + return new AppServicePlanImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotBaseImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotBaseImpl.java index f3eff551370a..9f85665ea1f9 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotBaseImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotBaseImpl.java @@ -54,7 +54,7 @@ abstract class DeploymentSlotBaseImpl< this.name = name.replaceAll(".*/", ""); this.parent = parent; inner().withServerFarmId(parent.appServicePlanId()); - inner().setLocation(regionName()); + inner().withLocation(regionName()); } @Override diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotsImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotsImpl.java index 3624c2ac8062..204a1fd5bc32 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotsImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/DeploymentSlotsImpl.java @@ -53,11 +53,11 @@ protected PagedFlux wrapPageAsync(PagedFlux innerPage this .inner() .getConfigurationSlotAsync( - siteInner.resourceGroup(), parent.name(), siteInner.getName()), + siteInner.resourceGroup(), parent.name(), siteInner.name()), this .inner() .getDiagnosticLogsConfigurationSlotAsync( - siteInner.resourceGroup(), parent.name(), siteInner.getName()), + siteInner.resourceGroup(), parent.name(), siteInner.name()), (siteConfigResourceInner, logsConfigInner) -> this.wrapModel(siteInner, siteConfigResourceInner, logsConfigInner))); } @@ -132,6 +132,6 @@ private DeploymentSlotImpl wrapModel( if (inner == null) { return null; } - return new DeploymentSlotImpl(inner.getName(), inner, siteConfig, logConfig, parent); + return new DeploymentSlotImpl(inner.name(), inner, siteConfig, logConfig, parent); } } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionAppsImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionAppsImpl.java index c9424c46eb7c..698e2cf85559 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionAppsImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionAppsImpl.java @@ -87,7 +87,7 @@ private FunctionAppImpl wrapModel( if (inner == null) { return null; } - return new FunctionAppImpl(inner.getName(), inner, siteConfig, logConfig, this.manager()); + return new FunctionAppImpl(inner.name(), inner, siteConfig, logConfig, this.manager()); } @Override @@ -100,11 +100,11 @@ protected PagedFlux wrapPageAsync(PagedFlux innerPage) { && Arrays.asList(siteInner.kind().split(",")).contains("functionapp")) { return Mono .zip( - this.inner().getConfigurationAsync(siteInner.resourceGroup(), siteInner.getName()), + this.inner().getConfigurationAsync(siteInner.resourceGroup(), siteInner.name()), this .inner() .getDiagnosticLogsConfigurationAsync( - siteInner.resourceGroup(), siteInner.getName()), + siteInner.resourceGroup(), siteInner.name()), (siteConfigResourceInner, logsConfigInner) -> this.wrapModel(siteInner, siteConfigResourceInner, logsConfigInner)); } else { diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionDeploymentSlotsImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionDeploymentSlotsImpl.java index 78d7dcd0bf81..d7cc051a52df 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionDeploymentSlotsImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/FunctionDeploymentSlotsImpl.java @@ -56,11 +56,11 @@ protected PagedFlux wrapPageAsync(PagedFlux i this .inner() .getConfigurationSlotAsync( - siteInner.resourceGroup(), parent.name(), siteInner.getName()), + siteInner.resourceGroup(), parent.name(), siteInner.name()), this .inner() .getDiagnosticLogsConfigurationSlotAsync( - siteInner.resourceGroup(), parent.name(), siteInner.getName()), + siteInner.resourceGroup(), parent.name(), siteInner.name()), (siteConfigResourceInner, logsConfigInner) -> this.wrapModel(siteInner, siteConfigResourceInner, logsConfigInner))); } @@ -135,6 +135,6 @@ private FunctionDeploymentSlotImpl wrapModel( if (inner == null) { return null; } - return new FunctionDeploymentSlotImpl(inner.getName(), inner, siteConfig, logConfig, parent); + return new FunctionDeploymentSlotImpl(inner.name(), inner, siteConfig, logConfig, parent); } } diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/HostNameBindingImpl.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/HostNameBindingImpl.java index 54bd9f35e882..04c4ea16ec15 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/HostNameBindingImpl.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/implementation/HostNameBindingImpl.java @@ -45,7 +45,7 @@ class HostNameBindingImpl wrapPageAsync(PagedFlux innerPage) { if (siteInner.kind() == null || Arrays.asList(siteInner.kind().split(",")).contains("app")) { return Mono .zip( - this.inner().getConfigurationAsync(siteInner.resourceGroup(), siteInner.getName()), + this.inner().getConfigurationAsync(siteInner.resourceGroup(), siteInner.name()), this .inner() .getDiagnosticLogsConfigurationAsync( - siteInner.resourceGroup(), siteInner.getName()), + siteInner.resourceGroup(), siteInner.name()), (siteConfigResourceInner, logsConfigInner) -> this.wrapModel(siteInner, siteConfigResourceInner, logsConfigInner)); } else { diff --git a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/models/OperationInner.java b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/models/OperationInner.java index 93c0313b9ff5..1b536baa2ee9 100644 --- a/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/models/OperationInner.java +++ b/sdk/appservice/mgmt/src/main/java/com/azure/management/appservice/models/OperationInner.java @@ -68,7 +68,7 @@ public final class OperationInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/AppRole.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/AppRole.java index 1eac9d20969a..cb7849fc6248 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/AppRole.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/AppRole.java @@ -60,7 +60,7 @@ public final class AppRole { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/OAuth2Permission.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/OAuth2Permission.java index 87d7d27c6543..b9e0ef828f30 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/OAuth2Permission.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/OAuth2Permission.java @@ -117,7 +117,7 @@ public OAuth2Permission withAdminConsentDisplayName(String adminConsentDisplayNa * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/ResourceAccess.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/ResourceAccess.java index 98c5386a895a..94a44ac8a28d 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/ResourceAccess.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/ResourceAccess.java @@ -39,7 +39,7 @@ public final class ResourceAccess { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/implementation/RoleAssignmentImpl.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/implementation/RoleAssignmentImpl.java index 3fabf6493164..c20c4402d853 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/implementation/RoleAssignmentImpl.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/implementation/RoleAssignmentImpl.java @@ -43,7 +43,7 @@ class RoleAssignmentImpl extends CreatableImpl assignableScopes() { @Override public String id() { - return inner().getId(); + return inner().id(); } @Override diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ClassicAdministratorInner.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ClassicAdministratorInner.java index ca4ddc100323..5bd8224a2e79 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ClassicAdministratorInner.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ClassicAdministratorInner.java @@ -47,7 +47,7 @@ public class ClassicAdministratorInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ProviderOperationsMetadataInner.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ProviderOperationsMetadataInner.java index 255dbbc36f31..9f3d6e3f028c 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ProviderOperationsMetadataInner.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/ProviderOperationsMetadataInner.java @@ -54,7 +54,7 @@ public final class ProviderOperationsMetadataInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleAssignmentInner.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleAssignmentInner.java index 8973dd009461..d937ab343863 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleAssignmentInner.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleAssignmentInner.java @@ -59,7 +59,7 @@ public class RoleAssignmentInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleDefinitionInner.java b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleDefinitionInner.java index 13c8d2129d49..bbcf499d88f4 100644 --- a/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleDefinitionInner.java +++ b/sdk/authorization/mgmt/src/main/java/com/azure/management/graphrbac/models/RoleDefinitionInner.java @@ -66,7 +66,7 @@ public class RoleDefinitionInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ApiEntityReference.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ApiEntityReference.java index 2c370feaf941..1fd2afbe0bd7 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ApiEntityReference.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ApiEntityReference.java @@ -23,7 +23,7 @@ public final class ApiEntityReference { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/CreationSource.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/CreationSource.java index 9f28cf6a8e4b..478bf8b866b0 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/CreationSource.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/CreationSource.java @@ -63,7 +63,7 @@ public CreationSourceType type() { public String sourceId() { if (this.type() == CreationSourceType.FROM_OS_DISK_IMAGE || this.type() == CreationSourceType.FROM_DATA_DISK_IMAGE) { - return this.creationData.imageReference().getId(); + return this.creationData.imageReference().id(); } if (this.type() == CreationSourceType.IMPORTED_FROM_VHD) { return this.creationData.sourceUri(); diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ImageDiskReference.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ImageDiskReference.java index dc0880a77ccb..c3e464fc5800 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ImageDiskReference.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ImageDiskReference.java @@ -30,7 +30,7 @@ public final class ImageDiskReference { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ManagedArtifact.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ManagedArtifact.java index aca452a7754f..f163ad897e4b 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ManagedArtifact.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/ManagedArtifact.java @@ -21,7 +21,7 @@ public final class ManagedArtifact { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SourceVault.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SourceVault.java index c5026e106650..9a0e3d72958a 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SourceVault.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SourceVault.java @@ -21,7 +21,7 @@ public final class SourceVault { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SubResourceReadOnly.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SubResourceReadOnly.java index 1953b621b139..f86bdf81a475 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SubResourceReadOnly.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/SubResourceReadOnly.java @@ -21,7 +21,7 @@ public class SubResourceReadOnly { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetImpl.java index e2ac377cef81..e33cde28bf68 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetImpl.java @@ -63,7 +63,7 @@ public Set virtualMachineIds() { if (idOfVMsInSet == null) { idOfVMsInSet = new HashSet<>(); for (SubResource resource : this.inner().virtualMachines()) { - idOfVMsInSet.add(resource.getId()); + idOfVMsInSet.add(resource.id()); } } return Collections.unmodifiableSet(idOfVMsInSet); @@ -71,7 +71,7 @@ public Set virtualMachineIds() { @Override public ProximityPlacementGroup proximityPlacementGroup() { - ResourceId id = ResourceId.fromString(inner().proximityPlacementGroup().getId()); + ResourceId id = ResourceId.fromString(inner().proximityPlacementGroup().id()); ProximityPlacementGroupInner plgInner = manager().inner().proximityPlacementGroups().getByResourceGroup(id.resourceGroupName(), id.name()); if (plgInner == null) { @@ -135,7 +135,7 @@ public AvailabilitySetImpl withSku(AvailabilitySetSkuTypes skuType) { @Override public AvailabilitySetImpl withProximityPlacementGroup(String proximityPlacementGroupId) { - this.inner().withProximityPlacementGroup(new SubResource().setId(proximityPlacementGroupId)); + this.inner().withProximityPlacementGroup(new SubResource().withId(proximityPlacementGroupId)); this.newProximityPlacementGroupType = null; this.newProximityPlacementGroupName = null; return this; @@ -190,7 +190,7 @@ private Mono createNewProximityPlacementGroupAsync() { if (this.newProximityPlacementGroupName != null && !this.newProximityPlacementGroupName.isEmpty()) { ProximityPlacementGroupInner plgInner = new ProximityPlacementGroupInner(); plgInner.withProximityPlacementGroupType(this.newProximityPlacementGroupType); - plgInner.setLocation(this.inner().getLocation()); + plgInner.withLocation(this.inner().location()); return this .manager() .inner() @@ -198,7 +198,7 @@ private Mono createNewProximityPlacementGroupAsync() { .createOrUpdateAsync(this.resourceGroupName(), this.newProximityPlacementGroupName, plgInner) .map( createdPlgInner -> { - this.inner().withProximityPlacementGroup(new SubResource().setId(createdPlgInner.getId())); + this.inner().withProximityPlacementGroup(new SubResource().withId(createdPlgInner.id())); return this; }); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetsImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetsImpl.java index 0b2af4512a4a..5a9382b768c1 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetsImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/AvailabilitySetsImpl.java @@ -71,6 +71,6 @@ protected AvailabilitySetImpl wrapModel(AvailabilitySetInner availabilitySetInne if (availabilitySetInner == null) { return null; } - return new AvailabilitySetImpl(availabilitySetInner.getName(), availabilitySetInner, this.manager()); + return new AvailabilitySetImpl(availabilitySetInner.name(), availabilitySetInner, this.manager()); } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/CustomImageDataDiskImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/CustomImageDataDiskImpl.java index c50f690976bd..d2cd4a7fa8f1 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/CustomImageDataDiskImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/CustomImageDataDiskImpl.java @@ -47,19 +47,19 @@ public CustomImageDataDiskImpl fromVhd(String sourceVhdUrl) { @Override public CustomImageDataDiskImpl fromSnapshot(String sourceSnapshotId) { - this.inner().withSnapshot(new SubResource().setId(sourceSnapshotId)); + this.inner().withSnapshot(new SubResource().withId(sourceSnapshotId)); return this; } @Override public CustomImageDataDiskImpl fromManagedDisk(String sourceManagedDiskId) { - this.inner().withManagedDisk(new SubResource().setId(sourceManagedDiskId)); + this.inner().withManagedDisk(new SubResource().withId(sourceManagedDiskId)); return this; } @Override public CustomImageDataDiskImpl fromManagedDisk(Disk sourceManagedDisk) { - this.inner().withManagedDisk(new SubResource().setId(sourceManagedDisk.id())); + this.inner().withManagedDisk(new SubResource().withId(sourceManagedDisk.id())); return this; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/DisksImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/DisksImpl.java index 5ca4bb40aaf4..2bd5f52307f6 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/DisksImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/DisksImpl.java @@ -56,7 +56,7 @@ protected DiskImpl wrapModel(DiskInner inner) { if (inner == null) { return null; } - return new DiskImpl(inner.getName(), inner, this.manager()); + return new DiskImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/EncryptionSettings.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/EncryptionSettings.java index f902922d9f53..e4a7a9aabbdd 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/EncryptionSettings.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/EncryptionSettings.java @@ -64,7 +64,7 @@ DiskEncryptionSettings storageProfileEncryptionSettings() { keyEncryptionKey = new KeyVaultKeyReference(); keyEncryptionKey.withKeyUrl(config.keyEncryptionKeyUrl()); if (config.keyEncryptionKeyVaultId() != null) { - keyEncryptionKey.withSourceVault(new SubResource().setId(config.keyEncryptionKeyVaultId())); + keyEncryptionKey.withSourceVault(new SubResource().withId(config.keyEncryptionKeyVaultId())); } } DiskEncryptionSettings diskEncryptionSettings = new DiskEncryptionSettings(); @@ -73,7 +73,7 @@ DiskEncryptionSettings storageProfileEncryptionSettings() { .withKeyEncryptionKey(keyEncryptionKey) .withDiskEncryptionKey(new KeyVaultSecretReference()) .diskEncryptionKey() - .withSourceVault(new SubResource().setId(config.keyVaultId())); + .withSourceVault(new SubResource().withId(config.keyVaultId())); return diskEncryptionSettings; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleriesImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleriesImpl.java index 08b8bd99653c..ad25e03324d2 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleriesImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleriesImpl.java @@ -97,7 +97,7 @@ public GalleryImpl define(String name) { @Override protected GalleryImpl wrapModel(GalleryInner inner) { - return new GalleryImpl(inner.getName(), inner, manager()); + return new GalleryImpl(inner.name(), inner, manager()); } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageImpl.java index e77a97c40d60..73234fdf4bd1 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageImpl.java @@ -47,14 +47,14 @@ class GalleryImageImpl extends CreatableUpdatableImpl getInnerAsync() { @Override public boolean isInCreateMode() { - return this.inner().getId() == null; + return this.inner().id() == null; } @Override @@ -161,7 +161,7 @@ public String eula() { @Override public String id() { - return this.inner().getId(); + return this.inner().id(); } @Override @@ -171,12 +171,12 @@ public GalleryImageIdentifier identifier() { @Override public String location() { - return this.inner().getLocation(); + return this.inner().location(); } @Override public String name() { - return this.inner().getName(); + return this.inner().name(); } @Override @@ -216,12 +216,12 @@ public String releaseNoteUri() { @Override public Map tags() { - return this.inner().getTags(); + return this.inner().tags(); } @Override public String type() { - return this.inner().getType(); + return this.inner().type(); } @Override @@ -240,13 +240,13 @@ public GalleryImageImpl withExistingGallery(Gallery gallery) { @Override public GalleryImageImpl withLocation(String location) { - this.inner().setLocation(location); + this.inner().withLocation(location); return this; } @Override public GalleryImageImpl withLocation(Region location) { - this.inner().setLocation(location.toString()); + this.inner().withLocation(location.toString()); return this; } @@ -473,7 +473,7 @@ public GalleryImageImpl withReleaseNoteUri(String releaseNoteUri) { @Override public GalleryImageImpl withTags(Map tags) { - this.inner().setTags(tags); + this.inner().withTags(tags); return this; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageVersionImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageVersionImpl.java index bf82f8b0e2c9..fd0a538a061c 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageVersionImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImageVersionImpl.java @@ -42,15 +42,15 @@ class GalleryImageVersionImpl } GalleryImageVersionImpl(GalleryImageVersionInner inner, ComputeManager manager) { - super(inner.getName(), inner); + super(inner.name(), inner); this.manager = manager; // Set resource name - this.galleryImageVersionName = inner.getName(); + this.galleryImageVersionName = inner.name(); // resource ancestor names - this.resourceGroupName = getValueFromIdByName(inner.getId(), "resourceGroups"); - this.galleryName = getValueFromIdByName(inner.getId(), "galleries"); - this.galleryImageName = getValueFromIdByName(inner.getId(), "images"); - this.galleryImageVersionName = getValueFromIdByName(inner.getId(), "versions"); + this.resourceGroupName = getValueFromIdByName(inner.id(), "resourceGroups"); + this.galleryName = getValueFromIdByName(inner.id(), "galleries"); + this.galleryImageName = getValueFromIdByName(inner.id(), "images"); + this.galleryImageVersionName = getValueFromIdByName(inner.id(), "versions"); // } @@ -97,22 +97,22 @@ protected Mono getInnerAsync() { @Override public boolean isInCreateMode() { - return this.inner().getId() == null; + return this.inner().id() == null; } @Override public String id() { - return this.inner().getId(); + return this.inner().id(); } @Override public String location() { - return this.inner().getLocation(); + return this.inner().location(); } @Override public String name() { - return this.inner().getName(); + return this.inner().name(); } @Override @@ -170,12 +170,12 @@ public GalleryImageVersionStorageProfile storageProfile() { @Override public Map tags() { - return this.inner().getTags(); + return this.inner().tags(); } @Override public String type() { - return this.inner().getType(); + return this.inner().type(); } @Override @@ -189,13 +189,13 @@ public GalleryImageVersionImpl withExistingImage( @Override public GalleryImageVersionImpl withLocation(String location) { - this.inner().setLocation(location); + this.inner().withLocation(location); return this; } @Override public DefinitionStages.WithSource withLocation(Region location) { - this.inner().setLocation(location.toString()); + this.inner().withLocation(location.toString()); return this; } @@ -349,7 +349,7 @@ public GalleryImageVersionImpl withoutExcludedFromLatest() { @Override public GalleryImageVersionImpl withTags(Map tags) { - this.inner().setTags(tags); + this.inner().withTags(tags); return this; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImpl.java index 29329753a469..7e79c6c46b0e 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/GalleryImpl.java @@ -43,7 +43,7 @@ protected Mono getInnerAsync() { @Override public boolean isInCreateMode() { - return this.inner().getId() == null; + return this.inner().id() == null; } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java index fb89a06f1ffd..33fd0bb3d49b 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/LinuxDiskVolumeLegacyEncryptionMonitorImpl.java @@ -116,7 +116,7 @@ private Mono retrieveExtensionWithInstanceViewAsyn return computeManager .inner() .virtualMachineExtensions() - .getAsync(rgName, vmName, extension.getName(), "instanceView") + .getAsync(rgName, vmName, extension.name(), "instanceView") .onErrorResume(e -> Mono.empty()); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProximityPlacementGroupImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProximityPlacementGroupImpl.java index 95ea67146c66..861cc12918a1 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProximityPlacementGroupImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProximityPlacementGroupImpl.java @@ -43,7 +43,7 @@ public List availabilitySetIds() { @Override public String location() { - return this.inner().getLocation(); + return this.inner().location(); } @Override @@ -53,7 +53,7 @@ public String resourceGroupName() { @Override public String id() { - return this.inner().getId(); + return this.inner().id(); } @Override @@ -68,7 +68,7 @@ private List getStringListFromSubResourceList(List subList) stringList = new ArrayList<>(); Iterator iter = subList.iterator(); while (iter.hasNext()) { - stringList.add(iter.next().getId()); + stringList.add(iter.next().id()); } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProxyEncryptionMonitorImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProxyEncryptionMonitorImpl.java index aaa6b5b280a3..86e941e0678d 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProxyEncryptionMonitorImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/ProxyEncryptionMonitorImpl.java @@ -86,16 +86,16 @@ public Mono refreshAsync() { self.resolvedEncryptionMonitor = (osType() == OperatingSystemTypes.LINUX) ? new LinuxDiskVolumeNoAADEncryptionMonitorImpl( - virtualMachine.getId(), computeManager) + virtualMachine.id(), computeManager) : new WindowsVolumeNoAADEncryptionMonitorImpl( - virtualMachine.getId(), computeManager); + virtualMachine.id(), computeManager); } else { self.resolvedEncryptionMonitor = (osType() == OperatingSystemTypes.LINUX) ? new LinuxDiskVolumeLegacyEncryptionMonitorImpl( - virtualMachine.getId(), computeManager) + virtualMachine.id(), computeManager) : new WindowsVolumeLegacyEncryptionMonitorImpl( - virtualMachine.getId(), computeManager); + virtualMachine.id(), computeManager); } return self.resolvedEncryptionMonitor.refreshAsync(); }) diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/SnapshotsImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/SnapshotsImpl.java index 2aec864b7110..36cc5d90e4d9 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/SnapshotsImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/SnapshotsImpl.java @@ -58,7 +58,7 @@ protected SnapshotImpl wrapModel(SnapshotInner inner) { if (inner == null) { return null; } - return new SnapshotImpl(inner.getName(), inner, this.manager()); + return new SnapshotImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VMSSPatchPayload.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VMSSPatchPayload.java index 8b9c50b385cf..3ed371b9cef9 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VMSSPatchPayload.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VMSSPatchPayload.java @@ -27,7 +27,7 @@ static VirtualMachineScaleSetUpdate preparePatchPayload(VirtualMachineScaleSet s updateParameter.withPlan(scaleSet.inner().plan()); updateParameter.withSinglePlacementGroup(scaleSet.inner().singlePlacementGroup()); updateParameter.withSku(scaleSet.inner().sku()); - updateParameter.withTags(scaleSet.inner().getTags()); + updateParameter.withTags(scaleSet.inner().tags()); updateParameter.withUpgradePolicy(scaleSet.inner().upgradePolicy()); updateParameter.withAdditionalCapabilities(scaleSet.inner().additionalCapabilities()); // @@ -103,7 +103,7 @@ static VirtualMachineScaleSetUpdate preparePatchPayload(VirtualMachineScaleSet s nicPatchConfig.withName(nicConfig.name()); nicPatchConfig.withNetworkSecurityGroup(nicConfig.networkSecurityGroup()); nicPatchConfig.withPrimary(nicConfig.primary()); - nicPatchConfig.setId(nicConfig.getId()); + nicPatchConfig.withId(nicConfig.id()); if (nicConfig.ipConfigurations() != null) { nicPatchConfig .withIpConfigurations(new ArrayList ()); @@ -120,7 +120,7 @@ static VirtualMachineScaleSetUpdate preparePatchPayload(VirtualMachineScaleSet s patchIpConfig.withPrimary(ipConfig.primary()); patchIpConfig.withPrivateIPAddressVersion(ipConfig.privateIPAddressVersion()); patchIpConfig.withSubnet(ipConfig.subnet()); - patchIpConfig.setId(ipConfig.getId()); + patchIpConfig.withId(ipConfig.id()); if (ipConfig.publicIPAddressConfiguration() != null) { patchIpConfig .withPublicIPAddressConfiguration( @@ -141,7 +141,7 @@ static VirtualMachineScaleSetUpdate preparePatchPayload(VirtualMachineScaleSet s for (SubResource asg : ipConfig.applicationSecurityGroups()) { patchIpConfig .applicationSecurityGroups() - .add(new SubResource().setId(asg.getId())); + .add(new SubResource().withId(asg.id())); } } nicPatchConfig.ipConfigurations().add(patchIpConfig); diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImageImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImageImpl.java index 7c78629bec8d..2e0d9b76d281 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImageImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImageImpl.java @@ -51,7 +51,7 @@ public String sourceVirtualMachineId() { if (this.inner().sourceVirtualMachine() == null) { return null; } - return this.inner().sourceVirtualMachine().getId(); + return this.inner().sourceVirtualMachine().id(); } @Override @@ -76,7 +76,7 @@ public Map dataDiskImages() { @Override public VirtualMachineCustomImageImpl fromVirtualMachine(String virtualMachineId) { - this.inner().withSourceVirtualMachine(new SubResource().setId(virtualMachineId)); + this.inner().withSourceVirtualMachine(new SubResource().withId(virtualMachineId)); return this; } @@ -108,7 +108,7 @@ public VirtualMachineCustomImageImpl withWindowsFromSnapshot( .ensureOsDiskImage() .withOsState(osState) .withOsType(OperatingSystemTypes.WINDOWS) - .withSnapshot(new SubResource().setId(sourceSnapshotId)); + .withSnapshot(new SubResource().withId(sourceSnapshotId)); return this; } @@ -119,7 +119,7 @@ public VirtualMachineCustomImageImpl withLinuxFromSnapshot( .ensureOsDiskImage() .withOsState(osState) .withOsType(OperatingSystemTypes.LINUX) - .withSnapshot(new SubResource().setId(sourceSnapshotId)); + .withSnapshot(new SubResource().withId(sourceSnapshotId)); return this; } @@ -143,7 +143,7 @@ public VirtualMachineCustomImageImpl withWindowsFromDisk( .ensureOsDiskImage() .withOsState(osState) .withOsType(OperatingSystemTypes.WINDOWS) - .withManagedDisk(new SubResource().setId(sourceManagedDiskId)); + .withManagedDisk(new SubResource().withId(sourceManagedDiskId)); return this; } @@ -154,7 +154,7 @@ public VirtualMachineCustomImageImpl withLinuxFromDisk( .ensureOsDiskImage() .withOsState(osState) .withOsType(OperatingSystemTypes.LINUX) - .withManagedDisk(new SubResource().setId(sourceManagedDiskId)); + .withManagedDisk(new SubResource().withId(sourceManagedDiskId)); return this; } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImagesImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImagesImpl.java index 23f95d694ae8..265d366bfaee 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImagesImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineCustomImagesImpl.java @@ -29,7 +29,7 @@ protected VirtualMachineCustomImageImpl wrapModel(ImageInner inner) { if (inner == null) { return null; } - return new VirtualMachineCustomImageImpl(inner.getName(), inner, this.manager()); + return new VirtualMachineCustomImageImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineDataDiskImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineDataDiskImpl.java index d2a7a3dbaf6e..1cbd302fe4e0 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineDataDiskImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineDataDiskImpl.java @@ -51,7 +51,7 @@ public String id() { if (this.inner().managedDisk() == null) { return null; } - return this.inner().managedDisk().getId(); + return this.inner().managedDisk().id(); } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionImageImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionImageImpl.java index 7bab06f80ac5..27eb6a92b08d 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionImageImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionImageImpl.java @@ -22,12 +22,12 @@ class VirtualMachineExtensionImageImpl extends WrapperImpl getInstanceViewAsync() { @Override public Map tags() { - Map tags = this.inner().getTags(); + Map tags = this.inner().tags(); if (tags == null) { tags = new TreeMap<>(); } @@ -178,23 +178,23 @@ public VirtualMachineExtensionImpl withVersion(String extensionImageVersionName) @Override public final VirtualMachineExtensionImpl withTags(Map tags) { - this.inner().setTags(new HashMap<>(tags)); + this.inner().withTags(new HashMap<>(tags)); return this; } @Override public final VirtualMachineExtensionImpl withTag(String key, String value) { - if (this.inner().getTags() == null) { - this.inner().setTags(new HashMap<>()); + if (this.inner().tags() == null) { + this.inner().withTags(new HashMap<>()); } - this.inner().getTags().put(key, value); + this.inner().tags().put(key, value); return this; } @Override public final VirtualMachineExtensionImpl withoutTag(String key) { - if (this.inner().getTags() != null) { - this.inner().getTags().remove(key); + if (this.inner().tags() != null) { + this.inner().tags().remove(key); } return this; } @@ -209,9 +209,9 @@ public VirtualMachineImpl attach() { protected Mono getInnerAsync() { String name; if (this.isReference()) { - name = ResourceUtils.nameFromResourceId(this.inner().getId()); + name = ResourceUtils.nameFromResourceId(this.inner().id()); } else { - name = this.inner().getName(); + name = this.inner().name(); } return this.client.getAsync(this.parent().resourceGroupName(), this.parent().name(), name); } @@ -235,7 +235,7 @@ public Mono createResourceAsync() { public Mono updateResourceAsync() { this.nullifySettingsIfEmpty(); if (this.isReference()) { - String extensionName = ResourceUtils.nameFromResourceId(this.inner().getId()); + String extensionName = ResourceUtils.nameFromResourceId(this.inner().id()); return this .client .getAsync(this.parent().resourceGroupName(), this.parent().name(), extensionName) @@ -281,7 +281,7 @@ public Mono deleteResourceAsync() { * on a specific VM will return fully expanded extension details. */ public boolean isReference() { - return this.inner().getName() == null; + return this.inner().name() == null; } // Helper methods diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java index 79bcb3bd7d18..fc5c5da3b070 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineExtensionsImpl.java @@ -116,17 +116,17 @@ protected List listChildResources() { List childResources = new ArrayList<>(); if (getParent().inner().resources() != null) { for (VirtualMachineExtensionInner inner : getParent().inner().resources()) { - if (inner.getName() == null) { + if (inner.name() == null) { // This extension exists in the parent VM extension collection as a reference id. - inner.setLocation(getParent().regionName()); + inner.withLocation(getParent().regionName()); childResources .add( new VirtualMachineExtensionImpl( - ResourceUtils.nameFromResourceId(inner.getId()), this.getParent(), inner, this.client)); + ResourceUtils.nameFromResourceId(inner.id()), this.getParent(), inner, this.client)); } else { // This extension exists in the parent VM as a fully blown object childResources - .add(new VirtualMachineExtensionImpl(inner.getName(), this.getParent(), inner, this.client)); + .add(new VirtualMachineExtensionImpl(inner.name(), this.getParent(), inner, this.client)); } } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImageImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImageImpl.java index d61088a9809c..0e6cb0f61e5e 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImageImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImageImpl.java @@ -50,7 +50,7 @@ public String id() { if (this.inner() == null) { return null; } - return this.inner().getId(); + return this.inner().id(); } @Override diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImpl.java index 83939d07ba78..ab623fcc926d 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineImpl.java @@ -606,7 +606,7 @@ public VirtualMachineImpl withLatestLinuxImage(String publisher, String offer, S @Override public VirtualMachineImpl withWindowsCustomImage(String customImageId) { ImageReference imageReferenceInner = new ImageReference(); - imageReferenceInner.setId(customImageId); + imageReferenceInner.withId(customImageId); this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE); this.inner().storageProfile().withImageReference(imageReferenceInner); this.inner().osProfile().withWindowsConfiguration(new WindowsConfiguration()); @@ -624,7 +624,7 @@ public VirtualMachineImpl withWindowsGalleryImageVersion(String galleryImageVers @Override public VirtualMachineImpl withLinuxCustomImage(String customImageId) { ImageReference imageReferenceInner = new ImageReference(); - imageReferenceInner.setId(customImageId); + imageReferenceInner.withId(customImageId); this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.FROM_IMAGE); this.inner().storageProfile().withImageReference(imageReferenceInner); this.inner().osProfile().withLinuxConfiguration(new LinuxConfiguration()); @@ -651,7 +651,7 @@ public VirtualMachineImpl withSpecializedOSUnmanagedDisk(String osDiskUrl, Opera @Override public VirtualMachineImpl withSpecializedOSDisk(Disk disk, OperatingSystemTypes osType) { ManagedDiskParameters diskParametersInner = new ManagedDiskParameters(); - diskParametersInner.setId(disk.id()); + diskParametersInner.withId(disk.id()); this.inner().storageProfile().osDisk().withCreateOption(DiskCreateOptionTypes.ATTACH); this.inner().storageProfile().osDisk().withManagedDisk(diskParametersInner); this.inner().storageProfile().osDisk().withOsType(osType); @@ -967,7 +967,7 @@ public VirtualMachineImpl withNewDataDisk( public VirtualMachineImpl withExistingDataDisk(Disk disk) { throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED); ManagedDiskParameters managedDiskParameters = new ManagedDiskParameters(); - managedDiskParameters.setId(disk.id()); + managedDiskParameters.withId(disk.id()); this .managedDataDisks .existingDisksToAttach @@ -979,7 +979,7 @@ public VirtualMachineImpl withExistingDataDisk(Disk disk) { public VirtualMachineImpl withExistingDataDisk(Disk disk, int lun, CachingTypes cachingType) { throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED); ManagedDiskParameters managedDiskParameters = new ManagedDiskParameters(); - managedDiskParameters.setId(disk.id()); + managedDiskParameters.withId(disk.id()); this .managedDataDisks .existingDisksToAttach @@ -991,7 +991,7 @@ public VirtualMachineImpl withExistingDataDisk(Disk disk, int lun, CachingTypes public VirtualMachineImpl withExistingDataDisk(Disk disk, int newSizeInGB, int lun, CachingTypes cachingType) { throwIfManagedDiskDisabled(ManagedUnmanagedDiskErrors.VM_BOTH_UNMANAGED_AND_MANAGED_DISK_NOT_ALLOWED); ManagedDiskParameters managedDiskParameters = new ManagedDiskParameters(); - managedDiskParameters.setId(disk.id()); + managedDiskParameters.withId(disk.id()); this .managedDataDisks .existingDisksToAttach @@ -1086,7 +1086,7 @@ public VirtualMachineImpl withNewAvailabilitySet(Creatable crea @Override public VirtualMachineImpl withProximityPlacementGroup(String proximityPlacementGroupId) { - this.inner().withProximityPlacementGroup(new SubResource().setId(proximityPlacementGroupId)); + this.inner().withProximityPlacementGroup(new SubResource().withId(proximityPlacementGroupId)); // clear the new setting newProximityPlacementGroupName = null; return this; @@ -1158,7 +1158,7 @@ public VirtualMachineImpl withoutSecondaryNetworkInterface(String name) { for (NetworkInterfaceReference nicReference : this.inner().networkProfile().networkInterfaces()) { idx++; if (!nicReference.primary() - && name.equalsIgnoreCase(ResourceUtils.nameFromResourceId(nicReference.getId()))) { + && name.equalsIgnoreCase(ResourceUtils.nameFromResourceId(nicReference.id()))) { this.inner().networkProfile().networkInterfaces().remove(idx); break; } @@ -1401,7 +1401,7 @@ public String osDiskId() { if (!isManagedDiskEnabled()) { return null; } - return this.storageProfile().osDisk().managedDisk().getId(); + return this.storageProfile().osDisk().managedDisk().id(); } @Override @@ -1448,7 +1448,7 @@ public String getPrimaryPublicIPAddressId() { public List networkInterfaceIds() { List nicIds = new ArrayList<>(); for (NetworkInterfaceReference nicRef : inner().networkProfile().networkInterfaces()) { - nicIds.add(nicRef.getId()); + nicIds.add(nicRef.id()); } return nicIds; } @@ -1459,7 +1459,7 @@ public String primaryNetworkInterfaceId() { String primaryNicRefId = null; if (nicRefs.size() == 1) { // One NIC so assume it to be primary - primaryNicRefId = nicRefs.get(0).getId(); + primaryNicRefId = nicRefs.get(0).id(); } else if (nicRefs.size() == 0) { // No NICs so null primaryNicRefId = null; @@ -1467,13 +1467,13 @@ public String primaryNetworkInterfaceId() { // Find primary interface as flagged by Azure for (NetworkInterfaceReference nicRef : inner().networkProfile().networkInterfaces()) { if (nicRef.primary() != null && nicRef.primary()) { - primaryNicRefId = nicRef.getId(); + primaryNicRefId = nicRef.id(); break; } } // If Azure didn't flag any NIC as primary then assume the first one if (primaryNicRefId == null) { - primaryNicRefId = nicRefs.get(0).getId(); + primaryNicRefId = nicRefs.get(0).id(); } } return primaryNicRefId; @@ -1482,7 +1482,7 @@ public String primaryNetworkInterfaceId() { @Override public String availabilitySetId() { if (inner().availabilitySet() != null) { - return inner().availabilitySet().getId(); + return inner().availabilitySet().id(); } return null; } @@ -1499,7 +1499,7 @@ public String licenseType() { @Override public ProximityPlacementGroup proximityPlacementGroup() { - ResourceId id = ResourceId.fromString(inner().proximityPlacementGroup().getId()); + ResourceId id = ResourceId.fromString(inner().proximityPlacementGroup().id()); ProximityPlacementGroupInner plgInner = manager().inner().proximityPlacementGroups().getByResourceGroup(id.resourceGroupName(), id.name()); if (plgInner == null) { @@ -1723,7 +1723,7 @@ public Mono updateResourceAsync() { updateParameter.withAvailabilitySet(this.inner().availabilitySet()); updateParameter.withLicenseType(this.inner().licenseType()); updateParameter.withZones(this.inner().zones()); - updateParameter.withTags(this.inner().getTags()); + updateParameter.withTags(this.inner().tags()); updateParameter.withProximityPlacementGroup(this.inner().proximityPlacementGroup()); updateParameter.withPriority(this.inner().priority()); this.virtualMachineMsiHandler.handleExternalIdentities(updateParameter); @@ -1945,7 +1945,7 @@ private Mono createNewProximityPlacementGroupAsync() { if (this.newProximityPlacementGroupName != null && !this.newProximityPlacementGroupName.isEmpty()) { ProximityPlacementGroupInner plgInner = new ProximityPlacementGroupInner(); plgInner.withProximityPlacementGroupType(this.newProximityPlacementGroupType); - plgInner.setLocation(this.inner().getLocation()); + plgInner.withLocation(this.inner().location()); return this .manager() .inner() @@ -1953,7 +1953,7 @@ private Mono createNewProximityPlacementGroupAsync() { .createOrUpdateAsync(this.resourceGroupName(), this.newProximityPlacementGroupName, plgInner) .map( createdPlgInner -> { - this.inner().withProximityPlacementGroup(new SubResource().setId(createdPlgInner.getId())); + this.inner().withProximityPlacementGroup(new SubResource().withId(createdPlgInner.id())); return this; }); } @@ -1973,7 +1973,7 @@ private void handleNetworkSettings() { if (primaryNetworkInterface != null) { NetworkInterfaceReference nicReference = new NetworkInterfaceReference(); nicReference.withPrimary(true); - nicReference.setId(primaryNetworkInterface.id()); + nicReference.withId(primaryNetworkInterface.id()); this.inner().networkProfile().networkInterfaces().add(nicReference); } } @@ -1985,14 +1985,14 @@ private void handleNetworkSettings() { this.taskResult(creatableSecondaryNetworkInterfaceKey); NetworkInterfaceReference nicReference = new NetworkInterfaceReference(); nicReference.withPrimary(false); - nicReference.setId(secondaryNetworkInterface.id()); + nicReference.withId(secondaryNetworkInterface.id()); this.inner().networkProfile().networkInterfaces().add(nicReference); } for (NetworkInterface secondaryNetworkInterface : this.existingSecondaryNetworkInterfacesToAssociate) { NetworkInterfaceReference nicReference = new NetworkInterfaceReference(); nicReference.withPrimary(false); - nicReference.setId(secondaryNetworkInterface.id()); + nicReference.withId(secondaryNetworkInterface.id()); this.inner().networkProfile().networkInterfaces().add(nicReference); } } @@ -2014,7 +2014,7 @@ private void handleAvailabilitySettings() { this.inner().withAvailabilitySet(new SubResource()); } - this.inner().availabilitySet().setId(availabilitySet.id()); + this.inner().availabilitySet().withId(availabilitySet.id()); } } @@ -2086,7 +2086,7 @@ private boolean isOSDiskAttachedUnmanaged(OSDisk osDisk) { private boolean isOSDiskAttachedManaged(OSDisk osDisk) { return osDisk.createOption() == DiskCreateOptionTypes.ATTACH && osDisk.managedDisk() != null - && osDisk.managedDisk().getId() != null; + && osDisk.managedDisk().id() != null; } /** @@ -2125,7 +2125,7 @@ private boolean isOSDiskFromPlatformImage(StorageProfile storageProfile) { */ private boolean isOsDiskFromCustomImage(StorageProfile storageProfile) { ImageReference imageReference = storageProfile.imageReference(); - return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.getId() != null; + return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.id() != null; } /** @@ -2218,7 +2218,7 @@ public String principalId() { @Override public String resourceId() { if (inner() != null) { - return inner().getId(); + return inner().id(); } else { return null; } @@ -2340,7 +2340,7 @@ private void setAttachableNewDataDisks(Callable nextLun) throws Excepti dataDisk.withLun(nextLun.call()); } dataDisk.withManagedDisk(new ManagedDiskParameters()); - dataDisk.managedDisk().setId(managedDisk.id()); + dataDisk.managedDisk().withId(managedDisk.id()); if (dataDisk.caching() == null) { dataDisk.withCaching(getDefaultCachingType()); } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetImpl.java index c0d465643607..79777d02e29f 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetImpl.java @@ -366,7 +366,7 @@ public int capacity() { @Override public Network getPrimaryNetwork() throws IOException { - String subnetId = primaryNicDefaultIPConfiguration().subnet().getId(); + String subnetId = primaryNicDefaultIPConfiguration().subnet().id(); String virtualNetworkId = ResourceUtils.parentResourceIdFromResourceId(subnetId); return this.networkManager.networks().getById(virtualNetworkId); } @@ -515,7 +515,7 @@ public boolean isAcceleratedNetworkingEnabled() { public String networkSecurityGroupId() { VirtualMachineScaleSetNetworkConfiguration nicConfig = primaryNicConfiguration(); if (nicConfig.networkSecurityGroup() != null) { - return nicConfig.networkSecurityGroup().getId(); + return nicConfig.networkSecurityGroup().id(); } else { return null; } @@ -537,7 +537,7 @@ public List applicationGatewayBackendAddressPoolsIds() { List result = new ArrayList<>(); if (backendPools != null) { for (SubResource backendPool : backendPools) { - result.add(backendPool.getId()); + result.add(backendPool.id()); } } return result; @@ -549,7 +549,7 @@ public List applicationSecurityGroupIds() { List asgIds = new ArrayList<>(); if (nicIpConfig.applicationSecurityGroups() != null) { for (SubResource asg : nicIpConfig.applicationSecurityGroups()) { - asgIds.add(asg.getId()); + asgIds.add(asg.id()); } } return asgIds; @@ -562,7 +562,7 @@ public Boolean doNotRunExtensionsOnOverprovisionedVMs() { @Override public ProximityPlacementGroup proximityPlacementGroup() { - ResourceId id = ResourceId.fromString(inner().proximityPlacementGroup().getId()); + ResourceId id = ResourceId.fromString(inner().proximityPlacementGroup().id()); ProximityPlacementGroupInner plgInner = manager().inner().proximityPlacementGroups().getByResourceGroup(id.resourceGroupName(), id.name()); if (plgInner == null) { @@ -713,7 +713,7 @@ public VirtualMachineScaleSetImpl withExistingPrimaryInternalLoadBalancer(LoadBa this.primaryInternalLoadBalancer, this.primaryNicDefaultIPConfiguration()); } else { String vmNicVnetId = - ResourceUtils.parentResourceIdFromResourceId(primaryNicDefaultIPConfiguration().subnet().getId()); + ResourceUtils.parentResourceIdFromResourceId(primaryNicDefaultIPConfiguration().subnet().id()); if (!vmNicVnetId.equalsIgnoreCase(lbNetworkId)) { throw logger.logExceptionAsError(new IllegalArgumentException( "Virtual network associated with scale set virtual machines" @@ -827,7 +827,7 @@ public VirtualMachineScaleSetImpl withSpecificWindowsImageVersion(ImageReference @Override public VirtualMachineScaleSetImpl withWindowsCustomImage(String customImageId) { ImageReference imageReferenceInner = new ImageReference(); - imageReferenceInner.setId(customImageId); + imageReferenceInner.withId(customImageId); this .inner() .virtualMachineProfile() @@ -891,7 +891,7 @@ public VirtualMachineScaleSetImpl withSpecificLinuxImageVersion(ImageReference i @Override public VirtualMachineScaleSetImpl withLinuxCustomImage(String customImageId) { ImageReference imageReferenceInner = new ImageReference(); - imageReferenceInner.setId(customImageId); + imageReferenceInner.withId(customImageId); this .inner() .virtualMachineProfile() @@ -1907,12 +1907,12 @@ private Mono loadCurrentPrimaryLoadBalancersIfAvaila VirtualMachineScaleSetIPConfiguration ipConfig = primaryNicDefaultIPConfiguration(); if (!ipConfig.loadBalancerBackendAddressPools().isEmpty()) { firstLoadBalancerId = - ResourceUtils.parentResourceIdFromResourceId(ipConfig.loadBalancerBackendAddressPools().get(0).getId()); + ResourceUtils.parentResourceIdFromResourceId(ipConfig.loadBalancerBackendAddressPools().get(0).id()); } if (firstLoadBalancerId == null && !ipConfig.loadBalancerInboundNatPools().isEmpty()) { firstLoadBalancerId = - ResourceUtils.parentResourceIdFromResourceId(ipConfig.loadBalancerInboundNatPools().get(0).getId()); + ResourceUtils.parentResourceIdFromResourceId(ipConfig.loadBalancerInboundNatPools().get(0).id()); } if (firstLoadBalancerId == null) { @@ -1944,18 +1944,18 @@ private Mono loadCurrentPrimaryLoadBalancersIfAvaila String secondLoadBalancerId = null; for (SubResource subResource : ipConfig.loadBalancerBackendAddressPools()) { - if (!subResource.getId().toLowerCase(Locale.ROOT) + if (!subResource.id().toLowerCase(Locale.ROOT) .startsWith(firstLoadBalancerId.toLowerCase(Locale.ROOT))) { - secondLoadBalancerId = ResourceUtils.parentResourceIdFromResourceId(subResource.getId()); + secondLoadBalancerId = ResourceUtils.parentResourceIdFromResourceId(subResource.id()); break; } } if (secondLoadBalancerId == null) { for (SubResource subResource : ipConfig.loadBalancerInboundNatPools()) { - if (!subResource.getId().toLowerCase(Locale.ROOT) + if (!subResource.id().toLowerCase(Locale.ROOT) .startsWith(firstLoadBalancerId.toLowerCase(Locale.ROOT))) { - secondLoadBalancerId = ResourceUtils.parentResourceIdFromResourceId(subResource.getId()); + secondLoadBalancerId = ResourceUtils.parentResourceIdFromResourceId(subResource.id()); break; } } @@ -2028,13 +2028,13 @@ private static void associateBackEndsToIpConfiguration( String backendPoolId = mergePath(loadBalancerId, "backendAddressPools", backendName); boolean found = false; for (SubResource subResource : ipConfig.loadBalancerBackendAddressPools()) { - if (subResource.getId().equalsIgnoreCase(backendPoolId)) { + if (subResource.id().equalsIgnoreCase(backendPoolId)) { found = true; break; } } if (!found) { - backendSubResourcesToAssociate.add(new SubResource().setId(backendPoolId)); + backendSubResourcesToAssociate.add(new SubResource().withId(backendPoolId)); } } @@ -2050,13 +2050,13 @@ private static void associateInboundNATPoolsToIpConfiguration( String inboundNatPoolId = mergePath(loadBalancerId, "inboundNatPools", inboundNatPool); boolean found = false; for (SubResource subResource : ipConfig.loadBalancerInboundNatPools()) { - if (subResource.getId().equalsIgnoreCase(inboundNatPoolId)) { + if (subResource.id().equalsIgnoreCase(inboundNatPoolId)) { found = true; break; } } if (!found) { - inboundNatPoolSubResourcesToAssociate.add(new SubResource().setId(inboundNatPoolId)); + inboundNatPoolSubResourcesToAssociate.add(new SubResource().withId(inboundNatPoolId)); } } @@ -2073,7 +2073,7 @@ private static Map getBackendsAssociatedWithIpConfi for (LoadBalancerBackend lbBackend : lbBackends.values()) { String backendId = mergePath(loadBalancerId, "backendAddressPools", lbBackend.name()); for (SubResource subResource : ipConfig.loadBalancerBackendAddressPools()) { - if (subResource.getId().equalsIgnoreCase(backendId)) { + if (subResource.id().equalsIgnoreCase(backendId)) { attachedBackends.put(lbBackend.name(), lbBackend); } } @@ -2089,7 +2089,7 @@ private static Map getInboundNatPoolsAssocia for (LoadBalancerInboundNatPool lbInboundNatPool : lbInboundNatPools.values()) { String inboundNatPoolId = mergePath(loadBalancerId, "inboundNatPools", lbInboundNatPool.name()); for (SubResource subResource : ipConfig.loadBalancerInboundNatPools()) { - if (subResource.getId().equalsIgnoreCase(inboundNatPoolId)) { + if (subResource.id().equalsIgnoreCase(inboundNatPoolId)) { attachedInboundNatPools.put(lbInboundNatPool.name(), lbInboundNatPool); } } @@ -2130,7 +2130,7 @@ private static void removeAllBackendAssociationFromIpConfiguration( LoadBalancer loadBalancer, VirtualMachineScaleSetIPConfiguration ipConfig) { List toRemove = new ArrayList<>(); for (SubResource subResource : ipConfig.loadBalancerBackendAddressPools()) { - if (subResource.getId().toLowerCase(Locale.ROOT) + if (subResource.id().toLowerCase(Locale.ROOT) .startsWith(loadBalancer.id().toLowerCase(Locale.ROOT) + "/")) { toRemove.add(subResource); } @@ -2145,7 +2145,7 @@ private static void removeAllInboundNatPoolAssociationFromIpConfiguration( LoadBalancer loadBalancer, VirtualMachineScaleSetIPConfiguration ipConfig) { List toRemove = new ArrayList<>(); for (SubResource subResource : ipConfig.loadBalancerInboundNatPools()) { - if (subResource.getId().toLowerCase(Locale.ROOT) + if (subResource.id().toLowerCase(Locale.ROOT) .startsWith(loadBalancer.id().toLowerCase(Locale.ROOT) + "/")) { toRemove.add(subResource); } @@ -2162,7 +2162,7 @@ private static void removeBackendsFromIpConfiguration( for (String backendName : backendNames) { String backendPoolId = mergePath(loadBalancerId, "backendAddressPools", backendName); for (SubResource subResource : ipConfig.loadBalancerBackendAddressPools()) { - if (subResource.getId().equalsIgnoreCase(backendPoolId)) { + if (subResource.id().equalsIgnoreCase(backendPoolId)) { toRemove.add(subResource); break; } @@ -2180,7 +2180,7 @@ private static void removeInboundNatPoolsFromIpConfiguration( for (String natPoolName : inboundNatPoolNames) { String inboundNatPoolId = mergePath(loadBalancerId, "inboundNatPools", natPoolName); for (SubResource subResource : ipConfig.loadBalancerInboundNatPools()) { - if (subResource.getId().equalsIgnoreCase(inboundNatPoolId)) { + if (subResource.id().equalsIgnoreCase(inboundNatPoolId)) { toRemove.add(subResource); break; } @@ -2232,7 +2232,7 @@ public String principalId() { @Override public String resourceId() { if (inner() != null) { - return inner().getId(); + return inner().id(); } else { return null; } @@ -2288,7 +2288,7 @@ private boolean isOSDiskFromImage(VirtualMachineScaleSetOSDisk osDisk) { */ private boolean isOsDiskFromCustomImage(VirtualMachineScaleSetStorageProfile storageProfile) { ImageReference imageReference = storageProfile.imageReference(); - return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.getId() != null; + return isOSDiskFromImage(storageProfile.osDisk()) && imageReference != null && imageReference.id() != null; } /** @@ -2458,14 +2458,14 @@ public VirtualMachineScaleSetImpl withoutIpForwarding() { @Override public VirtualMachineScaleSetImpl withExistingNetworkSecurityGroup(NetworkSecurityGroup networkSecurityGroup) { VirtualMachineScaleSetNetworkConfiguration nicConfig = this.primaryNicConfiguration(); - nicConfig.withNetworkSecurityGroup(new SubResource().setId(networkSecurityGroup.id())); + nicConfig.withNetworkSecurityGroup(new SubResource().withId(networkSecurityGroup.id())); return this; } @Override public VirtualMachineScaleSetImpl withExistingNetworkSecurityGroupId(String networkSecurityGroupId) { VirtualMachineScaleSetNetworkConfiguration nicConfig = this.primaryNicConfiguration(); - nicConfig.withNetworkSecurityGroup(new SubResource().setId(networkSecurityGroupId)); + nicConfig.withNetworkSecurityGroup(new SubResource().withId(networkSecurityGroupId)); return this; } @@ -2496,13 +2496,13 @@ public VirtualMachineScaleSetImpl withExistingApplicationGatewayBackendPool(Stri } boolean found = false; for (SubResource backendPool : nicIpConfig.applicationGatewayBackendAddressPools()) { - if (backendPool.getId().equalsIgnoreCase(backendPoolId)) { + if (backendPool.id().equalsIgnoreCase(backendPoolId)) { found = true; break; } } if (!found) { - nicIpConfig.applicationGatewayBackendAddressPools().add(new SubResource().setId(backendPoolId)); + nicIpConfig.applicationGatewayBackendAddressPools().add(new SubResource().withId(backendPoolId)); } return this; } @@ -2517,7 +2517,7 @@ public VirtualMachineScaleSetImpl withoutApplicationGatewayBackendPool(String ba int index = -1; for (SubResource backendPool : nicIpConfig.applicationGatewayBackendAddressPools()) { index = index + 1; - if (backendPool.getId().equalsIgnoreCase(backendPoolId)) { + if (backendPool.id().equalsIgnoreCase(backendPoolId)) { foundIndex = index; break; } @@ -2543,13 +2543,13 @@ public VirtualMachineScaleSetImpl withExistingApplicationSecurityGroupId(String } boolean found = false; for (SubResource asg : nicIpConfig.applicationSecurityGroups()) { - if (asg.getId().equalsIgnoreCase(applicationSecurityGroupId)) { + if (asg.id().equalsIgnoreCase(applicationSecurityGroupId)) { found = true; break; } } if (!found) { - nicIpConfig.applicationSecurityGroups().add(new SubResource().setId(applicationSecurityGroupId)); + nicIpConfig.applicationSecurityGroups().add(new SubResource().withId(applicationSecurityGroupId)); } return this; } @@ -2564,7 +2564,7 @@ public VirtualMachineScaleSetImpl withoutApplicationSecurityGroup(String applica int index = -1; for (SubResource asg : nicIpConfig.applicationSecurityGroups()) { index = index + 1; - if (asg.getId().equalsIgnoreCase(applicationSecurityGroupId)) { + if (asg.id().equalsIgnoreCase(applicationSecurityGroupId)) { foundIndex = index; break; } @@ -2578,7 +2578,7 @@ public VirtualMachineScaleSetImpl withoutApplicationSecurityGroup(String applica @Override public VirtualMachineScaleSetImpl withProximityPlacementGroup(String proximityPlacementGroupId) { - this.inner().withProximityPlacementGroup(new SubResource().setId(proximityPlacementGroupId)); + this.inner().withProximityPlacementGroup(new SubResource().withId(proximityPlacementGroupId)); this.newProximityPlacementGroupName = null; return this; } @@ -2612,7 +2612,7 @@ private void createNewProximityPlacementGroup() { if (this.newProximityPlacementGroupName != null && !this.newProximityPlacementGroupName.isEmpty()) { ProximityPlacementGroupInner plgInner = new ProximityPlacementGroupInner(); plgInner.withProximityPlacementGroupType(this.newProximityPlacementGroupType); - plgInner.setLocation(this.inner().getLocation()); + plgInner.withLocation(this.inner().location()); plgInner = this .manager() @@ -2620,7 +2620,7 @@ private void createNewProximityPlacementGroup() { .proximityPlacementGroups() .createOrUpdate(this.resourceGroupName(), this.newProximityPlacementGroupName, plgInner); - this.inner().withProximityPlacementGroup((new SubResource().setId(plgInner.getId()))); + this.inner().withProximityPlacementGroup((new SubResource().withId(plgInner.id()))); } } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMImpl.java index c8cd3bb7d045..548dd01fd40d 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMImpl.java @@ -91,17 +91,17 @@ class VirtualMachineScaleSetVMImpl @Override public String id() { - return this.inner().getId(); + return this.inner().id(); } @Override public String name() { - return this.inner().getName(); + return this.inner().name(); } @Override public String regionName() { - return this.inner().getLocation(); + return this.inner().location(); } @Override @@ -111,15 +111,15 @@ public Region region() { @Override public String type() { - return this.inner().getType(); + return this.inner().type(); } @Override public Map tags() { - if (this.inner().getTags() == null) { + if (this.inner().tags() == null) { return Collections.unmodifiableMap(new LinkedHashMap<>()); } - return Collections.unmodifiableMap(this.inner().getTags()); + return Collections.unmodifiableMap(this.inner().tags()); } @Override @@ -164,7 +164,7 @@ public boolean isOSBasedOnPlatformImage() { @Override public boolean isOSBasedOnCustomImage() { ImageReference imageReference = this.inner().storageProfile().imageReference(); - if (imageReference != null && imageReference.getId() != null) { + if (imageReference != null && imageReference.id() != null) { return true; } return false; @@ -207,7 +207,7 @@ public VirtualMachineImage getOSPlatformImage() { public VirtualMachineCustomImage getOSCustomImage() { if (this.isOSBasedOnCustomImage()) { ImageReference imageReference = this.inner().storageProfile().imageReference(); - return this.computeManager.virtualMachineCustomImages().getById(imageReference.getId()); + return this.computeManager.virtualMachineCustomImages().getById(imageReference.id()); } return null; } @@ -236,7 +236,7 @@ public String osUnmanagedDiskVhdUri() { @Override public String osDiskId() { if (this.storageProfile().osDisk().managedDisk() != null) { - return this.storageProfile().osDisk().managedDisk().getId(); + return this.storageProfile().osDisk().managedDisk().id(); } return null; } @@ -346,7 +346,7 @@ public String bootDiagnosticStorageAccountUri() { @Override public String availabilitySetId() { if (this.inner().availabilitySet() != null) { - return this.inner().availabilitySet().getId(); + return this.inner().availabilitySet().id(); } return null; } @@ -355,7 +355,7 @@ public String availabilitySetId() { public List networkInterfaceIds() { List resourceIds = new ArrayList<>(); for (NetworkInterfaceReference reference : this.inner().networkProfile().networkInterfaces()) { - resourceIds.add(reference.getId()); + resourceIds.add(reference.id()); } return Collections.unmodifiableList(resourceIds); } @@ -364,7 +364,7 @@ public List networkInterfaceIds() { public String primaryNetworkInterfaceId() { for (NetworkInterfaceReference reference : this.inner().networkProfile().networkInterfaces()) { if (reference.primary() != null && reference.primary()) { - return reference.getId(); + return reference.id(); } } return null; @@ -377,7 +377,7 @@ public Map extensions() { for (VirtualMachineExtensionInner extensionInner : this.inner().resources()) { extensions .put( - extensionInner.getName(), + extensionInner.name(), new VirtualMachineScaleSetVMInstanceExtensionImpl(extensionInner, this)); } } @@ -594,7 +594,7 @@ public Update withExistingDataDisk( ManagedDiskParameters managedDiskParameters = new ManagedDiskParameters().withStorageAccountType(storageAccountTypes); - managedDiskParameters.setId(dataDisk.id()); + managedDiskParameters.withId(dataDisk.id()); DataDisk attachDataDisk = new DataDisk() diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMInstanceExtensionImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMInstanceExtensionImpl.java index 0ae1ec81d947..93272d6c30f5 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMInstanceExtensionImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetVMInstanceExtensionImpl.java @@ -28,7 +28,7 @@ class VirtualMachineScaleSetVMInstanceExtensionImpl @Override public String name() { - return this.inner().getName(); + return this.inner().name(); } @Override @@ -38,7 +38,7 @@ public String publisherName() { @Override public String typeName() { - return this.inner().getType(); + return this.inner().type(); } @Override @@ -73,10 +73,10 @@ public VirtualMachineExtensionInstanceView instanceView() { @Override public Map tags() { - if (this.inner().getTags() == null) { + if (this.inner().tags() == null) { return Collections.unmodifiableMap(new LinkedHashMap ()); } - return Collections.unmodifiableMap(this.inner().getTags()); + return Collections.unmodifiableMap(this.inner().tags()); } private void initializeSettings() { diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java index 3d96554fef50..cb7ea815f11e 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachineScaleSetsImpl.java @@ -216,6 +216,6 @@ protected VirtualMachineScaleSetImpl wrapModel(VirtualMachineScaleSetInner inner return null; } return new VirtualMachineScaleSetImpl( - inner.getName(), inner, this.manager(), this.storageManager, this.networkManager, this.rbacManager); + inner.name(), inner, this.manager(), this.storageManager, this.networkManager, this.rbacManager); } } diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachinesImpl.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachinesImpl.java index 94d02d9cc112..671427cc1b1f 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachinesImpl.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/implementation/VirtualMachinesImpl.java @@ -221,7 +221,7 @@ protected VirtualMachineImpl wrapModel(VirtualMachineInner virtualMachineInner) return null; } return new VirtualMachineImpl( - virtualMachineInner.getName(), + virtualMachineInner.name(), virtualMachineInner, this.manager(), this.storageManager, diff --git a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/models/RunCommandDocumentBaseInner.java b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/models/RunCommandDocumentBaseInner.java index 8fe6c4402fbe..b3e6b5c11524 100644 --- a/sdk/compute/mgmt/src/main/java/com/azure/management/compute/models/RunCommandDocumentBaseInner.java +++ b/sdk/compute/mgmt/src/main/java/com/azure/management/compute/models/RunCommandDocumentBaseInner.java @@ -66,7 +66,7 @@ public RunCommandDocumentBaseInner withSchema(String schema) { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineCustomImageOperationsTest.java b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineCustomImageOperationsTest.java index cf6b61dd9172..d7def390e163 100644 --- a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineCustomImageOperationsTest.java +++ b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineCustomImageOperationsTest.java @@ -319,8 +319,8 @@ public void canCreateImageFromManagedDisk() { Assertions.assertNotNull(diskImage.managedDisk()); Assertions .assertTrue( - diskImage.managedDisk().getId().equalsIgnoreCase(managedDataDisk1.id()) - || diskImage.managedDisk().getId().equalsIgnoreCase(managedDataDisk2.id())); + diskImage.managedDisk().id().equalsIgnoreCase(managedDataDisk1.id()) + || diskImage.managedDisk().id().equalsIgnoreCase(managedDataDisk2.id())); } computeManager.disks().deleteById(managedOsDisk.id()); computeManager.disks().deleteById(managedDataDisk1.id()); diff --git a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineManagedDiskOperationsTests.java b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineManagedDiskOperationsTests.java index c3714a38dfb6..bbc63e625f64 100644 --- a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineManagedDiskOperationsTests.java +++ b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineManagedDiskOperationsTests.java @@ -327,7 +327,7 @@ public void canCreateVirtualMachineFromCustomImageWithManagedDisks() { Assertions.assertEquals(customImage.dataDiskImages().size(), 5); for (ImageDataDisk imageDataDisk : customImage.dataDiskImages().values()) { Assertions.assertNull(imageDataDisk.blobUri()); - Assertions.assertNotNull(imageDataDisk.managedDisk().getId()); + Assertions.assertNotNull(imageDataDisk.managedDisk().id()); } // Create virtual machine from the custom image diff --git a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineOperationsTests.java b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineOperationsTests.java index b6fbd1a33133..e4ff23004460 100644 --- a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineOperationsTests.java +++ b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineOperationsTests.java @@ -694,13 +694,13 @@ public void canUpdateTagsOnVM() { // checking to see if withTag correctly update virtualMachine.update().withTag("test", "testValue").apply(); - Assertions.assertEquals("testValue", virtualMachine.inner().getTags().get("test")); + Assertions.assertEquals("testValue", virtualMachine.inner().tags().get("test")); // checking to see if withTags correctly updates Map testTags = new HashMap (); testTags.put("testTag", "testValue"); virtualMachine.update().withTags(testTags).apply(); - Assertions.assertEquals(testTags, virtualMachine.inner().getTags()); + Assertions.assertEquals(testTags, virtualMachine.inner().tags()); } @Test diff --git a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineScaleSetOperationsTests.java b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineScaleSetOperationsTests.java index 4666017bc830..58331207f86c 100644 --- a/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineScaleSetOperationsTests.java +++ b/sdk/compute/mgmt/src/test/java/com/azure/management/compute/VirtualMachineScaleSetOperationsTests.java @@ -464,7 +464,7 @@ public void canCreateVirtualMachineScaleSetWithSecret() throws Exception { group .add( new VaultSecretGroup() - .withSourceVault(new SubResource().setId(vault.id())) + .withSourceVault(new SubResource().withId(vault.id())) .withVaultCertificates(certs)); VirtualMachineScaleSet virtualMachineScaleSet = diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/EventContent.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/EventContent.java index 7bc28a9c7237..92391bc7a873 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/EventContent.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/EventContent.java @@ -60,7 +60,7 @@ public final class EventContent { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/ImageUpdateTrigger.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/ImageUpdateTrigger.java index 963b55bf6375..e11944327f73 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/ImageUpdateTrigger.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/ImageUpdateTrigger.java @@ -35,7 +35,7 @@ public final class ImageUpdateTrigger { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/Request.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/Request.java index 3fc6fd0a3124..33cc41487fe4 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/Request.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/Request.java @@ -48,7 +48,7 @@ public final class Request { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/SourceTriggerDescriptor.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/SourceTriggerDescriptor.java index 62eed4c80397..c23e1a4c5d75 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/SourceTriggerDescriptor.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/SourceTriggerDescriptor.java @@ -57,7 +57,7 @@ public final class SourceTriggerDescriptor { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/StorageAccountProperties.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/StorageAccountProperties.java index b63a84dbe63d..cc02d34456da 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/StorageAccountProperties.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/StorageAccountProperties.java @@ -21,7 +21,7 @@ public final class StorageAccountProperties { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistriesImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistriesImpl.java index dd900ebbe96f..5cd90baa498e 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistriesImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistriesImpl.java @@ -45,7 +45,7 @@ public PagedFlux listAsync() { return this .inner() .listAsync() - .mapPage(inner -> new RegistryImpl(inner.getName(), inner, this.manager(), this.storageManager)); + .mapPage(inner -> new RegistryImpl(inner.name(), inner, this.manager(), this.storageManager)); } @Override @@ -89,7 +89,7 @@ protected RegistryImpl wrapModel(RegistryInner containerServiceInner) { } return new RegistryImpl( - containerServiceInner.getName(), containerServiceInner, this.manager(), this.storageManager); + containerServiceInner.name(), containerServiceInner, this.manager(), this.storageManager); } @Override diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryDockerTaskStepImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryDockerTaskStepImpl.java index 5725f0437f41..0e23d3345111 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryDockerTaskStepImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryDockerTaskStepImpl.java @@ -178,7 +178,7 @@ public DockerTaskStep inner() { } private boolean isInCreateMode() { - if (this.taskImpl.inner().getId() == null) { + if (this.taskImpl.inner().id() == null) { return true; } return false; diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryEncodedTaskStepImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryEncodedTaskStepImpl.java index 5c6907d23385..883582f3b0bf 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryEncodedTaskStepImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryEncodedTaskStepImpl.java @@ -143,7 +143,7 @@ public EncodedTaskStep inner() { } private boolean isInCreateMode() { - if (this.taskImpl.inner().getId() == null) { + if (this.taskImpl.inner().id() == null) { return true; } return false; diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryFileTaskStepImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryFileTaskStepImpl.java index 4de000d9ee32..085a5223e849 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryFileTaskStepImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryFileTaskStepImpl.java @@ -143,7 +143,7 @@ public FileTaskStep inner() { } private boolean isInCreateMode() { - if (this.taskImpl.inner().getId() == null) { + if (this.taskImpl.inner().id() == null) { return true; } return false; diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryImpl.java index c56772440db1..0a3f8b7ac1ca 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryImpl.java @@ -75,7 +75,7 @@ public Mono createResourceAsync() { .createAsync(self.resourceGroupName(), self.name(), self.inner()) .map(innerToFluentMap(this)); } else { - updateParameters.withTags(inner().getTags()); + updateParameters.withTags(inner().tags()); return manager() .inner() .registries() @@ -116,7 +116,7 @@ public String storageAccountName() { return null; } - return ResourceUtils.nameFromResourceId(this.inner().storageAccount().getId()); + return ResourceUtils.nameFromResourceId(this.inner().storageAccount().id()); } @Override @@ -125,7 +125,7 @@ public String storageAccountId() { return null; } - return this.inner().storageAccount().getId(); + return this.inner().storageAccount().id(); } @Override diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistrySourceTriggerImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistrySourceTriggerImpl.java index b2b303948061..5abc6813d426 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistrySourceTriggerImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistrySourceTriggerImpl.java @@ -31,7 +31,7 @@ class RegistrySourceTriggerImpl RegistrySourceTriggerImpl(String sourceTriggerName, RegistryTaskImpl registryTaskImpl, boolean creation) { if (creation) { this.registryTaskImpl = registryTaskImpl; - if (registryTaskImpl.inner().getId() == null) { + if (registryTaskImpl.inner().id() == null) { this.inner = new SourceTrigger(); this.inner.withSourceRepository(new SourceProperties()); this.inner.withName(sourceTriggerName); @@ -263,7 +263,7 @@ public SourceTrigger inner() { } private boolean isInCreateMode() { - if (this.registryTaskImpl.inner().getId() == null) { + if (this.registryTaskImpl.inner().id() == null) { return true; } return false; diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryTaskImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryTaskImpl.java index 5b2f3f42859a..6b04e2a142c5 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryTaskImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/RegistryTaskImpl.java @@ -64,22 +64,22 @@ class RegistryTaskImpl implements RegistryTask, RegistryTask.Definition, Registr @Override public String id() { - return this.inner().getId(); + return this.inner().id(); } @Override public String name() { - return this.inner().getName(); + return this.inner().name(); } @Override public String type() { - return this.inner().getType(); + return this.inner().type(); } @Override public String regionName() { - return this.inner().getLocation(); + return this.inner().location(); } @Override @@ -89,7 +89,7 @@ public Region region() { @Override public Map tags() { - return this.inner().getTags(); + return this.inner().tags(); } @Override @@ -184,11 +184,11 @@ public Map sourceTriggers() { RegistryTaskImpl(ContainerRegistryManager registryManager, TaskInner inner) { this.tasksInner = registryManager.inner().tasks(); - this.taskName = inner.getName(); + this.taskName = inner.name(); this.inner = inner; - this.resourceGroupName = ResourceUtils.groupFromResourceId(this.inner.getId()); + this.resourceGroupName = ResourceUtils.groupFromResourceId(this.inner.id()); this.registryName = - ResourceUtils.nameFromResourceId(ResourceUtils.parentResourceIdFromResourceId(this.inner.getId())); + ResourceUtils.nameFromResourceId(ResourceUtils.parentResourceIdFromResourceId(this.inner.id())); this.taskUpdateParameters = new TaskUpdateParameters(); setTaskUpdateParameterTriggers(); } @@ -217,13 +217,13 @@ public RegistryDockerTaskStep.DefinitionStages.Blank defineDockerTaskStep() { @Override public DefinitionStages.Platform withLocation(String location) { - this.inner.setLocation(location); + this.inner.withLocation(location); return this; } @Override public DefinitionStages.Platform withLocation(Region location) { - this.inner.setLocation(location.toString()); + this.inner.withLocation(location.toString()); return this; } @@ -541,7 +541,7 @@ public Mono applyAsync() { } private boolean isInCreateMode() { - if (this.inner().getId() == null) { + if (this.inner().id() == null) { return true; } return false; diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhookImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhookImpl.java index 005b21612ab2..5d03d29927ac 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhookImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhookImpl.java @@ -97,17 +97,17 @@ private void initCreateUpdateParams() { @Override public String id() { - return this.inner().getId(); + return this.inner().id(); } @Override public String type() { - return this.inner().getType(); + return this.inner().type(); } @Override public String regionName() { - return this.inner().getLocation(); + return this.inner().location(); } @Override @@ -117,7 +117,7 @@ public Region region() { @Override public Map tags() { - Map tags = this.inner().getTags(); + Map tags = this.inner().tags(); if (tags == null) { tags = new TreeMap<>(); } @@ -186,7 +186,7 @@ public String ping() { .inner() .webhooks() .ping(this.resourceGroupName, this.registryName, name()) - .getId(); + .id(); } @Override @@ -196,7 +196,7 @@ public Mono pingAsync() { .inner() .webhooks() .pingAsync(this.resourceGroupName, this.registryName, name()) - .map(eventInfoInner -> eventInfoInner.getId()); + .map(eventInfoInner -> eventInfoInner.id()); } @Override @@ -344,7 +344,7 @@ public WebhookImpl withTags(Map tags) { if (tags != null) { this.tags = null; ensureValidTags(); - for (Map.Entry entry : inner().getTags().entrySet()) { + for (Map.Entry entry : inner().tags().entrySet()) { this.tags.put(entry.getKey(), entry.getValue()); } } @@ -404,7 +404,7 @@ public WebhookImpl withCustomHeaders(Map customHeaders) { if (customHeaders != null) { this.customHeaders = null; ensureValidCustomHeaders(); - for (Map.Entry entry : inner().getTags().entrySet()) { + for (Map.Entry entry : inner().tags().entrySet()) { this.customHeaders.put(entry.getKey(), entry.getValue()); } } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhooksClientImpl.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhooksClientImpl.java index cccaff707455..277451833d40 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhooksClientImpl.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/implementation/WebhooksClientImpl.java @@ -77,12 +77,12 @@ public PagedFlux listAsync(final String resourceGroupName, final String inner -> { if (self.containerRegistry != null) { return new WebhookImpl( - inner.getName(), self.containerRegistry, inner, self.containerRegistryManager); + inner.name(), self.containerRegistry, inner, self.containerRegistryManager); } else { return new WebhookImpl( resourceGroupName, registryName, - inner.getName(), + inner.name(), inner, self.containerRegistryManager); } diff --git a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/models/EventInfoInner.java b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/models/EventInfoInner.java index 9aa1c24f1084..324e68030612 100644 --- a/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/models/EventInfoInner.java +++ b/sdk/containerregistry/mgmt/src/main/java/com/azure/management/containerregistry/models/EventInfoInner.java @@ -21,7 +21,7 @@ public class EventInfoInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/ResourceReference.java b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/ResourceReference.java index 0fc40365bb67..11d13661395e 100644 --- a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/ResourceReference.java +++ b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/ResourceReference.java @@ -21,7 +21,7 @@ public final class ResourceReference { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/implementation/KubernetesClustersImpl.java b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/implementation/KubernetesClustersImpl.java index 06c20a40e579..d7d602baa992 100644 --- a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/implementation/KubernetesClustersImpl.java +++ b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/implementation/KubernetesClustersImpl.java @@ -38,7 +38,7 @@ public PagedIterable list() { @Override public PagedFlux listAsync() { - return this.inner().listAsync().mapPage(inner -> new KubernetesClusterImpl(inner.getName(), inner, manager())); + return this.inner().listAsync().mapPage(inner -> new KubernetesClusterImpl(inner.name(), inner, manager())); } @Override @@ -76,7 +76,7 @@ protected KubernetesClusterImpl wrapModel(ManagedClusterInner inner) { return null; } - return new KubernetesClusterImpl(inner.getName(), inner, this.manager()); + return new KubernetesClusterImpl(inner.name(), inner, this.manager()); } @Override diff --git a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolAvailableVersionsInner.java b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolAvailableVersionsInner.java index 287806cfbc64..027a9dc115fe 100644 --- a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolAvailableVersionsInner.java +++ b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolAvailableVersionsInner.java @@ -43,7 +43,7 @@ public class AgentPoolAvailableVersionsInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolUpgradeProfileInner.java b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolUpgradeProfileInner.java index 288bedd6c9c6..dc4ee7d1a5a1 100644 --- a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolUpgradeProfileInner.java +++ b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/AgentPoolUpgradeProfileInner.java @@ -57,7 +57,7 @@ public class AgentPoolUpgradeProfileInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/ManagedClusterUpgradeProfileInner.java b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/ManagedClusterUpgradeProfileInner.java index 98bc9aab5a21..67cc47a9be10 100644 --- a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/ManagedClusterUpgradeProfileInner.java +++ b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/ManagedClusterUpgradeProfileInner.java @@ -49,7 +49,7 @@ public class ManagedClusterUpgradeProfileInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/OrchestratorVersionProfileListResultInner.java b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/OrchestratorVersionProfileListResultInner.java index 7a226cdeab55..b3e273979030 100644 --- a/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/OrchestratorVersionProfileListResultInner.java +++ b/sdk/containerservice/mgmt/src/main/java/com/azure/management/containerservice/models/OrchestratorVersionProfileListResultInner.java @@ -43,7 +43,7 @@ public class OrchestratorVersionProfileListResultInner { * * @return the id value. */ - public String getId() { + public String id() { return this.id; } diff --git a/sdk/core/azure-core-amqp/CHANGELOG.md b/sdk/core/azure-core-amqp/CHANGELOG.md index 8344eff83898..afe1283c77b3 100644 --- a/sdk/core/azure-core-amqp/CHANGELOG.md +++ b/sdk/core/azure-core-amqp/CHANGELOG.md @@ -3,6 +3,13 @@ ## 1.2.0-beta.1 (Unreleased) +## 1.1.2 (2020-05-07) + +- Fixes dependency version of `azure-core`. + +## 1.1.1 (2020-05-07) +- Bug fix to get link size from service the first time before sending message from `ReactorSender`. + ## 1.1.0 (2020-05-04) - Update proton-j dependencies to support larger web socket frame and module name. diff --git a/sdk/core/azure-core-amqp/README.md b/sdk/core/azure-core-amqp/README.md index 84f5ecec0d2f..4b2055a81f78 100644 --- a/sdk/core/azure-core-amqp/README.md +++ b/sdk/core/azure-core-amqp/README.md @@ -16,7 +16,7 @@ own AMQP client library that abstracts from the underlying transport library's i ``` [//]: # ({x-version-update-end}) diff --git a/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSender.java b/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSender.java index 53b714032703..8230223b058c 100644 --- a/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSender.java +++ b/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSender.java @@ -77,7 +77,6 @@ class ReactorSender implements AmqpSendLink { ReplayProcessor.cacheLastOrDefault(AmqpEndpointState.UNINITIALIZED); private FluxSink com.azure azure-core-amqp -1.1.0 +1.1.2 endpointStateSink = endpointStates.sink(FluxSink.OverflowStrategy.BUFFER); - private final TokenManager tokenManager; private final MessageSerializer messageSerializer; private final AmqpRetryPolicy retry; @@ -88,16 +87,10 @@ class ReactorSender implements AmqpSendLink { private volatile Exception lastKnownLinkError; private volatile Instant lastKnownErrorReportedAt; - - /** - * Max message size can change from its initial value. When the send link is opened, we query for the remote link - * capacity. - */ - private volatile int maxMessageSize; + private volatile int linkSize; ReactorSender(String entityPath, Sender sender, SendLinkHandler handler, ReactorProvider reactorProvider, - TokenManager tokenManager, MessageSerializer messageSerializer, Duration timeout, AmqpRetryPolicy retry, - int maxMessageSize) { + TokenManager tokenManager, MessageSerializer messageSerializer, Duration timeout, AmqpRetryPolicy retry) { this.entityPath = entityPath; this.sender = sender; this.handler = handler; @@ -106,7 +99,6 @@ class ReactorSender implements AmqpSendLink { this.messageSerializer = messageSerializer; this.retry = retry; this.timeout = timeout; - this.maxMessageSize = maxMessageSize; this.subscriptions = Disposables.composite( this.handler.getDeliveredMessages().subscribe(this::processDeliveredMessage), @@ -155,26 +147,27 @@ public Flux getEndpointStates() { @Override public Mono send(Message message) { - final int payloadSize = messageSerializer.getSize(message); - final int allocationSize = - Math.min(payloadSize + MAX_AMQP_HEADER_SIZE_BYTES, maxMessageSize); - final byte[] bytes = new byte[allocationSize]; - - int encodedSize; - try { - encodedSize = message.encode(bytes, 0, allocationSize); - } catch (BufferOverflowException exception) { - final String errorMessage = - String.format(Locale.US, - "Error sending. Size of the payload exceeded maximum message size: %s kb", - maxMessageSize / 1024); - final Throwable error = new AmqpException(false, AmqpErrorCondition.LINK_PAYLOAD_SIZE_EXCEEDED, - errorMessage, exception, handler.getErrorContext(sender)); - - return Mono.error(error); - } - - return send(bytes, encodedSize, DeliveryImpl.DEFAULT_MESSAGE_FORMAT); + return getLinkSize() + .flatMap(maxMessageSize -> { + final int payloadSize = messageSerializer.getSize(message); + final int allocationSize = + Math.min(payloadSize + MAX_AMQP_HEADER_SIZE_BYTES, maxMessageSize); + final byte[] bytes = new byte[allocationSize]; + + int encodedSize; + try { + encodedSize = message.encode(bytes, 0, allocationSize); + } catch (BufferOverflowException exception) { + final String errorMessage = + String.format(Locale.US, + "Error sending. Size of the payload exceeded maximum message size: %s kb", + maxMessageSize / 1024); + final Throwable error = new AmqpException(false, AmqpErrorCondition.LINK_PAYLOAD_SIZE_EXCEEDED, + errorMessage, exception, handler.getErrorContext(sender)); + return Mono.error(error); + } + return send(bytes, encodedSize, DeliveryImpl.DEFAULT_MESSAGE_FORMAT); + }); } @Override @@ -183,48 +176,54 @@ public Mono send(List messageBatch) { return send(messageBatch.get(0)); } - final Message firstMessage = messageBatch.get(0); - - // proton-j doesn't support multiple dataSections to be part of AmqpMessage - // here's the alternate approach provided by them: https://github.com/apache/qpid-proton/pull/54 - final Message batchMessage = Proton.message(); - batchMessage.setMessageAnnotations(firstMessage.getMessageAnnotations()); - - final int maxMessageSizeTemp = this.maxMessageSize; - - final byte[] bytes = new byte[maxMessageSizeTemp]; - int encodedSize = batchMessage.encode(bytes, 0, maxMessageSizeTemp); - int byteArrayOffset = encodedSize; - - for (final Message amqpMessage : messageBatch) { - final Message messageWrappedByData = Proton.message(); + return getLinkSize() + .flatMap(maxMessageSize -> { + final Message firstMessage = messageBatch.get(0); + + // proton-j doesn't support multiple dataSections to be part of AmqpMessage + // here's the alternate approach provided by them: https://github.com/apache/qpid-proton/pull/54 + final Message batchMessage = Proton.message(); + batchMessage.setMessageAnnotations(firstMessage.getMessageAnnotations()); + + final int maxMessageSizeTemp = maxMessageSize; + + final byte[] bytes = new byte[maxMessageSizeTemp]; + int encodedSize = batchMessage.encode(bytes, 0, maxMessageSizeTemp); + int byteArrayOffset = encodedSize; + + for (final Message amqpMessage : messageBatch) { + final Message messageWrappedByData = Proton.message(); + + int payloadSize = messageSerializer.getSize(amqpMessage); + int allocationSize = + Math.min(payloadSize + MAX_AMQP_HEADER_SIZE_BYTES, maxMessageSizeTemp); + + byte[] messageBytes = new byte[allocationSize]; + int messageSizeBytes = amqpMessage.encode(messageBytes, 0, allocationSize); + messageWrappedByData.setBody(new Data(new Binary(messageBytes, 0, messageSizeBytes))); + + try { + encodedSize = + messageWrappedByData + .encode(bytes, byteArrayOffset, maxMessageSizeTemp - byteArrayOffset - 1); + } catch (BufferOverflowException exception) { + final String message = + String.format(Locale.US, + "Size of the payload exceeded maximum message size: %s kb", + maxMessageSizeTemp / 1024); + final AmqpException error = new AmqpException(false, + AmqpErrorCondition.LINK_PAYLOAD_SIZE_EXCEEDED, message, exception, + handler.getErrorContext(sender)); + + return Mono.error(error); + } - int payloadSize = messageSerializer.getSize(amqpMessage); - int allocationSize = - Math.min(payloadSize + MAX_AMQP_HEADER_SIZE_BYTES, maxMessageSizeTemp); + byteArrayOffset = byteArrayOffset + encodedSize; + } - byte[] messageBytes = new byte[allocationSize]; - int messageSizeBytes = amqpMessage.encode(messageBytes, 0, allocationSize); - messageWrappedByData.setBody(new Data(new Binary(messageBytes, 0, messageSizeBytes))); + return send(bytes, byteArrayOffset, AmqpConstants.AMQP_BATCH_MESSAGE_FORMAT); + }); - try { - encodedSize = - messageWrappedByData.encode(bytes, byteArrayOffset, maxMessageSizeTemp - byteArrayOffset - 1); - } catch (BufferOverflowException exception) { - final String message = - String.format(Locale.US, - "Size of the payload exceeded maximum message size: %s kb", - maxMessageSizeTemp / 1024); - final AmqpException error = new AmqpException(false, AmqpErrorCondition.LINK_PAYLOAD_SIZE_EXCEEDED, - message, exception, handler.getErrorContext(sender)); - - return Mono.error(error); - } - - byteArrayOffset = byteArrayOffset + encodedSize; - } - - return send(bytes, byteArrayOffset, AmqpConstants.AMQP_BATCH_MESSAGE_FORMAT); } @Override @@ -249,23 +248,29 @@ public String getHostname() { @Override public Mono getLinkSize() { - if (this.hasConnected.get() && this.maxMessageSize > 0) { - return Mono.just(maxMessageSize); + if (linkSize > 0) { + return Mono.just(this.linkSize); } - return RetryUtil.withRetry( - getEndpointStates() - .takeUntil(state -> state == AmqpEndpointState.ACTIVE) - .then(Mono.fromCallable(() -> { - final UnsignedLong remoteMaxMessageSize = sender.getRemoteMaxMessageSize(); - - if (remoteMaxMessageSize != null) { - this.maxMessageSize = remoteMaxMessageSize.intValue(); - } + synchronized (this) { + if (linkSize > 0) { + return Mono.just(this.linkSize); + } - return this.maxMessageSize; - })), - timeout, retry); + return RetryUtil.withRetry( + getEndpointStates() + .takeUntil(state -> state == AmqpEndpointState.ACTIVE) + .then(Mono.fromCallable(() -> { + final UnsignedLong remoteMaxMessageSize = sender.getRemoteMaxMessageSize(); + + if (remoteMaxMessageSize != null) { + this.linkSize = remoteMaxMessageSize.intValue(); + } + + return this.linkSize; + })), + timeout, retry); + } } @Override @@ -284,7 +289,7 @@ public void dispose() { tokenManager.close(); } - private Mono send(byte[] bytes, int arrayOffset, int messageFormat) { + Mono send(byte[] bytes, int arrayOffset, int messageFormat) { if (hasConnected.get()) { return Mono.create(sink -> send(new RetriableWorkItem(bytes, arrayOffset, messageFormat, sink, timeout))); } else { diff --git a/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSession.java b/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSession.java index 0f52af5038f0..6308e628c7b7 100644 --- a/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSession.java +++ b/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/ReactorSession.java @@ -336,7 +336,7 @@ private LinkSubscription getSubscription(String linkName, String e sender.open(); final ReactorSender reactorSender = new ReactorSender(entityPath, sender, sendLinkHandler, provider, - tokenManager, messageSerializer, timeout, retry, ClientConstants.MAX_MESSAGE_LENGTH_BYTES); + tokenManager, messageSerializer, timeout, retry); final Disposable subscription = reactorSender.getEndpointStates().subscribe(state -> { }, error -> { diff --git a/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/ReactorSenderTest.java b/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/ReactorSenderTest.java new file mode 100644 index 000000000000..58cf1b7a341d --- /dev/null +++ b/sdk/core/azure-core-amqp/src/test/java/com/azure/core/amqp/implementation/ReactorSenderTest.java @@ -0,0 +1,182 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.core.amqp.implementation; + +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +import com.azure.core.amqp.AmqpRetryOptions; +import com.azure.core.amqp.ExponentialAmqpRetryPolicy; +import com.azure.core.amqp.exception.AmqpException; +import com.azure.core.amqp.exception.AmqpResponseCode; +import com.azure.core.amqp.implementation.handler.SendLinkHandler; +import java.io.IOException; +import java.time.Duration; +import java.util.Arrays; +import org.apache.qpid.proton.Proton; +import org.apache.qpid.proton.amqp.UnsignedLong; +import org.apache.qpid.proton.amqp.messaging.Accepted; +import org.apache.qpid.proton.amqp.messaging.AmqpValue; +import org.apache.qpid.proton.engine.Delivery; +import org.apache.qpid.proton.engine.EndpointState; +import org.apache.qpid.proton.engine.Record; +import org.apache.qpid.proton.engine.Sender; +import org.apache.qpid.proton.message.Message; +import org.apache.qpid.proton.reactor.Reactor; +import org.apache.qpid.proton.reactor.Selectable; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import reactor.core.publisher.Flux; +import reactor.core.publisher.Mono; +import reactor.test.StepVerifier; + +/** + * Unit tests for {@link ReactorSender} + */ +public class ReactorSenderTest { + + private String entityPath = "entity-path"; + + @Mock + private Sender sender; + @Mock + private SendLinkHandler handler; + @Mock + private ReactorProvider reactorProvider; + @Mock + private TokenManager tokenManager; + @Mock + private Reactor reactor; + @Mock + private Selectable selectable; + @Mock + private MessageSerializer messageSerializer; + + @BeforeEach + public void setup() throws IOException { + MockitoAnnotations.initMocks(this); + + Delivery delivery = mock(Delivery.class); + when(delivery.getRemoteState()).thenReturn(Accepted.getInstance()); + when(delivery.getTag()).thenReturn("tag".getBytes()); + when(handler.getDeliveredMessages()).thenReturn(Flux.just(delivery)); + when(reactor.selectable()).thenReturn(selectable); + + when(handler.getLinkCredits()).thenReturn(Flux.just(100)); + when(handler.getEndpointStates()).thenReturn(Flux.just(EndpointState.ACTIVE)); + when(handler.getErrors()).thenReturn(Flux.empty()); + when(tokenManager.getAuthorizationResults()).thenReturn(Flux.just(AmqpResponseCode.ACCEPTED)); + when(sender.getCredit()).thenReturn(0); + doNothing().when(selectable).setChannel(any()); + doNothing().when(selectable).onReadable(any()); + doNothing().when(selectable).onFree(any()); + doNothing().when(selectable).setReading(true); + doNothing().when(reactor).update(selectable); + ReactorDispatcher reactorDispatcher = new ReactorDispatcher(reactor); + when(reactor.attachments()).thenReturn(new Record() { + @Override + public T get(Object o, Class aClass) { + return null; + } + + @Override + public void set(Object o, Class aClass, T t) { + + } + + @Override + public void clear() { + + } + }); + when(reactorProvider.getReactorDispatcher()).thenReturn(reactorDispatcher); + when(sender.getRemoteMaxMessageSize()).thenReturn(UnsignedLong.valueOf(1000)); + } + + @Test + public void testLinkSize() throws IOException { + ReactorSender reactorSender = new ReactorSender(entityPath, sender, handler, reactorProvider, tokenManager, + messageSerializer, Duration.ofSeconds(1), new ExponentialAmqpRetryPolicy(new AmqpRetryOptions())); + StepVerifier.create(reactorSender.getLinkSize()) + .expectNext(1000) + .verifyComplete(); + StepVerifier.create(reactorSender.getLinkSize()) + .expectNext(1000) + .verifyComplete(); + verify(sender, times(1)).getRemoteMaxMessageSize(); + } + + @Test + public void testSend() { + Message message = Proton.message(); + message.setMessageId("id"); + message.setBody(new AmqpValue("hello")); + ReactorSender reactorSender = new ReactorSender(entityPath, sender, handler, reactorProvider, tokenManager, + messageSerializer, Duration.ofSeconds(1), new ExponentialAmqpRetryPolicy(new AmqpRetryOptions())); + ReactorSender spyReactorSender = spy(reactorSender); + + doReturn(Mono.empty()).when(spyReactorSender).send(any(byte[].class), anyInt(), anyInt()); + StepVerifier.create(spyReactorSender.send(message)) + .verifyComplete(); + StepVerifier.create(spyReactorSender.send(message)) + .verifyComplete(); + verify(sender, times(1)).getRemoteMaxMessageSize(); + verify(spyReactorSender, times(2)).send(any(byte[].class), anyInt(), anyInt()); + } + + @Test + public void testSendBatch() { + Message message = Proton.message(); + message.setMessageId("id1"); + message.setBody(new AmqpValue("hello")); + + Message message2 = Proton.message(); + message2.setMessageId("id2"); + message2.setBody(new AmqpValue("world")); + + ReactorSender reactorSender = new ReactorSender(entityPath, sender, handler, reactorProvider, tokenManager, + messageSerializer, Duration.ofSeconds(1), new ExponentialAmqpRetryPolicy(new AmqpRetryOptions())); + ReactorSender spyReactorSender = spy(reactorSender); + + doReturn(Mono.empty()).when(spyReactorSender).send(any(byte[].class), anyInt(), anyInt()); + StepVerifier.create(spyReactorSender.send(Arrays.asList(message, message2))) + .verifyComplete(); + StepVerifier.create(spyReactorSender.send(Arrays.asList(message, message2))) + .verifyComplete(); + verify(sender, times(1)).getRemoteMaxMessageSize(); + verify(spyReactorSender, times(2)).send(any(byte[].class), anyInt(), anyInt()); + } + + @Test + public void testLinkSizeSmallerThanMessageSize() { + when(sender.getRemoteMaxMessageSize()).thenReturn(UnsignedLong.valueOf(10)); + Message message = Proton.message(); + message.setMessageId("id"); + message.setBody(new AmqpValue("hello")); + ReactorSender reactorSender = new ReactorSender(entityPath, sender, handler, reactorProvider, tokenManager, + messageSerializer, Duration.ofSeconds(1), new ExponentialAmqpRetryPolicy(new AmqpRetryOptions())); + ReactorSender spyReactorSender = spy(reactorSender); + + doReturn(Mono.empty()).when(spyReactorSender).send(any(byte[].class), anyInt(), anyInt()); + StepVerifier.create(spyReactorSender.send(message)) + .verifyErrorSatisfies(throwable -> { + Assertions.assertTrue(throwable instanceof AmqpException); + Assertions.assertTrue(throwable.getMessage().startsWith("Error sending. Size of the payload exceeded " + + "maximum message size")); + }); + verify(sender, times(1)).getRemoteMaxMessageSize(); + verify(spyReactorSender, times(0)).send(any(byte[].class), anyInt(), anyInt()); + } + +} diff --git a/sdk/core/azure-core-serializer-json-gson/CHANGELOG.md b/sdk/core/azure-core-serializer-json-gson/CHANGELOG.md index 8df66935cab9..2eadb1c6038f 100644 --- a/sdk/core/azure-core-serializer-json-gson/CHANGELOG.md +++ b/sdk/core/azure-core-serializer-json-gson/CHANGELOG.md @@ -1,5 +1,8 @@ # Release History +## 1.0.0-beta.2 (Unreleased) + + ## 1.0.0-beta.1 (2020-05-04) -- Initial release. Please see the README and wiki for information on the new design. \ No newline at end of file +- Initial release. Please see the README and wiki for information on the new design. diff --git a/sdk/core/azure-core-serializer-json-gson/README.md b/sdk/core/azure-core-serializer-json-gson/README.md index fddde2c0c585..b6a6caeb2997 100644 --- a/sdk/core/azure-core-serializer-json-gson/README.md +++ b/sdk/core/azure-core-serializer-json-gson/README.md @@ -45,4 +45,7 @@ Azure Projects Contribution Guidelines](http://azure.github.io/guidelines.html). 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request + +[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK +  diff --git a/sdk/core/azure-core-serializer-json-jackson/README.md b/sdk/core/azure-core-serializer-json-jackson/README.md index a04b2e3a675e..12539da9988e 100644 --- a/sdk/core/azure-core-serializer-json-jackson/README.md +++ b/sdk/core/azure-core-serializer-json-jackson/README.md @@ -45,4 +45,7 @@ Azure Projects Contribution Guidelines](http://azure.github.io/guidelines.html). 4. Push to the branch (`git push origin my-new-feature`) 5. Create new Pull Request + +[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK +  diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsynReadWithMultipleClients.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsynReadWithMultipleClients.java index b7d1250c6cfa..dd9c0ad47baf 100644 --- a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsynReadWithMultipleClients.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsynReadWithMultipleClients.java @@ -226,6 +226,7 @@ private void createClients() { .connectionPolicy(configuration.getConnectionPolicy()) .consistencyLevel(configuration.getConsistencyLevel()) .connectionReuseAcrossClientsEnabled(true) + .contentResponseOnWriteEnabled(Boolean.parseBoolean(configuration.isContentResponseOnWriteEnabled())) .buildAsyncClient(); List docsToRead = new ArrayList<>(); CosmosAsyncDatabase cosmosAsyncDatabase = null; diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsyncBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsyncBenchmark.java index b1530abb1a30..7324fcfcf5e1 100644 --- a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsyncBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/AsyncBenchmark.java @@ -66,6 +66,7 @@ abstract class AsyncBenchmark { .key(cfg.getMasterKey()) .connectionPolicy(cfg.getConnectionPolicy()) .consistencyLevel(cfg.getConsistencyLevel()) + .contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled())) .buildAsyncClient(); configuration = cfg; logger = LoggerFactory.getLogger(this.getClass()); diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Configuration.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Configuration.java index 377e3c5f18c9..9a7d35eabbb4 100644 --- a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Configuration.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Configuration.java @@ -130,6 +130,9 @@ public Duration convert(String value) { @Parameter(names = "-useSync", description = "Uses Sync API") private boolean useSync = false; + @Parameter(names = "-contentResponseOnWriteEnabled", description = "if set to false, does not returns content response on document write operations") + private String contentResponseOnWriteEnabled = String.valueOf(true); + @Parameter(names = {"-h", "-help", "--help"}, description = "Help", help = true) private boolean help = false; @@ -264,6 +267,10 @@ ConsistencyLevel getConsistencyLevel() { return consistencyLevel; } + String isContentResponseOnWriteEnabled() { + return contentResponseOnWriteEnabled; + } + String getDatabaseId() { return databaseId; } diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Main.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Main.java index 26c7fdd3c285..d2b4295a8d74 100644 --- a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Main.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/Main.java @@ -27,6 +27,8 @@ public static void main(String[] args) throws Exception { return; } + validateConfiguration(cfg); + if (cfg.isSync()) { syncBenchmark(cfg); } else { @@ -44,6 +46,19 @@ public static void main(String[] args) throws Exception { } } + private static void validateConfiguration(Configuration cfg) { + switch (cfg.getOperationType()) { + case WriteLatency: + case WriteThroughput: + break; + default: + if (!Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled())) { + throw new IllegalArgumentException("contentResponseOnWriteEnabled parameter can only be set to false " + + "for write latency and write throughput operations"); + } + } + } + private static void syncBenchmark(Configuration cfg) throws Exception { LOGGER.info("Sync benchmark ..."); SyncBenchmark benchmark = null; diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/SyncBenchmark.java b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/SyncBenchmark.java index e27f7939db8f..ddd4420301cd 100644 --- a/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/SyncBenchmark.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/main/java/com/azure/cosmos/benchmark/SyncBenchmark.java @@ -105,6 +105,7 @@ public T apply(T o, Throwable throwable) { .key(cfg.getMasterKey()) .connectionPolicy(cfg.getConnectionPolicy()) .consistencyLevel(cfg.getConsistencyLevel()) + .contentResponseOnWriteEnabled(Boolean.parseBoolean(cfg.isContentResponseOnWriteEnabled())) .buildClient(); try { diff --git a/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/cosmos/benchmark/Utils.java b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/cosmos/benchmark/Utils.java index bdbca32cdbed..e55098ca9480 100644 --- a/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/cosmos/benchmark/Utils.java +++ b/sdk/cosmos/azure-cosmos-benchmark/src/test/java/com/azure/cosmos/benchmark/Utils.java @@ -26,9 +26,10 @@ public static AsyncDocumentClient housekeepingClient() { options.setMaxRetryWaitTime(Duration.ofSeconds(60)); connectionPolicy.setThrottlingRetryOptions(options); return new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) - .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) - .withConnectionPolicy(connectionPolicy) - .build(); + .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) + .withConnectionPolicy(connectionPolicy) + .withContentResponseOnWriteEnabled(true) + .build(); } public static String getCollectionLink(Database db, DocumentCollection collection) { diff --git a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java index 3200aba9020a..439f510ed9f7 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/examples/ChangeFeed/SampleChangeFeedProcessor.java @@ -121,6 +121,7 @@ public static CosmosAsyncClient getCosmosClient() { .key(SampleConfigurations.MASTER_KEY) .connectionPolicy(ConnectionPolicy.getDefaultPolicy()) .consistencyLevel(ConsistencyLevel.EVENTUAL) + .contentResponseOnWriteEnabled(true) .buildAsyncClient(); } diff --git a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java index a6707b2e8391..5b15fbd2a274 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java +++ b/sdk/cosmos/azure-cosmos-examples/src/main/java/com/azure/cosmos/rx/examples/multimaster/samples/MultiMasterScenario.java @@ -59,7 +59,9 @@ public MultiMasterScenario() { .withMasterKeyOrResourceToken(this.accountKey) .withServiceEndpoint(this.accountEndpoint) .withConsistencyLevel(ConsistencyLevel.EVENTUAL) - .withConnectionPolicy(policy).build(); + .withConnectionPolicy(policy) + .withContentResponseOnWriteEnabled(true) + .build(); workers.add(new Worker(client, databaseName, basicCollectionName)); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java index 6e572f6febe4..04a10a6d4fff 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CollectionCRUDAsyncAPITest.java @@ -81,7 +81,8 @@ public void before_CollectionCRUDAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/ConflictAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/ConflictAPITest.java index 9c6d26038223..3271607d60ef 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/ConflictAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/ConflictAPITest.java @@ -59,7 +59,8 @@ public void before_ConflictAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CosmosAuthorizationTokenResolverTest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CosmosAuthorizationTokenResolverTest.java index bc051fe7596a..380a27b0dd2a 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CosmosAuthorizationTokenResolverTest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/CosmosAuthorizationTokenResolverTest.java @@ -69,7 +69,8 @@ public void before_TokenResolverTest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); @@ -145,6 +146,7 @@ public void readDocumentThroughTokenResolver() throws Exception { .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.SESSION) .withTokenResolver(getTokenResolverForRead()) + .withContentResponseOnWriteEnabled(true) .build(); List > capturedResponse = Collections .synchronizedList(new ArrayList<>()); @@ -183,6 +185,7 @@ public void deleteDocumentThroughTokenResolver() throws Exception { .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.SESSION) .withTokenResolver(getTokenResolverForReadWrite()) + .withContentResponseOnWriteEnabled(true) .build(); List > capturedResponse = Collections .synchronizedList(new ArrayList<>()); @@ -225,6 +228,7 @@ public void blockListUserThroughTokenResolver() throws Exception { .withConnectionPolicy(connectionPolicy) .withConsistencyLevel(ConsistencyLevel.SESSION) .withTokenResolver(getTokenResolverWithBlockList(blockListedUserId, errorMessage)) + .withContentResponseOnWriteEnabled(true) .build(); // READ a document using a block listed user, passing the 'userId' in the item. diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java index 62da255a422d..5e76d3df1931 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DatabaseCRUDAsyncAPITest.java @@ -65,7 +65,8 @@ public void before_DatabaseCRUDAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); } diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java index 4db2b93f169e..04cca82d59e1 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentCRUDAsyncAPITest.java @@ -89,7 +89,8 @@ public void before_DocumentCRUDAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentQueryAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentQueryAsyncAPITest.java index b32b68fb54f1..5c9d999137f2 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentQueryAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/DocumentQueryAsyncAPITest.java @@ -85,7 +85,8 @@ public void before_DocumentQueryAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/InMemoryGroupbyTest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/InMemoryGroupbyTest.java index c24d34f7d5d3..b6a2008bb378 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/InMemoryGroupbyTest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/InMemoryGroupbyTest.java @@ -46,7 +46,8 @@ public void before_InMemoryGroupbyTest() throws Exception { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/OfferCRUDAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/OfferCRUDAsyncAPITest.java index e19ed9deba1a..1cea3438e29b 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/OfferCRUDAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/OfferCRUDAsyncAPITest.java @@ -50,7 +50,8 @@ public void before_OfferCRUDAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/StoredProcedureAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/StoredProcedureAsyncAPITest.java index 5af4fe79426d..a02fa03358aa 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/StoredProcedureAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/StoredProcedureAsyncAPITest.java @@ -56,7 +56,8 @@ public void before_StoredProcedureAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/UniqueIndexAsyncAPITest.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/UniqueIndexAsyncAPITest.java index f4c0f9bd4d75..924561d43a40 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/UniqueIndexAsyncAPITest.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/UniqueIndexAsyncAPITest.java @@ -91,7 +91,8 @@ public void before_UniqueIndexAsyncAPITest() { .withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) .withConnectionPolicy(connectionPolicy) - .withConsistencyLevel(ConsistencyLevel.SESSION); + .withConsistencyLevel(ConsistencyLevel.SESSION) + .withContentResponseOnWriteEnabled(true); this.client = this.clientBuilder().build(); diff --git a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/Utils.java b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/Utils.java index eeec67601ac5..1972f39c53a4 100644 --- a/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/Utils.java +++ b/sdk/cosmos/azure-cosmos-examples/src/test/java/com/azure/cosmos/rx/examples/Utils.java @@ -28,7 +28,7 @@ public void cleanupStaleDatabase() { connectionPolicy.setThrottlingRetryOptions(options); AsyncDocumentClient client = new AsyncDocumentClient.Builder().withServiceEndpoint(TestConfigurations.HOST) .withMasterKeyOrResourceToken(TestConfigurations.MASTER_KEY) - .withConnectionPolicy(connectionPolicy) + .withConnectionPolicy(connectionPolicy).withContentResponseOnWriteEnabled(true) .build(); safeCleanDatabases(client); client.close(); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java index e30ff232cd61..afdb6877aa63 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncClient.java @@ -16,6 +16,7 @@ import com.azure.cosmos.models.FeedOptions; import com.azure.cosmos.models.ModelBridgeInternal; import com.azure.cosmos.models.SqlQuerySpec; +import com.azure.cosmos.models.ThroughputProperties; import com.azure.cosmos.util.CosmosPagedFlux; import com.azure.cosmos.util.UtilBridgeInternal; import io.micrometer.core.instrument.MeterRegistry; @@ -49,6 +50,7 @@ public final class CosmosAsyncClient implements Closeable { private final CosmosKeyCredential cosmosKeyCredential; private final boolean sessionCapturingOverride; private final boolean enableTransportClientSharing; + private final boolean contentResponseOnWriteEnabled; CosmosAsyncClient(CosmosClientBuilder builder) { this.configs = builder.configs(); @@ -61,6 +63,7 @@ public final class CosmosAsyncClient implements Closeable { this.cosmosKeyCredential = builder.getKeyCredential(); this.sessionCapturingOverride = builder.isSessionCapturingOverrideEnabled(); this.enableTransportClientSharing = builder.isConnectionReuseAcrossClientsEnabled(); + this.contentResponseOnWriteEnabled = builder.isContentResponseOnWriteEnabled(); this.asyncDocumentClient = new AsyncDocumentClient.Builder() .withServiceEndpoint(this.serviceEndpoint) .withMasterKeyOrResourceToken(this.keyOrResourceToken) @@ -71,6 +74,7 @@ public final class CosmosAsyncClient implements Closeable { .withTokenResolver(this.cosmosAuthorizationTokenResolver) .withCosmosKeyCredential(this.cosmosKeyCredential) .withTransportClientSharing(this.enableTransportClientSharing) + .withContentResponseOnWriteEnabled(this.contentResponseOnWriteEnabled) .build(); } @@ -163,6 +167,22 @@ CosmosKeyCredential cosmosKeyCredential() { return cosmosKeyCredential; } + /** + * Gets the boolean which indicates whether to only return the headers and status code in Cosmos DB response + * in case of Create, Update and Delete operations on CosmosItem. + * + * If set to false (which is by default), this removes the resource from response. It reduces networking + * and CPU load by not sending the resource back over the network and serializing it + * on the client. + * + * By-default, this is false. + * + * @return a boolean indicating whether resource will be included in the response or not + */ + boolean isContentResponseOnWriteEnabled() { + return contentResponseOnWriteEnabled; + } + /** * CREATE a Database if it does not already exist on the service * @@ -323,6 +343,19 @@ public Mono
createDatabase(String id, int throughpu return createDatabase(new CosmosDatabaseProperties(id), options); } + /** + * Creates a database. + * + * @param id the id + * @param throughputProperties the throughputProperties + * @return the mono + */ + public Mono createDatabase(String id, ThroughputProperties throughputProperties) { + CosmosDatabaseRequestOptions options = new CosmosDatabaseRequestOptions(); + ModelBridgeInternal.setOfferProperties(options, throughputProperties); + return createDatabase(new CosmosDatabaseProperties(id), options); + } + /** * Reads all databases. * diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java index f33665cdbc54..9e416dc328a7 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncContainer.java @@ -19,6 +19,8 @@ import com.azure.cosmos.models.ModelBridgeInternal; import com.azure.cosmos.models.PartitionKey; import com.azure.cosmos.models.SqlQuerySpec; +import com.azure.cosmos.models.ThroughputProperties; +import com.azure.cosmos.models.ThroughputResponse; import com.azure.cosmos.util.CosmosPagedFlux; import com.azure.cosmos.util.UtilBridgeInternal; import reactor.core.publisher.Flux; @@ -661,6 +663,70 @@ public Mono
replaceProvisionedThroughput(int requestUnitsPerSecond) { }).map(offerResourceResponse -> offerResourceResponse.getResource().getThroughput()); } + /** + * Replace the throughput . + * + * @param throughputProperties the throughput properties + * @return the mono containing throughput response + */ + public Mono replaceThroughput(ThroughputProperties throughputProperties) { + return this.read() + .flatMap(response -> this.database.getDocClientWrapper() + .queryOffers(database.getOfferQuerySpecFromResourceId(response + .getProperties() + .getResourceId()) + , new FeedOptions()) + .single() + .flatMap(offerFeedResponse -> { + if (offerFeedResponse.getResults().isEmpty()) { + return Mono.error(BridgeInternal + .createCosmosClientException( + HttpConstants.StatusCodes.BADREQUEST, + "No offers found for the " + + "resource " + this.getId())); + } + + Offer existingOffer = offerFeedResponse.getResults().get(0); + Offer updatedOffer = + ModelBridgeInternal.updateOfferFromProperties(existingOffer, + throughputProperties); + return this.database.getDocClientWrapper() + .replaceOffer(updatedOffer) + .single(); + }).map(ModelBridgeInternal::createThroughputRespose)); + } + + /** + * Read the throughput throughput . + * + * @return the mono containing throughput response + */ + public Mono readThroughput() { + return this.read() + .flatMap(response -> this.database.getDocClientWrapper() + .queryOffers(database.getOfferQuerySpecFromResourceId(response + .getProperties() + .getResourceId()) + , new FeedOptions()) + .single() + .flatMap(offerFeedResponse -> { + if (offerFeedResponse.getResults().isEmpty()) { + return Mono.error(BridgeInternal + .createCosmosClientException( + HttpConstants.StatusCodes.BADREQUEST, + "No offers found for the resource " + + this.getId())); + } + return this.database.getDocClientWrapper() + .readOffer(offerFeedResponse.getResults() + .get(0) + .getSelfLink()) + .single(); + }) + .map(ModelBridgeInternal::createThroughputRespose)); + } + + /** * Gets the parent Database * diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncDatabase.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncDatabase.java index f84535a1ee77..e0352ec3893d 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncDatabase.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosAsyncDatabase.java @@ -11,17 +11,24 @@ import com.azure.cosmos.models.CosmosAsyncUserResponse; import com.azure.cosmos.models.CosmosContainerProperties; import com.azure.cosmos.models.CosmosContainerRequestOptions; +import com.azure.cosmos.models.CosmosDatabaseProperties; import com.azure.cosmos.models.CosmosDatabaseRequestOptions; import com.azure.cosmos.models.CosmosUserProperties; import com.azure.cosmos.models.FeedOptions; import com.azure.cosmos.models.ModelBridgeInternal; +import com.azure.cosmos.models.SqlParameter; import com.azure.cosmos.models.SqlQuerySpec; import com.azure.cosmos.implementation.apachecommons.lang.StringUtils; +import com.azure.cosmos.models.ThroughputProperties; +import com.azure.cosmos.models.ThroughputResponse; import com.azure.cosmos.util.CosmosPagedFlux; import com.azure.cosmos.util.UtilBridgeInternal; import reactor.core.Exceptions; import reactor.core.publisher.Mono; +import java.util.Collections; +import java.util.List; + import static com.azure.cosmos.implementation.Utils.setContinuationTokenAndMaxItemCount; /** @@ -154,6 +161,22 @@ public Mono createContainer( return createContainer(containerProperties, options); } + /** + * Creates a container. + * + * @param containerProperties the container properties + * @param throughputProperties the throughput properties + * @param options the request options + * @return the mono + */ + public Mono createContainer( + CosmosContainerProperties containerProperties, + ThroughputProperties throughputProperties, + CosmosContainerRequestOptions options){ + ModelBridgeInternal.setOfferProperties(options, throughputProperties); + return createContainer(containerProperties, options); + } + /** * Creates a document container. * @@ -663,6 +686,79 @@ public Mono
replaceProvisionedThroughput(int requestUnitsPerSecond) { .getThroughput())); } + /** + * Sets throughput provisioned for a container in measurement of + * Requests-per-Unit in the Azure Cosmos service. + * + * @param throughputProperties the throughput properties + * @return the mono + */ + public Mono replaceThroughput(ThroughputProperties throughputProperties) { + return this.read() + .flatMap(response -> this.getDocClientWrapper() + .queryOffers(getOfferQuerySpecFromResourceId(response.getProperties() + .getResourceId()), + new FeedOptions()) + .single() + .flatMap(offerFeedResponse -> { + if (offerFeedResponse.getResults().isEmpty()) { + return Mono.error(BridgeInternal + .createCosmosClientException( + HttpConstants.StatusCodes.BADREQUEST, + "No offers found for the " + + "resource " + this.getId())); + } + + Offer existingOffer = offerFeedResponse.getResults().get(0); + Offer updatedOffer = + ModelBridgeInternal.updateOfferFromProperties(existingOffer, + throughputProperties); + + return this.getDocClientWrapper() + .replaceOffer(updatedOffer) + .single(); + }) + .map(ModelBridgeInternal::createThroughputRespose)); + } + + /** + * Gets the throughput of the database + * + * @return the mono containing throughput response + */ + public Mono readThroughput() { + return this.read() + .flatMap(response -> getDocClientWrapper() + .queryOffers(getOfferQuerySpecFromResourceId(response.getProperties() + .getResourceId()), + new FeedOptions()) + .single() + .flatMap(offerFeedResponse -> { + if (offerFeedResponse.getResults().isEmpty()) { + return Mono.error(BridgeInternal + .createCosmosClientException( + HttpConstants.StatusCodes.BADREQUEST, + "No offers found for the " + + "resource " + this.getId())); + } + return getDocClientWrapper() + .readOffer(offerFeedResponse.getResults() + .get(0) + .getSelfLink()) + .single(); + }) + .map(ModelBridgeInternal::createThroughputRespose)); + } + + SqlQuerySpec getOfferQuerySpecFromResourceId(String resourceId) { + String queryText = "select * from c where c.offerResourceId = @resourceId"; + SqlQuerySpec querySpec = new SqlQuerySpec(queryText); + List parameters = Collections + .singletonList(new SqlParameter("@resourceId", resourceId)); + querySpec.setParameters(parameters); + return querySpec; + } + CosmosAsyncClient getClient() { return client; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosBridgeInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosBridgeInternal.java index 937a452ddc83..932e3fc69e32 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosBridgeInternal.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosBridgeInternal.java @@ -4,8 +4,6 @@ package com.azure.cosmos; import com.azure.cosmos.implementation.AsyncDocumentClient; -import com.azure.cosmos.implementation.DocumentCollection; -import com.azure.cosmos.models.CosmosContainerProperties; /** * DO NOT USE. For internal use only by the SDK. These methods might break at any time. No support will be provided. @@ -66,7 +64,8 @@ public static CosmosClientBuilder cloneCosmosClientBuilder(CosmosClientBuilder b .keyCredential(builder.getKeyCredential()) .permissions(builder.getPermissions()) .authorizationTokenResolver(builder.getAuthorizationTokenResolver()) - .resourceToken(builder.getResourceToken()); + .resourceToken(builder.getResourceToken()) + .contentResponseOnWriteEnabled(builder.isContentResponseOnWriteEnabled()); return copy; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java index fa42fcdda5df..0435020dc3e8 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosClientBuilder.java @@ -39,6 +39,7 @@ public class CosmosClientBuilder { private CosmosKeyCredential cosmosKeyCredential; private boolean sessionCapturingOverrideEnabled; private boolean connectionReuseAcrossClientsEnabled; + private boolean contentResponseOnWriteEnabled; /** * Instantiates a new Cosmos client builder. @@ -291,6 +292,41 @@ public CosmosClientBuilder keyCredential(CosmosKeyCredential cosmosKeyCredential return this; } + /** + * Gets the boolean which indicates whether to only return the headers and status code in Cosmos DB response + * in case of Create, Update and Delete operations on CosmosItem. + * + * If set to false (which is by default), this removes the resource from response. It reduces networking + * and CPU load by not sending the resource back over the network and serializing it + * on the client. + * + * By-default, this is false. + * + * @return a boolean indicating whether resource will be included in the response or not + */ + boolean isContentResponseOnWriteEnabled() { + return contentResponseOnWriteEnabled; + } + + /** + * Sets the boolean to only return the headers and status code in Cosmos DB response + * in case of Create, Update and Delete operations on CosmosItem. + * + * If set to false (which is by default), this removes the resource from response. It reduces networking + * and CPU load by not sending the resource back over the network and serializing it on the client. + * + * This feature does not impact RU usage for read or write operations. + * + * By-default, this is false. + * + * @param contentResponseOnWriteEnabled a boolean indicating whether resource will be included in the response or not + * @return current cosmosClientBuilder + */ + public CosmosClientBuilder contentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled) { + this.contentResponseOnWriteEnabled = contentResponseOnWriteEnabled; + return this; + } + /** * Builds a cosmos configuration object with the provided properties * diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java index bb9c874f3d44..06002438b337 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosContainer.java @@ -13,6 +13,8 @@ import com.azure.cosmos.models.ModelBridgeInternal; import com.azure.cosmos.models.PartitionKey; import com.azure.cosmos.models.SqlQuerySpec; +import com.azure.cosmos.models.ThroughputProperties; +import com.azure.cosmos.models.ThroughputResponse; import com.azure.cosmos.util.CosmosPagedFlux; import com.azure.cosmos.util.CosmosPagedIterable; import com.azure.cosmos.util.UtilBridgeInternal; @@ -140,6 +142,24 @@ public Integer replaceProvisionedThroughput(int requestUnitsPerSecond) throws Co .replaceProvisionedThroughput(requestUnitsPerSecond)); } + /** + * Sets the throughput. + * + * @param throughputProperties the throughput properties + * @return the throughput response + */ + public ThroughputResponse replaceThroughput(ThroughputProperties throughputProperties) { + return database.throughputResponseToBlock(this.asyncContainer.replaceThroughput(throughputProperties)); + } + + /** + * Gets the throughput. + * + * @return the throughput response + */ + public ThroughputResponse readThroughput() { + return database.throughputResponseToBlock(this.asyncContainer.readThroughput()); + } /* CosmosAsyncItem operations */ diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosDatabase.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosDatabase.java index 9fee11c726be..cf9fd465ed70 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosDatabase.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/CosmosDatabase.java @@ -15,6 +15,8 @@ import com.azure.cosmos.models.FeedOptions; import com.azure.cosmos.models.ModelBridgeInternal; import com.azure.cosmos.models.SqlQuerySpec; +import com.azure.cosmos.models.ThroughputProperties; +import com.azure.cosmos.models.ThroughputResponse; import com.azure.cosmos.util.CosmosPagedFlux; import com.azure.cosmos.util.CosmosPagedIterable; import com.azure.cosmos.util.UtilBridgeInternal; @@ -155,6 +157,24 @@ public CosmosContainerResponse createContainer( options)); } + /** + * Creates a cosmos container. + * + * @param containerProperties the container properties + * @param throughputProperties the throughput properties + * @param options the options + * @return the cosmos container response + * @throws CosmosClientException the cosmos client exception + */ + public CosmosContainerResponse createContainer( + CosmosContainerProperties containerProperties, + ThroughputProperties throughputProperties, + CosmosContainerRequestOptions options) throws CosmosClientException { + return this.mapContainerResponseAndBlock(databaseWrapper.createContainer(containerProperties, + throughputProperties, + options)); + } + /** * Create container cosmos sync container response. * @@ -479,7 +499,26 @@ public Integer replaceProvisionedThroughput(int requestUnitsPerSecond) throws Co return throughputResponseToBlock(databaseWrapper.replaceProvisionedThroughput(requestUnitsPerSecond)); } - Integer throughputResponseToBlock(Mono throughputResponse) throws CosmosClientException { + /** + * Sets the throughput. + * + * @param throughputProperties the throughput properties + * @return the throughput response + */ + public ThroughputResponse replaceThroughput(ThroughputProperties throughputProperties) { + return throughputResponseToBlock(databaseWrapper.replaceThroughput(throughputProperties)); + } + + /** + * Gets the throughput of the database + * + * @return the throughput response + */ + public ThroughputResponse readThroughput() { + return throughputResponseToBlock(databaseWrapper.readThroughput()); + } + + T throughputResponseToBlock(Mono throughputResponse) throws CosmosClientException { try { return throughputResponse.block(); } catch (Exception ex) { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/AsyncDocumentClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/AsyncDocumentClient.java index 3bcec8266202..f0751fba79f1 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/AsyncDocumentClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/AsyncDocumentClient.java @@ -77,6 +77,7 @@ class Builder { CosmosKeyCredential cosmosKeyCredential; boolean sessionCapturingOverride; boolean transportClientSharing; + boolean contentResponseOnWriteEnabled; public Builder withServiceEndpoint(String serviceEndpoint) { try { @@ -158,6 +159,11 @@ public Builder withCosmosKeyCredential(CosmosKeyCredential cosmosKeyCredential) return this; } + public Builder withContentResponseOnWriteEnabled(boolean contentResponseOnWriteEnabled) { + this.contentResponseOnWriteEnabled = contentResponseOnWriteEnabled; + return this; + } + /** * This method will accept functional interface TokenResolver which helps in generation authorization * token per request. AsyncDocumentClient can be successfully initialized with this API without passing any MasterKey, ResourceToken or PermissionFeed. @@ -187,15 +193,16 @@ public AsyncDocumentClient build() { "cannot buildAsyncClient client without key credential"); RxDocumentClientImpl client = new RxDocumentClientImpl(serviceEndpoint, - masterKeyOrResourceToken, - permissionFeed, - connectionPolicy, - desiredConsistencyLevel, - configs, - cosmosAuthorizationTokenResolver, - cosmosKeyCredential, - sessionCapturingOverride, - transportClientSharing); + masterKeyOrResourceToken, + permissionFeed, + connectionPolicy, + desiredConsistencyLevel, + configs, + cosmosAuthorizationTokenResolver, + cosmosKeyCredential, + sessionCapturingOverride, + transportClientSharing, + contentResponseOnWriteEnabled); client.init(); return client; } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Constants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Constants.java index 5e1fac067138..fea6a976cb21 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Constants.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Constants.java @@ -50,6 +50,11 @@ public static final class Properties { public static final String DOCUMENTS_LINK = "_docs"; public static final String RESOURCE_LINK = "resource"; public static final String MEDIA_LINK = "media"; + public static final String AUTOPILOT_MAX_THROUGHPUT = "maxThroughput"; + public static final String AUTOPILOT_AUTO_UPGRADE_POLICY = "autoUpgradePolicy"; + public static final String AUTOPILOT_AUTO_THROUGHPUT_POLICY = "throughputPolicy"; + public static final String AUTOPILOT_THROUGHPUT_POLICY_INCREMENT_PERCENT = "incrementPercent"; + public static final String AUTOPILOT_SETTINGS = "offerAutopilotSettings"; public static final String PERMISSION_MODE = "permissionMode"; public static final String RESOURCE_KEY = "key"; diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/HttpConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/HttpConstants.java index 6b85e9cfc80d..b14fce7394f8 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/HttpConstants.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/HttpConstants.java @@ -171,6 +171,9 @@ public static class HttpHeaders { public static final String OFFER_TYPE = "x-ms-offer-type"; public static final String OFFER_THROUGHPUT = "x-ms-offer-throughput"; public static final String OFFER_IS_RU_PER_MINUTE_THROUGHPUT_ENABLED = "x-ms-offer-is-ru-per-minute-throughput-enabled"; + public static final String OFFER_MIN_THROUGHPUT = "x-ms-cosmos-min-throughput"; + public static final String OFFER_AUTOPILOT_SETTINGS = "x-ms-cosmos-offer-autopilot-settings"; + public static final String OFFER_REPLACE_PENDING = "x-ms-offer-replace-pending"; // Upsert header public static final String IS_UPSERT = "x-ms-documentdb-is-upsert"; @@ -306,6 +309,7 @@ public static class SubStatusCodes { } public static class HeaderValues { - public static final String NoCache = "no-cache"; + public static final String NO_CACHE = "no-cache"; + public static final String PREFER_RETURN_MINIMAL = "return=minimal"; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Offer.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Offer.java index 0364a22f11b6..c5c5db127928 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Offer.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/Offer.java @@ -4,6 +4,7 @@ package com.azure.cosmos.implementation; import com.azure.cosmos.BridgeInternal; +import com.azure.cosmos.models.ModelBridgeInternal; import com.azure.cosmos.models.Resource; import com.fasterxml.jackson.databind.node.ObjectNode; @@ -26,6 +27,18 @@ public Offer(int offerThroughput) { this.setContent(content); } + Offer(OfferAutoscaleSettings offerAutoscaleSettings) { + super(); + this.setOfferVersion(Constants.Properties.OFFER_VERSION_V2); + this.setOfferType(""); + ObjectNode content = Utils.getSimpleObjectMapper().createObjectNode(); +// content.put(Constants.Properties.OFFER_THROUGHPUT, null); + content.replace(Constants.Properties.AUTOPILOT_SETTINGS, ModelBridgeInternal + .getPropertyBagFromJsonSerializable(offerAutoscaleSettings)); + this.setContent(content); + } + + /** * Initialize an offer object from json string. * @@ -34,7 +47,80 @@ public Offer(int offerThroughput) { public Offer(String jsonString) { super(jsonString); } - + + /** + * Instantiates a new Offer from object node. + * + * @param objectNode the object node + */ + public Offer(ObjectNode objectNode) { + super(objectNode); + } + + /** + * Create fixed offer. + * + * @param throughput the throughput + * @return the offer + */ + public static Offer createManualOffer(int throughput) { + return new Offer(throughput); + } + + /** + * Create autoscale offer. + * + * @param startingMaxThroughput the starting max throughput + * @param autoUpgradeMaxThroughputIncrementPercentage the auto upgrade max throughput increment percentage + * @return the offer + */ + public static Offer createAutoscaleOffer( + int startingMaxThroughput, + int autoUpgradeMaxThroughputIncrementPercentage) { + return new Offer(new OfferAutoscaleSettings(startingMaxThroughput, + autoUpgradeMaxThroughputIncrementPercentage)); + } + + /** + * Gets offer auto scale settings. + * + * @return the offer auto scale settings + */ + public OfferAutoscaleSettings getOfferAutoScaleSettings() { + if (this.getContent().hasNonNull(Constants.Properties.AUTOPILOT_SETTINGS)) { + return new OfferAutoscaleSettings((ObjectNode) this.getContent() + .get(Constants.Properties.AUTOPILOT_SETTINGS)); + } else { + return null; + } + } + + /** + * Gets max autoscale throughput. + * + * @return the max autoscale throughput + */ + public int getAutoscaleMaxThroughput() { + OfferAutoscaleSettings offerAutoscaleSettings = this.getOfferAutoScaleSettings(); + if (offerAutoscaleSettings != null) { + return offerAutoscaleSettings.getMaxThroughput(); + } else { + return 0; + } + } + + /** + * Sets max autoscale throughput. + * + * @param autoscaleMaxThroughput the max autoscale throughput + */ + public void setAutoscaleMaxThroughput(int autoscaleMaxThroughput) { + OfferAutoscaleSettings offerAutoscaleSettings = this.getOfferAutoScaleSettings(); + if (offerAutoscaleSettings != null) { + offerAutoscaleSettings.setMaxThroughput(autoscaleMaxThroughput); + } + } + /** * Gets the self-link of a resource to which the resource offer applies. * @@ -116,6 +202,15 @@ public int getThroughput() { return this.getContent().get(Constants.Properties.OFFER_THROUGHPUT).asInt(); } + /** + * Has offer throughput. + * + * @return the if the offer has throughput + */ + public boolean hasOfferThroughput(){ + return this.getContent().hasNonNull(Constants.Properties.OFFER_THROUGHPUT); + } + /** * Sets the offer throughput for this offer. * @@ -142,4 +237,12 @@ public String getString(String propertyName) { public Integer getInt(String propertyName) { return super.getInt(propertyName); } + + public void updateAutoscaleThroughput(int maxAutoscaleThroughput) { + this.getOfferAutoScaleSettings().setMaxThroughput(maxAutoscaleThroughput); + } + + public void updateContent(Offer offer) { + this.setContent(offer.getContent()); + } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/OfferAutoscaleAutoUpgradeProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/OfferAutoscaleAutoUpgradeProperties.java new file mode 100644 index 000000000000..13f7671c5778 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/OfferAutoscaleAutoUpgradeProperties.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.cosmos.implementation; + +import com.azure.cosmos.models.JsonSerializable; +import com.azure.cosmos.models.ModelBridgeInternal; +import com.fasterxml.jackson.databind.node.ObjectNode; + +public class OfferAutoscaleAutoUpgradeProperties extends JsonSerializable { + + private AutoscaleThroughputProperties autoscaleThroughputProperties; + + OfferAutoscaleAutoUpgradeProperties(int maxThroughputIncrementPercentage) { + this.autoscaleThroughputProperties = new AutoscaleThroughputProperties(maxThroughputIncrementPercentage); + super.set(Constants.Properties.AUTOPILOT_AUTO_THROUGHPUT_POLICY, autoscaleThroughputProperties); + } + + OfferAutoscaleAutoUpgradeProperties(ObjectNode objectNode) { + super(objectNode); + } + + AutoscaleThroughputProperties getAutoscaleThroughputProperties() { + return autoscaleThroughputProperties; + } + + public static class AutoscaleThroughputProperties extends JsonSerializable { + + AutoscaleThroughputProperties(int maxThroughputIncrementPercentage) { + super.set(Constants.Properties.AUTOPILOT_THROUGHPUT_POLICY_INCREMENT_PERCENT, + maxThroughputIncrementPercentage); + } + + /** + * Getter for property 'incrementPercent'. + * + * @return Value for property 'incrementPercent'. + */ + int getIncrementPercent() { + return this.getInt(Constants.Properties.AUTOPILOT_THROUGHPUT_POLICY_INCREMENT_PERCENT); + } + } +} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/OfferAutoscaleSettings.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/OfferAutoscaleSettings.java new file mode 100644 index 000000000000..d53a6f2688b6 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/OfferAutoscaleSettings.java @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.cosmos.implementation; + +import com.azure.cosmos.models.JsonSerializable; +import com.azure.cosmos.models.ModelBridgeInternal; +import com.fasterxml.jackson.databind.node.ObjectNode; + + +public class OfferAutoscaleSettings extends JsonSerializable { + OfferAutoscaleAutoUpgradeProperties offerAutoscaleAutoUpgradeProperties; + + OfferAutoscaleSettings(final int maxThroughput, int maxThroughputIncrementPercentage) { + super(); + offerAutoscaleAutoUpgradeProperties = new OfferAutoscaleAutoUpgradeProperties(maxThroughputIncrementPercentage); + super.set(Constants.Properties.AUTOPILOT_MAX_THROUGHPUT, maxThroughput); + super.set(Constants.Properties.AUTOPILOT_AUTO_UPGRADE_POLICY, offerAutoscaleAutoUpgradeProperties); + } + + OfferAutoscaleSettings(String json) { + super(json); + } + + OfferAutoscaleSettings(ObjectNode objectNode) { + super(objectNode); + } + + /** + * Getter for property 'maxThroughput'. + * + * @return Value for property 'maxThroughput'. + */ + int getMaxThroughput() { + return this.getInt(Constants.Properties.AUTOPILOT_MAX_THROUGHPUT); + } + + void setMaxThroughput(int maxAutoscaleThroughput) { + super.set(Constants.Properties.AUTOPILOT_MAX_THROUGHPUT, maxAutoscaleThroughput); + } + + /** + * Getter for property 'autoscaleAutoUpgradeProperties'. + * + * @return Value for property 'autoscaleAutoUpgradeProperties'. + */ + OfferAutoscaleAutoUpgradeProperties getAutoscaleAutoUpgradeProperties() { + if (offerAutoscaleAutoUpgradeProperties == null) { + if (this.has(Constants.Properties.AUTOPILOT_AUTO_UPGRADE_POLICY)) + offerAutoscaleAutoUpgradeProperties = + new OfferAutoscaleAutoUpgradeProperties((ObjectNode) this.get(Constants.Properties + .AUTOPILOT_AUTO_UPGRADE_POLICY)); + } + return offerAutoscaleAutoUpgradeProperties; + } +} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java index 62b7a14154cc..31cc4e95ec4e 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RequestOptions.java @@ -7,6 +7,7 @@ import com.azure.cosmos.ConsistencyLevel; import com.azure.cosmos.models.IndexingDirective; import com.azure.cosmos.models.PartitionKey; +import com.azure.cosmos.models.ThroughputProperties; import java.util.HashMap; import java.util.List; @@ -31,6 +32,7 @@ public class RequestOptions { private boolean scriptLoggingEnabled; private boolean populateQuotaInfo; private Map properties; + private ThroughputProperties throughputProperties; /** * Gets the triggers to be invoked before the operation. @@ -194,6 +196,14 @@ public void setOfferThroughput(Integer offerThroughput) { this.offerThroughput = offerThroughput; } + public void setThroughputProperties(ThroughputProperties throughputProperties) { + this.throughputProperties = throughputProperties; + } + + public ThroughputProperties getThroughputProperties() { + return this.throughputProperties; + } + /** * Gets the partition key used to identify the current request's target partition. * diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ResourceResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ResourceResponse.java index ba1453d4017c..a20fa6aeae7b 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ResourceResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/ResourceResponse.java @@ -358,6 +358,17 @@ public String getCosmosResponseDiagnosticString() { return cosmosResponseRequestDiagnosticStatistics.toString(); } + /** + * Gets the ETag from the response headers. + * + * Null in case of delete operation. + * + * @return ETag + */ + public String getETag() { + return this.response.getResponseHeaders().get(HttpConstants.HttpHeaders.E_TAG); + } + long getCurrentQuotaHeader(String headerName) { if (this.usageHeaders.size() == 0 && !StringUtils.isEmpty(this.getMaxResourceQuota()) && diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java index 9f3f52ffffbe..a0e597a815af 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentClientImpl.java @@ -77,6 +77,8 @@ * This is meant to be internally used only by our sdk. */ public class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorizationTokenProvider { + + private static final char PREFER_HEADER_SEPERATOR = ';'; private final static ObjectMapper mapper = Utils.getSimpleObjectMapper(); private final Logger logger = LoggerFactory.getLogger(RxDocumentClientImpl.class); private final String masterKeyOrResourceToken; @@ -98,6 +100,7 @@ public class RxDocumentClientImpl implements AsyncDocumentClient, IAuthorization private GlobalAddressResolver addressResolver; private RxPartitionKeyRangeCache partitionKeyRangeCache; private Map > resourceTokensMap; + private final boolean contentResponseOnWriteEnabled; // RetryPolicy retries a request when it encounters session unavailable (see ClientRetryPolicy). // Once it exhausts all write regions it clears the session container, then it uses RxClientCollectionCache @@ -131,8 +134,10 @@ public RxDocumentClientImpl(URI serviceEndpoint, CosmosAuthorizationTokenResolver cosmosAuthorizationTokenResolver, CosmosKeyCredential cosmosKeyCredential, boolean sessionCapturingOverride, - boolean connectionSharingAcrossClientsEnabled) { - this(serviceEndpoint, masterKeyOrResourceToken, permissionFeed, connectionPolicy, consistencyLevel, configs, cosmosKeyCredential, sessionCapturingOverride, connectionSharingAcrossClientsEnabled); + boolean connectionSharingAcrossClientsEnabled, + boolean contentResponseOnWriteEnabled) { + this(serviceEndpoint, masterKeyOrResourceToken, permissionFeed, connectionPolicy, consistencyLevel, configs, + cosmosKeyCredential, sessionCapturingOverride, connectionSharingAcrossClientsEnabled, contentResponseOnWriteEnabled); this.cosmosAuthorizationTokenResolver = cosmosAuthorizationTokenResolver; } @@ -144,8 +149,10 @@ private RxDocumentClientImpl(URI serviceEndpoint, Configs configs, CosmosKeyCredential cosmosKeyCredential, boolean sessionCapturingOverrideEnabled, - boolean connectionSharingAcrossClientsEnabled) { - this(serviceEndpoint, masterKeyOrResourceToken, connectionPolicy, consistencyLevel, configs, cosmosKeyCredential, sessionCapturingOverrideEnabled, connectionSharingAcrossClientsEnabled); + boolean connectionSharingAcrossClientsEnabled, + boolean contentResponseOnWriteEnabled) { + this(serviceEndpoint, masterKeyOrResourceToken, connectionPolicy, consistencyLevel, configs, + cosmosKeyCredential, sessionCapturingOverrideEnabled, connectionSharingAcrossClientsEnabled, contentResponseOnWriteEnabled); if (permissionFeed != null && permissionFeed.size() > 0) { this.resourceTokensMap = new HashMap<>(); for (Permission permission : permissionFeed) { @@ -195,7 +202,8 @@ private RxDocumentClientImpl(URI serviceEndpoint, Configs configs, CosmosKeyCredential cosmosKeyCredential, boolean sessionCapturingOverrideEnabled, - boolean connectionSharingAcrossClientsEnabled) { + boolean connectionSharingAcrossClientsEnabled, + boolean contentResponseOnWriteEnabled) { logger.info( "Initializing DocumentClient with" @@ -207,6 +215,7 @@ private RxDocumentClientImpl(URI serviceEndpoint, this.masterKeyOrResourceToken = masterKeyOrResourceToken; this.serviceEndpoint = serviceEndpoint; this.cosmosKeyCredential = cosmosKeyCredential; + this.contentResponseOnWriteEnabled = contentResponseOnWriteEnabled; if (this.cosmosKeyCredential != null) { hasAuthKeyResourceToken = false; @@ -416,7 +425,7 @@ private Mono > createDatabaseInternal(Database databas logger.debug("Creating a Database. id: [{}]", database.getId()); validateResource(database); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.Database, OperationType.Create); ZonedDateTime serializationStartTimeUTC = ZonedDateTime.now(ZoneOffset.UTC); ByteBuffer byteBuffer = ModelBridgeInternal.serializeJsonToByteBuffer(database); ZonedDateTime serializationEndTimeUTC = ZonedDateTime.now(ZoneOffset.UTC); @@ -458,7 +467,7 @@ private Mono > deleteDatabaseInternal(String databaseL logger.debug("Deleting a Database. databaseLink: [{}]", databaseLink); String path = Utils.joinPath(databaseLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.Database, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.Database, path, requestHeaders, options); @@ -487,7 +496,7 @@ private Mono > readDatabaseInternal(String databaseLin logger.debug("Reading a Database. databaseLink: [{}]", databaseLink); String path = Utils.joinPath(databaseLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.Database, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.Database, path, requestHeaders, options); @@ -593,7 +602,7 @@ private Mono > createCollectionInternal(Stri validateResource(collection); String path = Utils.joinPath(databaseLink, Paths.COLLECTIONS_PATH_SEGMENT); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.DocumentCollection, OperationType.Create); ZonedDateTime serializationStartTimeUTC = ZonedDateTime.now(ZoneOffset.UTC); ByteBuffer byteBuffer = ModelBridgeInternal.serializeJsonToByteBuffer(collection); @@ -645,7 +654,7 @@ private Mono > replaceCollectionInternal(Doc validateResource(collection); String path = Utils.joinPath(collection.getSelfLink(), null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.DocumentCollection, OperationType.Replace); ZonedDateTime serializationStartTimeUTC = ZonedDateTime.now(ZoneOffset.UTC); ByteBuffer byteBuffer = ModelBridgeInternal.serializeJsonToByteBuffer(collection); ZonedDateTime serializationEndTimeUTC = ZonedDateTime.now(ZoneOffset.UTC); @@ -699,7 +708,7 @@ private Mono > deleteCollectionInternal(Stri logger.debug("Deleting a Collection. collectionLink: [{}]", collectionLink); String path = Utils.joinPath(collectionLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.DocumentCollection, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.DocumentCollection, path, requestHeaders, options); @@ -771,7 +780,7 @@ private Mono > readCollectionInternal(String logger.debug("Reading a Collection. collectionLink: [{}]", collectionLink); String path = Utils.joinPath(collectionLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.DocumentCollection, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.DocumentCollection, path, requestHeaders, options); @@ -843,7 +852,7 @@ private static void validateResource(Resource resource) { } } - private Map getRequestHeaders(RequestOptions options) { + private Map getRequestHeaders(RequestOptions options, ResourceType resourceType, OperationType operationType) { Map headers = new HashMap<>(); if (this.useMultipleWriteLocations) { @@ -854,6 +863,11 @@ private Map getRequestHeaders(RequestOptions options) { headers.put(HttpConstants.HttpHeaders.CONSISTENCY_LEVEL, consistencyLevel.toString()); } + // If content response on write is not enabled, and operation is document write - then add minimal prefer header + if (resourceType.equals(ResourceType.Document) && operationType.isWriteOperation() && !this.contentResponseOnWriteEnabled) { + headers.put(HttpConstants.HttpHeaders.PREFER, HttpConstants.HeaderValues.PREFER_RETURN_MINIMAL); + } + if (options == null) { return headers; } @@ -904,6 +918,34 @@ private Map getRequestHeaders(RequestOptions options) { headers.put(HttpConstants.HttpHeaders.OFFER_TYPE, options.getOfferType()); } + if (options.getOfferThroughput() == null) { + if (options.getThroughputProperties() != null) { + Offer offer = ModelBridgeInternal.getOfferFromThroughputProperties(options.getThroughputProperties()); + final OfferAutoscaleSettings offerAutoscaleSettings = offer.getOfferAutoScaleSettings(); + OfferAutoscaleAutoUpgradeProperties autoscaleAutoUpgradeProperties = null; + if (offerAutoscaleSettings != null) { + autoscaleAutoUpgradeProperties + = offer.getOfferAutoScaleSettings().getAutoscaleAutoUpgradeProperties(); + } + if (offer.hasOfferThroughput() && + (offerAutoscaleSettings != null && offerAutoscaleSettings.getMaxThroughput() >= 0 || + autoscaleAutoUpgradeProperties != null && + autoscaleAutoUpgradeProperties + .getAutoscaleThroughputProperties() + .getIncrementPercent() >= 0)) { + throw new IllegalArgumentException("Autoscale provisioned throughput can not be configured with " + + "fixed offer"); + } + + if (offer.hasOfferThroughput()) { + headers.put(HttpConstants.HttpHeaders.OFFER_THROUGHPUT, String.valueOf(offer.getThroughput())); + } else if (offer.getOfferAutoScaleSettings() != null) { + headers.put(HttpConstants.HttpHeaders.OFFER_AUTOPILOT_SETTINGS, + ModelBridgeInternal.toJsonFromJsonSerializable(offer.getOfferAutoScaleSettings())); + } + } + } + if (options.isPopulateQuotaInfo()) { headers.put(HttpConstants.HttpHeaders.POPULATE_QUOTA_INFO, String.valueOf(true)); } @@ -1031,7 +1073,7 @@ private Mono getCreateDocumentRequest(DocumentClientRe SerializationDiagnosticsContext.SerializationType.ITEM_SERIALIZATION); String path = Utils.joinPath(documentCollectionLink, Paths.DOCUMENTS_PATH_SEGMENT); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.Document, operationType); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.Document, path, requestHeaders, options, content); @@ -1292,7 +1334,7 @@ private Mono > replaceDocumentInternal(String document logger.debug("Replacing a Document. documentLink: [{}]", documentLink); final String path = Utils.joinPath(documentLink, null); - final Map requestHeaders = getRequestHeaders(options); + final Map requestHeaders = getRequestHeaders(options, ResourceType.Document, OperationType.Replace); ZonedDateTime serializationStartTimeUTC = ZonedDateTime.now(ZoneOffset.UTC); ByteBuffer content = serializeJsonToByteBuffer(document); ZonedDateTime serializationEndTime = ZonedDateTime.now(ZoneOffset.UTC); @@ -1335,7 +1377,7 @@ private Mono > deleteDocumentInternal(String documentL logger.debug("Deleting a Document. documentLink: [{}]", documentLink); String path = Utils.joinPath(documentLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.Document, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.Document, path, requestHeaders, options); if (retryPolicyInstance != null) { @@ -1371,7 +1413,7 @@ private Mono > readDocumentInternal(String documentLin logger.debug("Reading a Document. documentLink: [{}]", documentLink); String path = Utils.joinPath(documentLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.Document, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.Document, path, requestHeaders, options); if (retryPolicyInstance != null) { @@ -1736,7 +1778,7 @@ private RxDocumentServiceRequest getStoredProcedureRequest(String collectionLink validateResource(storedProcedure); String path = Utils.joinPath(collectionLink, Paths.STORED_PROCEDURES_PATH_SEGMENT); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.StoredProcedure, operationType); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.StoredProcedure, path, storedProcedure, requestHeaders, options); @@ -1755,7 +1797,7 @@ private RxDocumentServiceRequest getUserDefinedFunctionRequest(String collection validateResource(udf); String path = Utils.joinPath(collectionLink, Paths.USER_DEFINED_FUNCTIONS_PATH_SEGMENT); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.UserDefinedFunction, operationType); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.UserDefinedFunction, path, udf, requestHeaders, options); @@ -1845,7 +1887,7 @@ private Mono > replaceStoredProcedureInternal(S RxDocumentClientImpl.validateResource(storedProcedure); String path = Utils.joinPath(storedProcedure.getSelfLink(), null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.StoredProcedure, OperationType.Replace); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.StoredProcedure, path, storedProcedure, requestHeaders, options); @@ -1882,7 +1924,7 @@ private Mono > deleteStoredProcedureInternal(St logger.debug("Deleting a StoredProcedure. storedProcedureLink [{}]", storedProcedureLink); String path = Utils.joinPath(storedProcedureLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.StoredProcedure, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.StoredProcedure, path, requestHeaders, options); @@ -1921,7 +1963,7 @@ private Mono > readStoredProcedureInternal(Stri logger.debug("Reading a StoredProcedure. storedProcedureLink [{}]", storedProcedureLink); String path = Utils.joinPath(storedProcedureLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.StoredProcedure, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.StoredProcedure, path, requestHeaders, options); @@ -1982,7 +2024,7 @@ private Mono executeStoredProcedureInternal(String stor logger.debug("Executing a StoredProcedure. storedProcedureLink [{}]", storedProcedureLink); String path = Utils.joinPath(storedProcedureLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.StoredProcedure, OperationType.ExecuteJavaScript); requestHeaders.put(HttpConstants.HttpHeaders.ACCEPT, RuntimeConstants.MediaTypes.JSON); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.ExecuteJavaScript, @@ -2069,7 +2111,7 @@ private RxDocumentServiceRequest getTriggerRequest(String collectionLink, Trigge RxDocumentClientImpl.validateResource(trigger); String path = Utils.joinPath(collectionLink, Paths.TRIGGERS_PATH_SEGMENT); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Trigger, operationType); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.Trigger, path, trigger, requestHeaders, options); @@ -2094,7 +2136,7 @@ private Mono > replaceTriggerInternal(Trigger trigger, RxDocumentClientImpl.validateResource(trigger); String path = Utils.joinPath(trigger.getSelfLink(), null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Trigger, OperationType.Replace); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.Trigger, path, trigger, requestHeaders, options); @@ -2124,7 +2166,7 @@ private Mono > deleteTriggerInternal(String triggerLink logger.debug("Deleting a Trigger. triggerLink [{}]", triggerLink); String path = Utils.joinPath(triggerLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Trigger, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.Trigger, path, requestHeaders, options); @@ -2155,7 +2197,7 @@ private Mono > readTriggerInternal(String triggerLink, logger.debug("Reading a Trigger. triggerLink [{}]", triggerLink); String path = Utils.joinPath(triggerLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Trigger, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.Trigger, path, requestHeaders, options); @@ -2278,7 +2320,7 @@ private Mono > replaceUserDefinedFunctionIn validateResource(udf); String path = Utils.joinPath(udf.getSelfLink(), null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.UserDefinedFunction, OperationType.Replace); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.UserDefinedFunction, path, udf, requestHeaders, options); @@ -2315,7 +2357,7 @@ private Mono > deleteUserDefinedFunctionInt logger.debug("Deleting a UserDefinedFunction. udfLink [{}]", udfLink); String path = Utils.joinPath(udfLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.UserDefinedFunction, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.UserDefinedFunction, path, requestHeaders, options); @@ -2352,7 +2394,7 @@ private Mono > readUserDefinedFunctionInter logger.debug("Reading a UserDefinedFunction. udfLink [{}]", udfLink); String path = Utils.joinPath(udfLink, null); - Map requestHeaders = this.getRequestHeaders(options); + Map requestHeaders = this.getRequestHeaders(options, ResourceType.UserDefinedFunction, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.UserDefinedFunction, path, requestHeaders, options); @@ -2408,7 +2450,7 @@ private Mono > readConflictInternal(String conflictLin logger.debug("Reading a Conflict. conflictLink [{}]", conflictLink); String path = Utils.joinPath(conflictLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Conflict, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.Conflict, path, requestHeaders, options); @@ -2466,7 +2508,7 @@ private Mono > deleteConflictInternal(String conflictL logger.debug("Deleting a Conflict. conflictLink [{}]", conflictLink); String path = Utils.joinPath(conflictLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Conflict, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.Conflict, path, requestHeaders, options); @@ -2538,7 +2580,7 @@ private RxDocumentServiceRequest getUserRequest(String databaseLink, User user, RxDocumentClientImpl.validateResource(user); String path = Utils.joinPath(databaseLink, Paths.USERS_PATH_SEGMENT); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.User, operationType); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.User, path, user, requestHeaders, options); @@ -2560,7 +2602,7 @@ private Mono > replaceUserInternal(User user, RequestOptio RxDocumentClientImpl.validateResource(user); String path = Utils.joinPath(user.getSelfLink(), null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.User, OperationType.Replace); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.User, path, user, requestHeaders, options); if (retryPolicyInstance != null) { @@ -2590,7 +2632,7 @@ private Mono > deleteUserInternal(String userLink, Request } logger.debug("Deleting a User. userLink [{}]", userLink); String path = Utils.joinPath(userLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.User, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.User, path, requestHeaders, options); @@ -2618,7 +2660,7 @@ private Mono > readUserInternal(String userLink, RequestOp } logger.debug("Reading a User. userLink [{}]", userLink); String path = Utils.joinPath(userLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.User, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.User, path, requestHeaders, options); @@ -2715,7 +2757,7 @@ private RxDocumentServiceRequest getPermissionRequest(String userLink, Permissio RxDocumentClientImpl.validateResource(permission); String path = Utils.joinPath(userLink, Paths.PERMISSIONS_PATH_SEGMENT); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Permission, operationType); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(operationType, ResourceType.Permission, path, permission, requestHeaders, options); @@ -2737,7 +2779,7 @@ private Mono > replacePermissionInternal(Permission RxDocumentClientImpl.validateResource(permission); String path = Utils.joinPath(permission.getSelfLink(), null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Permission, OperationType.Replace); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Replace, ResourceType.Permission, path, permission, requestHeaders, options); @@ -2768,7 +2810,7 @@ private Mono > deletePermissionInternal(String permi } logger.debug("Deleting a Permission. permissionLink [{}]", permissionLink); String path = Utils.joinPath(permissionLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Permission, OperationType.Delete); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Delete, ResourceType.Permission, path, requestHeaders, options); @@ -2797,7 +2839,7 @@ private Mono > readPermissionInternal(String permiss } logger.debug("Reading a Permission. permissionLink [{}]", permissionLink); String path = Utils.joinPath(permissionLink, null); - Map requestHeaders = getRequestHeaders(options); + Map requestHeaders = getRequestHeaders(options, ResourceType.Permission, OperationType.Read); RxDocumentServiceRequest request = RxDocumentServiceRequest.create(OperationType.Read, ResourceType.Permission, path, requestHeaders, options); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentServiceRequest.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentServiceRequest.java index f5287a9b82a3..24ae1acca4b1 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentServiceRequest.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/RxDocumentServiceRequest.java @@ -26,8 +26,6 @@ * This is core Transport/Connection agnostic request to the Azure Cosmos DB database service. */ public class RxDocumentServiceRequest implements Cloneable { - private static final char PREFER_HEADER_SEPERATOR = ';'; - private static final String PREFER_HEADER_VALUE_FORMAT = "%s=%s"; public volatile boolean forcePartitionKeyRangeRefresh; public volatile boolean forceCollectionRoutingMapRefresh; @@ -969,17 +967,6 @@ public boolean isValidAddress(ResourceType resourceType) { } } - public void addPreferHeader(String preferHeaderName, String preferHeaderValue) { - String headerToAdd = String.format(PREFER_HEADER_VALUE_FORMAT, preferHeaderName, preferHeaderValue); - String preferHeader = this.headers.get(HttpConstants.HttpHeaders.PREFER); - if(StringUtils.isNotEmpty(preferHeader)) { - preferHeader += PREFER_HEADER_SEPERATOR + headerToAdd; - } else { - preferHeader = headerToAdd; - } - this.headers.put(HttpConstants.HttpHeaders.PREFER, preferHeader); - } - public static RxDocumentServiceRequest createFromResource(RxDocumentServiceRequest request, Resource modifiedResource) { RxDocumentServiceRequest modifiedRequest; if (!request.getIsNameBased()) { diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java index 04bb13d98a68..9ec2da929bd3 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/HttpTransportClient.java @@ -84,7 +84,7 @@ public HttpTransportClient(Configs configs, Duration requestTimeout, UserAgentCo // Set requested API version header for version enforcement. this.defaultHeaders.put(HttpConstants.HttpHeaders.VERSION, HttpConstants.Versions.CURRENT_VERSION); - this.defaultHeaders.put(HttpConstants.HttpHeaders.CACHE_CONTROL, HttpConstants.HeaderValues.NoCache); + this.defaultHeaders.put(HttpConstants.HttpHeaders.CACHE_CONTROL, HttpConstants.HeaderValues.NO_CACHE); if (userAgent == null) { userAgent = new UserAgentContainer(); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdConstants.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdConstants.java index 86849db8c6da..951747ddd83a 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdConstants.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdConstants.java @@ -572,7 +572,8 @@ public enum RntbdRequestHeader implements RntbdHeader { ContentSerializationFormat((short) 0x0065, RntbdTokenType.Byte, false), AllowTentativeWrites((short) 0x0066, RntbdTokenType.Byte, false), IsUserRequest((short) 0x0067, RntbdTokenType.Byte, false), - SharedOfferThroughput((short) 0x0068, RntbdTokenType.ULong, false); + SharedOfferThroughput((short) 0x0068, RntbdTokenType.ULong, false), + ReturnPreference((short) 0x0082, RntbdTokenType.Byte, false); public static final ImmutableMap map; public static final ImmutableSet set = Sets.immutableEnumSet(EnumSet.allOf(RntbdRequestHeader.class)); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdRequestHeaders.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdRequestHeaders.java index ccf5a8b6b64f..ccadaf602b04 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdRequestHeaders.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/implementation/directconnectivity/rntbd/RntbdRequestHeaders.java @@ -17,7 +17,6 @@ import com.azure.cosmos.implementation.RemoteStorageType; import com.azure.cosmos.implementation.ResourceId; import com.azure.cosmos.implementation.RxDocumentServiceRequest; -import com.azure.cosmos.models.IndexingDirective; import com.fasterxml.jackson.annotation.JsonFilter; import io.netty.buffer.ByteBuf; import io.netty.buffer.Unpooled; @@ -29,6 +28,7 @@ import java.util.function.Supplier; import static com.azure.cosmos.implementation.HttpConstants.HttpHeaders; +import static com.azure.cosmos.implementation.HttpConstants.HeaderValues; import static com.azure.cosmos.implementation.directconnectivity.WFConstants.BackendHeaders; import static com.azure.cosmos.implementation.directconnectivity.rntbd.RntbdConstants.RntbdConsistencyLevel; import static com.azure.cosmos.implementation.directconnectivity.rntbd.RntbdConstants.RntbdContentSerializationFormat; @@ -112,6 +112,7 @@ final class RntbdRequestHeaders extends RntbdTokenStream { this.addStartAndEndKeys(headers); this.addSupportSpatialLegacyCoordinates(headers); this.addUsePolygonsSmallerThanAHemisphere(headers); + this.addReturnPreference(headers); // Normal headers (Strings, Ints, Longs, etc.) @@ -279,6 +280,10 @@ private RntbdToken getEffectivePartitionKey() { return this.get(RntbdRequestHeader.EffectivePartitionKey); } + private RntbdToken getReturnPreference() { + return this.get(RntbdRequestHeader.ReturnPreference); + } + private RntbdToken getEmitVerboseTracesInQuery() { return this.get(RntbdRequestHeader.EmitVerboseTracesInQuery); } @@ -1159,6 +1164,13 @@ private void addUsePolygonsSmallerThanAHemisphere(final Map head } } + private void addReturnPreference(final Map headers) { + final String value = headers.get(HttpHeaders.PREFER); + if (StringUtils.isNotEmpty(value) && value.contains(HeaderValues.PREFER_RETURN_MINIMAL)) { + this.getReturnPreference().setValue(true); + } + } + private void fillTokenFromHeader(final Map headers, final Supplier supplier, final String name) { final String value = headers.get(name); diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncItemResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncItemResponse.java index 56529eaf98ee..a919a6a83554 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncItemResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosAsyncItemResponse.java @@ -179,4 +179,15 @@ public CosmosResponseDiagnostics getResponseDiagnostics() { public Duration getRequestLatency() { return resourceResponse.getRequestLatency(); } + + /** + * Gets the ETag from the response headers. + * + * Null in case of delete operation. + * + * @return ETag + */ + public String getETag() { + return resourceResponse.getETag(); + } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerProperties.java index 723e9de73ced..8b7cdd720988 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerProperties.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerProperties.java @@ -244,17 +244,17 @@ public CosmosContainerProperties setDefaultTimeToLiveInSeconds(Integer timeToLiv } /** - * Sets the analytical storage time to live in seconds for items in a container from the Azure Cosmos DB service. + * Sets the analytical store time to live in seconds for items in a container from the Azure Cosmos DB service. * * It is an optional property. A valid value must be either a nonzero positive integer, '-1', or 0. - * By default, AnalyticalStorageTimeToLive is set to 0 meaning the analytical store is turned off for the container; + * By default, AnalyticalStoreTimeToLive is set to 0 meaning the analytical store is turned off for the container; * -1 means documents in analytical store never expire. * The unit of measurement is seconds. The maximum allowed value is 2147483647. * - * @param timeToLive the analytical storage time to live in seconds. + * @param timeToLive the analytical store time to live in seconds. * @return the CosmosContainerProperties. */ - public CosmosContainerProperties setAnalyticalStorageTimeToLiveInSeconds(Integer timeToLive) { + public CosmosContainerProperties setAnalyticalStoreTimeToLiveInSeconds(Integer timeToLive) { // a "null" value is represented as a missing element on the wire. // setting timeToLive to null should remove the property from the property bag. if (timeToLive != null) { @@ -267,16 +267,16 @@ public CosmosContainerProperties setAnalyticalStorageTimeToLiveInSeconds(Integer } /** - * Gets the analytical storage time to live in seconds for items in a container from the Azure Cosmos DB service. + * Gets the analytical store time to live in seconds for items in a container from the Azure Cosmos DB service. * * It is an optional property. A valid value must be either a nonzero positive integer, '-1', or 0. - * By default, AnalyticalStorageTimeToLive is set to 0 meaning the analytical store is turned off for the container; + * By default, AnalyticalStoreTimeToLive is set to 0 meaning the analytical store is turned off for the container; * -1 means documents in analytical store never expire. * The unit of measurement is seconds. The maximum allowed value is 2147483647. * * @return analytical ttl */ - public Integer getAnalyticalStorageTimeToLiveInSeconds() { + public Integer getAnalyticalStoreTimeToLiveInSeconds() { if (super.has(Constants.Properties.ANALYTICAL_STORAGE_TTL)) { return super.getInt(Constants.Properties.ANALYTICAL_STORAGE_TTL); } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java index 80e2fcc74c62..331184db2f1e 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosContainerRequestOptions.java @@ -14,6 +14,7 @@ public final class CosmosContainerRequestOptions { private ConsistencyLevel consistencyLevel; private String sessionToken; private AccessCondition accessCondition; + private ThroughputProperties throughputProperties; /** * Gets the throughput in the form of Request Units per second when creating a cosmos container. @@ -119,6 +120,11 @@ public CosmosContainerRequestOptions setAccessCondition(AccessCondition accessCo return this; } + CosmosContainerRequestOptions setThroughputProperties(ThroughputProperties throughputProperties) { + this.throughputProperties = throughputProperties; + return this; + } + RequestOptions toRequestOptions() { RequestOptions options = new RequestOptions(); options.setAccessCondition(accessCondition); @@ -126,6 +132,7 @@ RequestOptions toRequestOptions() { options.setPopulateQuotaInfo(populateQuotaInfo); options.setSessionToken(sessionToken); options.setConsistencyLevel(consistencyLevel); + options.setThroughputProperties(this.throughputProperties); return options; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java index 3fe4b1d5d976..f810e57cfd21 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosDatabaseRequestOptions.java @@ -2,6 +2,7 @@ // Licensed under the MIT License. package com.azure.cosmos.models; +import com.azure.cosmos.implementation.Offer; import com.azure.cosmos.implementation.RequestOptions; /** @@ -10,6 +11,7 @@ public final class CosmosDatabaseRequestOptions { private Integer offerThroughput; private AccessCondition accessCondition; + private ThroughputProperties throughputProperties; /** * Gets the conditions associated with the request. @@ -51,10 +53,16 @@ CosmosDatabaseRequestOptions setOfferThroughput(Integer offerThroughput) { return this; } + CosmosDatabaseRequestOptions setThroughputProperties(ThroughputProperties throughputProperties) { + this.throughputProperties = throughputProperties; + return this; + } + RequestOptions toRequestOptions() { RequestOptions options = new RequestOptions(); options.setAccessCondition(accessCondition); options.setOfferThroughput(offerThroughput); + options.setThroughputProperties(this.throughputProperties); return options; } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemResponse.java index b1bde4ac913a..13063cdb23b7 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosItemResponse.java @@ -121,4 +121,14 @@ public Duration getRequestLatency() { return responseWrapper.getRequestLatency(); } + /** + * Gets the ETag from the response headers. + * + * Null in case of delete operation. + * + * @return ETag + */ + public String getETag() { + return responseWrapper.getETag(); + } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosResponse.java index d81f04396180..cded9a4d3b3a 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosResponse.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/CosmosResponse.java @@ -13,7 +13,7 @@ * The cosmos response * @param the type of resource */ -public class CosmosResponse { +public class CosmosResponse { private T properties; protected final ResourceResponse> resourceResponseWrapper; diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ModelBridgeInternal.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ModelBridgeInternal.java index 4f2280c979cd..c978c8fbac9a 100644 --- a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ModelBridgeInternal.java +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ModelBridgeInternal.java @@ -20,6 +20,7 @@ import com.azure.cosmos.implementation.Document; import com.azure.cosmos.implementation.DocumentCollection; import com.azure.cosmos.implementation.HttpConstants; +import com.azure.cosmos.implementation.Offer; import com.azure.cosmos.implementation.PartitionKeyRange; import com.azure.cosmos.implementation.Permission; import com.azure.cosmos.implementation.QueryMetrics; @@ -226,6 +227,22 @@ public static CosmosDatabaseRequestOptions setOfferThroughput(CosmosDatabaseRequ return cosmosDatabaseRequestOptions.setOfferThroughput(offerThroughput); } + public static CosmosDatabaseRequestOptions setOfferProperties( + CosmosDatabaseRequestOptions cosmosDatabaseRequestOptions, + ThroughputProperties throughputProperties) { + return cosmosDatabaseRequestOptions.setThroughputProperties(throughputProperties); + } + + public static CosmosContainerRequestOptions setOfferProperties( + CosmosContainerRequestOptions containerRequestOptions, + ThroughputProperties throughputProperties) { + return containerRequestOptions.setThroughputProperties(throughputProperties); + } + + public static Offer updateOfferFromProperties(Offer offer, ThroughputProperties properties) { + return properties.updateOfferFromProperties(offer); + } + public static CosmosItemRequestOptions setPartitionKey(CosmosItemRequestOptions cosmosItemRequestOptions, PartitionKey partitionKey) { return cosmosItemRequestOptions.setPartitionKey(partitionKey); @@ -483,4 +500,11 @@ public static void setFeedOptionsMaxItemCount(FeedOptions feedOptions, Integer m feedOptions.setMaxItemCount(maxItemCount); } + public static Offer getOfferFromThroughputProperties(ThroughputProperties properties) { + return properties.getOffer(); + } + + public static ThroughputResponse createThroughputRespose(ResourceResponse offerResourceResponse) { + return new ThroughputResponse(offerResourceResponse); + } } diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ThroughputProperties.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ThroughputProperties.java new file mode 100644 index 000000000000..503f17b9958e --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ThroughputProperties.java @@ -0,0 +1,93 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.cosmos.models; + +import com.azure.cosmos.implementation.Offer; +import com.azure.cosmos.implementation.OfferAutoscaleSettings; + +/** + * Represents throughput of the resources in the Azure Cosmos DB service. + */ +public class ThroughputProperties { + private final Offer offer; + + ThroughputProperties(Offer offer) { + this.offer = offer; + } + + /** + * Create fixed throughput properties. + * + * @param throughput the throughput + * @return the throughput properties + */ + public static ThroughputProperties createManualThroughput(int throughput) { + return new ThroughputProperties(Offer.createManualOffer(throughput)); + } + + /** + * Create auto scale throughput properties. + * + * @param autoScaleMaxThroughput the max auto scale throughput + * @param autoUpgradethroughputIncrementPercentage the auto upgrade max throughput increment percentage + * @return the throughput properties + */ + static ThroughputProperties createAutoscaledThroughput( + int autoScaleMaxThroughput, + int autoUpgradethroughputIncrementPercentage) { + return new ThroughputProperties(Offer.createAutoscaleOffer(autoScaleMaxThroughput, + autoUpgradethroughputIncrementPercentage)); + } + + /** + * Create auto scaled provisioned throughput throughput properties. + * + * @param autoScaleMaxThroughput the max auto scale throughput + * @return the throughput properties + */ + public static ThroughputProperties createAutoscaledThroughput(int autoScaleMaxThroughput) { + return new ThroughputProperties(Offer.createAutoscaleOffer(autoScaleMaxThroughput, + 0)); + } + + /** + * Gets offer throughput. + * + * @return the offer throughput + */ + public Integer getManualThroughput() { + return offer.getThroughput(); + } + + /** + * Gets offer autoscale properties. + * + * @return the offer autoscale properties + */ + OfferAutoscaleSettings getOfferAutoscaleProperties() { + return this.offer.getOfferAutoScaleSettings(); + } + + /** + * Gets max autoscale throughput. + * + * @return the max autoscale throughput + */ + public int getAutoscaleMaxThroughput() { + return this.offer.getAutoscaleMaxThroughput(); + } + + + Offer getOffer() { + return this.offer; + } + + /** + * Get an updated offer based on the properties. + */ + Offer updateOfferFromProperties(Offer oldOffer) { + oldOffer.updateContent(this.offer); + return oldOffer; + } + +} diff --git a/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ThroughputResponse.java b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ThroughputResponse.java new file mode 100644 index 000000000000..199d0882da82 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/ThroughputResponse.java @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +package com.azure.cosmos.models; + +import com.azure.cosmos.implementation.HttpConstants; +import com.azure.cosmos.implementation.Offer; +import com.azure.cosmos.implementation.ResourceResponse; + +/** + * The cosmos throughput response. + */ +public class ThroughputResponse extends CosmosResponse { + + private ResourceResponse offerResourceResponse; + private ThroughputProperties throughputProperties; + + ThroughputResponse(ResourceResponse offerResourceResponse) { + super(offerResourceResponse); + this.offerResourceResponse = offerResourceResponse; + } + + @Override + public ThroughputProperties getProperties(){ + if (throughputProperties == null){ + Offer offer = + new Offer(ModelBridgeInternal.getPropertyBagFromJsonSerializable(offerResourceResponse.getResource())); + throughputProperties = new ThroughputProperties(offer); + } + return throughputProperties; + } + + /** + * Gets minimum throughput in measurement of request units per second in the Azure Cosmos service. + * + * @return the minimun throughput + */ + public int getMinThroughput(){ + return Integer.parseInt(offerResourceResponse + .getResponseHeaders() + .get(HttpConstants.HttpHeaders.OFFER_MIN_THROUGHPUT)); + } + + /** + * Gets the status whether offer replace is successful or pending. + * + * @return the boolean representing the status + */ + public boolean isReplacePending(){ + return Boolean.parseBoolean(offerResourceResponse + .getResponseHeaders() + .get(HttpConstants.HttpHeaders.OFFER_REPLACE_PENDING)); + } + +} diff --git a/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/AnalyticalStorageCodeSnippet.java b/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/AnalyticalStorageCodeSnippet.java index 5317d24b719a..6d95fca46413 100644 --- a/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/AnalyticalStorageCodeSnippet.java +++ b/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/AnalyticalStorageCodeSnippet.java @@ -7,8 +7,6 @@ import com.azure.cosmos.models.CosmosAsyncDatabaseResponse; import com.azure.cosmos.models.CosmosContainerProperties; -import java.time.Instant; - public class AnalyticalStorageCodeSnippet { public static void main(String[] args) throws Exception { @@ -20,7 +18,7 @@ public static void main(String[] args) throws Exception { CosmosAsyncDatabaseResponse database = client.createDatabaseIfNotExists("testDB").block(); CosmosContainerProperties cosmosContainerProperties = new CosmosContainerProperties("testContainer", "/id"); - cosmosContainerProperties.setAnalyticalStorageTimeToLiveInSeconds(-1); + cosmosContainerProperties.setAnalyticalStoreTimeToLiveInSeconds(-1); database.getDatabase().createContainer(cosmosContainerProperties).block(); diff --git a/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/ThroughputPropertiesCodeSnippet.java b/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/ThroughputPropertiesCodeSnippet.java new file mode 100644 index 000000000000..91200638154c --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/samples/java/com/azure/cosmos/ThroughputPropertiesCodeSnippet.java @@ -0,0 +1,20 @@ +package com.azure.cosmos; + +import com.azure.cosmos.implementation.TestConfigurations; +import com.azure.cosmos.models.ThroughputProperties; + +public class ThroughputPropertiesCodeSnippet { + public static void main(String[] args) throws Exception { + + CosmosAsyncClient client = new CosmosClientBuilder() + .endpoint(TestConfigurations.HOST) + .key(TestConfigurations.MASTER_KEY) + .buildAsyncClient(); + + final String databaseName = "testDB"; + int throughput = 5000; + ThroughputProperties properties = ThroughputProperties.createAutoscaledThroughput(throughput); + client.createDatabase(databaseName, properties).block(); + client.close(); + } +} diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ClientUnderTestBuilder.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ClientUnderTestBuilder.java index 107a9286372b..60d9aefe9920 100644 --- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ClientUnderTestBuilder.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/ClientUnderTestBuilder.java @@ -17,6 +17,7 @@ public ClientUnderTestBuilder(CosmosClientBuilder builder) { this.key(builder.getKey()); this.endpoint(builder.getEndpoint()); this.keyCredential(builder.getKeyCredential()); + this.contentResponseOnWriteEnabled(builder.isContentResponseOnWriteEnabled()); } @Override @@ -29,7 +30,8 @@ public CosmosAsyncClient buildAsyncClient() { this.getConnectionPolicy(), this.getConsistencyLevel(), this.configs(), - this.getKeyCredential()); + this.getKeyCredential(), + this.isContentResponseOnWriteEnabled()); } catch (URISyntaxException e) { throw new IllegalArgumentException(e.getMessage()); } diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java new file mode 100644 index 000000000000..da23f418b482 --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerContentResponseOnWriteTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + * + */ + +package com.azure.cosmos; + +import com.azure.cosmos.models.CosmosContainerProperties; +import com.azure.cosmos.models.CosmosContainerRequestOptions; +import com.azure.cosmos.models.CosmosContainerResponse; +import com.azure.cosmos.models.IndexingMode; +import com.azure.cosmos.models.IndexingPolicy; +import com.azure.cosmos.models.PartitionKeyDefinition; +import com.azure.cosmos.rx.TestSuiteBase; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CosmosContainerContentResponseOnWriteTest extends TestSuiteBase { + + private final String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); + private CosmosClient client; + private CosmosDatabase createdDatabase; + + // Currently Gateway and Direct TCP support minimal response feature. + @Factory(dataProvider = "clientBuildersWithDirectTcpWithContentResponseOnWriteDisabled") + public CosmosContainerContentResponseOnWriteTest(CosmosClientBuilder clientBuilder) { + super(clientBuilder); + } + + @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) + public void beforeClass() { + assertThat(this.client).isNull(); + this.client = getClientBuilder().buildClient(); + createdDatabase = createSyncDatabase(client, preExistingDatabaseId); + } + + @AfterClass(groups = {"emulator"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) + public void afterClass() { + safeDeleteSyncDatabase(createdDatabase); + safeCloseSyncClient(client); + } + + @Test(groups = { "emulator" }, timeOut = TIMEOUT) + public void createContainer_withContentResponseOnWriteDisabled() throws Exception { + String collectionName = UUID.randomUUID().toString(); + CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); + + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + assertThat(containerResponse.getRequestCharge()).isGreaterThan(0); + validateContainerResponse(containerProperties, containerResponse); + } + + @Test(groups = { "emulator" }, timeOut = TIMEOUT) + public void readContainer_withContentResponseOnWriteDisabled() throws Exception { + String collectionName = UUID.randomUUID().toString(); + CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); + CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); + + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + + CosmosContainer syncContainer = createdDatabase.getContainer(collectionName); + + CosmosContainerResponse read = syncContainer.read(); + validateContainerResponse(containerProperties, read); + + CosmosContainerResponse read1 = syncContainer.read(options); + validateContainerResponse(containerProperties, read1); + } + + @Test(groups = { "emulator" }, timeOut = TIMEOUT) + public void replaceContainer_withContentResponseOnWriteDisabled() throws Exception { + + String collectionName = UUID.randomUUID().toString(); + CosmosContainerProperties containerProperties = getCollectionDefinition(collectionName); + CosmosContainerRequestOptions options = new CosmosContainerRequestOptions(); + + CosmosContainerResponse containerResponse = createdDatabase.createContainer(containerProperties); + validateContainerResponse(containerProperties, containerResponse); + + assertThat(containerResponse.getProperties().getIndexingPolicy().getIndexingMode()).isEqualTo(IndexingMode.CONSISTENT); + + CosmosContainerResponse replaceResponse = containerResponse.getContainer() + .replace(containerResponse.getProperties().setIndexingPolicy( + new IndexingPolicy().setIndexingMode(IndexingMode.LAZY))); + assertThat(replaceResponse.getProperties().getIndexingPolicy().getIndexingMode()) + .isEqualTo(IndexingMode.LAZY); + + CosmosContainerResponse replaceResponse1 = containerResponse.getContainer() + .replace(containerResponse.getProperties().setIndexingPolicy( + new IndexingPolicy().setIndexingMode(IndexingMode.CONSISTENT)), + options); + assertThat(replaceResponse1.getProperties().getIndexingPolicy().getIndexingMode()) + .isEqualTo(IndexingMode.CONSISTENT); + + } + + private CosmosContainerProperties getCollectionDefinition(String collectionName) { + PartitionKeyDefinition partitionKeyDef = new PartitionKeyDefinition(); + ArrayList paths = new ArrayList (); + paths.add("/mypk"); + partitionKeyDef.setPaths(paths); + + return new CosmosContainerProperties( + collectionName, + partitionKeyDef); + } + + private void validateContainerResponse(CosmosContainerProperties containerProperties, + CosmosContainerResponse createResponse) { + // Basic validation + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) + .as("check Resource Id") + .isEqualTo(containerProperties.getId()); + + } + +} diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerTest.java index 90bddb077306..698d0538d02f 100644 --- a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerTest.java +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosContainerTest.java @@ -92,7 +92,7 @@ public void createContainer_withAnalyticalTTL(Integer analyticalTTL) throws Exce String collectionName = UUID.randomUUID().toString(); CosmosContainerProperties containerProperties = new CosmosContainerProperties(collectionName, "/id"); - containerProperties.setAnalyticalStorageTimeToLiveInSeconds(analyticalTTL); + containerProperties.setAnalyticalStoreTimeToLiveInSeconds(analyticalTTL); if (analyticalTTL != null && analyticalTTL > 0) { containerProperties.setDefaultTimeToLiveInSeconds(analyticalTTL - 1); } @@ -101,7 +101,7 @@ public void createContainer_withAnalyticalTTL(Integer analyticalTTL) throws Exce assertThat(containerResponse.getRequestCharge()).isGreaterThan(0); validateContainerResponse(containerProperties, containerResponse); - assertThat(containerResponse.getProperties().getAnalyticalStorageTimeToLiveInSeconds()).isEqualTo(analyticalTTL); + assertThat(containerResponse.getProperties().getAnalyticalStoreTimeToLiveInSeconds()).isEqualTo(analyticalTTL); } @Test(groups = {"emulator"}, timeOut = TIMEOUT) diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java new file mode 100644 index 000000000000..e4264996bdac --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosDatabaseContentResponseOnWriteTest.java @@ -0,0 +1,84 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + * + */ + +package com.azure.cosmos; + +import com.azure.cosmos.models.CosmosDatabaseProperties; +import com.azure.cosmos.models.CosmosDatabaseRequestOptions; +import com.azure.cosmos.models.CosmosDatabaseResponse; +import com.azure.cosmos.rx.TestSuiteBase; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.List; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CosmosDatabaseContentResponseOnWriteTest extends TestSuiteBase { + + private final String preExistingDatabaseId = CosmosDatabaseForTest.generateId(); + private final List databases = new ArrayList<>(); + private CosmosClient client; + private CosmosDatabase createdDatabase; + + // Currently Gateway and Direct TCP support minimal response feature. + @Factory(dataProvider = "clientBuildersWithDirectTcpWithContentResponseOnWriteDisabled") + public CosmosDatabaseContentResponseOnWriteTest(CosmosClientBuilder clientBuilder) { + super(clientBuilder); + } + + @BeforeClass(groups = {"emulator"}, timeOut = SETUP_TIMEOUT) + public void beforeClass() { + assertThat(this.client).isNull(); + this.client = getClientBuilder().buildClient(); + createdDatabase = createSyncDatabase(client, preExistingDatabaseId); + } + + @AfterClass(groups = {"emulator"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) + public void afterClass() { + safeDeleteSyncDatabase(createdDatabase); + for (String dbId : databases) { + safeDeleteSyncDatabase(client.getDatabase(dbId)); + } + safeCloseSyncClient(client); + } + + @Test(groups = {"emulator"}, timeOut = TIMEOUT) + public void createDatabase_withContentResponseOnWriteDisabled() throws CosmosClientException { + CosmosDatabaseProperties databaseDefinition = new CosmosDatabaseProperties(CosmosDatabaseForTest.generateId()); + databases.add(databaseDefinition.getId()); + + CosmosDatabaseResponse createResponse = client.createDatabase(databaseDefinition, new CosmosDatabaseRequestOptions()); + + validateDatabaseResponse(databaseDefinition, createResponse); + } + + @Test(groups = {"emulator"}, timeOut = TIMEOUT) + public void readDatabase_withContentResponseOnWriteDisabled() throws Exception { + CosmosDatabase database = client.getDatabase(createdDatabase.getId()); + CosmosDatabaseProperties properties = new CosmosDatabaseProperties(createdDatabase.getId()); + CosmosDatabaseRequestOptions options = new CosmosDatabaseRequestOptions(); + + CosmosDatabaseResponse read = database.read(); + validateDatabaseResponse(properties, read); + + CosmosDatabaseResponse read1 = database.read(options); + validateDatabaseResponse(properties, read1); + } + + private void validateDatabaseResponse(CosmosDatabaseProperties databaseDefinition, CosmosDatabaseResponse createResponse) { + // Basic validation + assertThat(createResponse.getProperties().getId()).isNotNull(); + assertThat(createResponse.getProperties().getId()) + .as("check Resource Id") + .isEqualTo(databaseDefinition.getId()); + + } + +} diff --git a/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java new file mode 100644 index 000000000000..a291d7a2f3ab --- /dev/null +++ b/sdk/cosmos/azure-cosmos/src/test/java/com/azure/cosmos/CosmosItemContentResponseOnWriteTest.java @@ -0,0 +1,155 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. + * + */ + +package com.azure.cosmos; + +import com.azure.cosmos.implementation.CosmosItemProperties; +import com.azure.cosmos.models.CosmosContainerProperties; +import com.azure.cosmos.models.CosmosItemRequestOptions; +import com.azure.cosmos.models.CosmosItemResponse; +import com.azure.cosmos.models.ModelBridgeInternal; +import com.azure.cosmos.models.PartitionKey; +import com.azure.cosmos.models.PartitionKeyDefinition; +import com.azure.cosmos.rx.TestSuiteBase; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; + +import java.util.ArrayList; +import java.util.UUID; + +import static org.assertj.core.api.Assertions.assertThat; + +public class CosmosItemContentResponseOnWriteTest extends TestSuiteBase { + + private CosmosClient client; + private CosmosContainer container; + + // Currently Gateway and Direct TCP support minimal response feature. + @Factory(dataProvider = "clientBuildersWithDirectTcpWithContentResponseOnWriteDisabled") + public CosmosItemContentResponseOnWriteTest(CosmosClientBuilder clientBuilder) { + super(clientBuilder); + } + + @BeforeClass(groups = {"simple"}, timeOut = SETUP_TIMEOUT) + public void beforeClass() { + assertThat(this.client).isNull(); + this.client = getClientBuilder().buildClient(); + CosmosAsyncContainer asyncContainer = getSharedMultiPartitionCosmosContainer(this.client.asyncClient()); + container = client.getDatabase(asyncContainer.getDatabase().getId()).getContainer(asyncContainer.getId()); + } + + @AfterClass(groups = {"simple"}, timeOut = SHUTDOWN_TIMEOUT, alwaysRun = true) + public void afterClass() { + assertThat(this.client).isNotNull(); + this.client.close(); + } + + @Test(groups = { "simple" }, timeOut = TIMEOUT) + public void createItem_withContentResponseOnWriteDisabled() throws Exception { + CosmosItemProperties properties = getDocumentDefinition(UUID.randomUUID().toString()); + CosmosItemResponse itemResponse = container.createItem(properties); + assertThat(itemResponse.getRequestCharge()).isGreaterThan(0); + validateMinimalItemResponse(properties, itemResponse, true); + + properties = getDocumentDefinition(UUID.randomUUID().toString()); + CosmosItemResponse