diff --git a/sdk/iothub/azure-resourcemanager-iothub/CHANGELOG.md b/sdk/iothub/azure-resourcemanager-iothub/CHANGELOG.md index 8e66e76bc61f4..9d3a9229a5c47 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/CHANGELOG.md +++ b/sdk/iothub/azure-resourcemanager-iothub/CHANGELOG.md @@ -1,7 +1,8 @@ # Release History -## 1.1.0-beta.1 (Unreleased) +## 1.0.0-beta.1 (2021-06-18) +- Azure Resource Manager IotHub client library for Java. This package contains Microsoft Azure SDK for IotHub Management SDK. Use this API to manage the IoT hubs in your Azure subscription. Package tag package-2021-07. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ## 1.0.0 (2021-05-14) diff --git a/sdk/iothub/azure-resourcemanager-iothub/README.md b/sdk/iothub/azure-resourcemanager-iothub/README.md index aea81a25c2f2e..3f87528836ebc 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/README.md +++ b/sdk/iothub/azure-resourcemanager-iothub/README.md @@ -2,7 +2,7 @@ Azure Resource Manager IotHub client library for Java. -This package contains Microsoft Azure SDK for IotHub Management SDK. Use this API to manage the IoT hubs in your Azure subscription. Package tag package-2021-03. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). +This package contains Microsoft Azure SDK for IotHub Management SDK. Use this API to manage the IoT hubs in your Azure subscription. Package tag package-2021-07. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt). ## We'd love to hear your feedback @@ -32,7 +32,7 @@ Various documentation is available to help you get started com.azure.resourcemanager azure-resourcemanager-iothub - 1.0.0 + 1.1.0-beta.1 ``` [//]: # ({x-version-update-end}) @@ -74,6 +74,8 @@ See [API design][design] for general introduction on design and key concepts on ## Examples + + ## Troubleshooting ## Next steps diff --git a/sdk/iothub/azure-resourcemanager-iothub/pom.xml b/sdk/iothub/azure-resourcemanager-iothub/pom.xml index ef593cdb3b624..1ced17caed49a 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/pom.xml +++ b/sdk/iothub/azure-resourcemanager-iothub/pom.xml @@ -1,67 +1,86 @@ - 4.0.0 - - com.azure - azure-client-sdk-parent - 1.7.0 - ../../parents/azure-client-sdk-parent - + 4.0.0 + + com.azure + azure-client-sdk-parent + 1.7.0 + ../../parents/azure-client-sdk-parent + - com.azure.resourcemanager - azure-resourcemanager-iothub - 1.1.0-beta.1 - jar + com.azure.resourcemanager + azure-resourcemanager-iothub + 1.1.0-beta.1 + jar - Microsoft Azure SDK for IotHub Management - This package contains Microsoft Azure SDK for IotHub Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Use this API to manage the IoT hubs in your Azure subscription. Package tag package-2021-03. - https://github.com/Azure/azure-sdk-for-java + Microsoft Azure SDK for IotHub Management + This package contains Microsoft Azure SDK for IotHub Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Use this API to manage the IoT hubs in your Azure subscription. Package tag package-2021-07. + https://github.com/Azure/azure-sdk-for-java - - - The MIT License (MIT) - http://opensource.org/licenses/MIT - repo - - + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + - - https://github.com/Azure/azure-sdk-for-java - scm:git:git@github.com:Azure/azure-sdk-for-java.git - scm:git:git@github.com:Azure/azure-sdk-for-java.git - HEAD - - - - microsoft - Microsoft - - - - UTF-8 - - - - - com.azure - azure-core - 1.17.0 - - - com.azure - azure-core-management - 1.3.0 - - - - - - org.jacoco - jacoco-maven-plugin - 0.8.5 - - true - - - - + + https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + + microsoft + Microsoft + + + + UTF-8 + + + + + com.azure + azure-core + 1.17.0 + + + com.azure + azure-core-management + 1.3.0 + + + + + + org.jacoco + jacoco-maven-plugin + 0.8.5 + + true + + + + org.revapi + revapi-maven-plugin + 0.11.2 + + + + + java.method.addedToInterface + + + true + .* + com\.azure\.resourcemanager(\.[^.]+)+\.fluent(\.[^.]+)* + + + + + + + diff --git a/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/IotHubManager.java b/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/IotHubManager.java index 2ebe2d85afdc6..7cc543ac5fd2f 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/IotHubManager.java +++ b/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/IotHubManager.java @@ -9,7 +9,6 @@ import com.azure.core.http.HttpPipeline; import com.azure.core.http.HttpPipelineBuilder; import com.azure.core.http.policy.AddDatePolicy; -import com.azure.core.http.policy.BearerTokenAuthenticationPolicy; import com.azure.core.http.policy.HttpLogOptions; import com.azure.core.http.policy.HttpLoggingPolicy; import com.azure.core.http.policy.HttpPipelinePolicy; @@ -17,6 +16,7 @@ import com.azure.core.http.policy.RequestIdPolicy; import com.azure.core.http.policy.RetryPolicy; import com.azure.core.http.policy.UserAgentPolicy; +import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy; import com.azure.core.management.profile.AzureProfile; import com.azure.core.util.Configuration; import com.azure.core.util.logging.ClientLogger; @@ -101,6 +101,7 @@ public static final class Configurable { private HttpClient httpClient; private HttpLogOptions httpLogOptions; private final List policies = new ArrayList<>(); + private final List scopes = new ArrayList<>(); private RetryPolicy retryPolicy; private Duration defaultPollInterval; @@ -140,6 +141,17 @@ public Configurable withPolicy(HttpPipelinePolicy policy) { return this; } + /** + * Adds the scope to permission sets. + * + * @param scope the scope. + * @return the configurable object itself. + */ + public Configurable withScope(String scope) { + this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null.")); + return this; + } + /** * Sets the retry policy to the HTTP pipeline. * @@ -182,7 +194,7 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi .append("-") .append("com.azure.resourcemanager.iothub") .append("/") - .append("1.0.0"); + .append("1.0.0-beta.1"); if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) { userAgentBuilder .append(" (") @@ -196,6 +208,9 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi userAgentBuilder.append(" (auto-generated)"); } + if (scopes.isEmpty()) { + scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default"); + } if (retryPolicy == null) { retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS); } @@ -205,10 +220,7 @@ public IotHubManager authenticate(TokenCredential credential, AzureProfile profi HttpPolicyProviders.addBeforeRetryPolicies(policies); policies.add(retryPolicy); policies.add(new AddDatePolicy()); - policies - .add( - new BearerTokenAuthenticationPolicy( - credential, profile.getEnvironment().getManagementEndpoint() + "/.default")); + policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0]))); policies.addAll(this.policies); HttpPolicyProviders.addAfterRetryPolicies(policies); policies.add(new HttpLoggingPolicy(httpLogOptions)); diff --git a/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/implementation/IotHubClientImpl.java b/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/implementation/IotHubClientImpl.java index 3ab5b4bc30983..cc70412dc79f8 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/implementation/IotHubClientImpl.java +++ b/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/implementation/IotHubClientImpl.java @@ -222,7 +222,7 @@ public PrivateEndpointConnectionsClient getPrivateEndpointConnections() { this.defaultPollInterval = defaultPollInterval; this.subscriptionId = subscriptionId; this.endpoint = endpoint; - this.apiVersion = "2021-03-31"; + this.apiVersion = "2021-07-01"; this.operations = new OperationsClientImpl(this); this.iotHubResources = new IotHubResourcesClientImpl(this); this.resourceProviderCommons = new ResourceProviderCommonsClientImpl(this); diff --git a/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/models/IotHubProperties.java b/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/models/IotHubProperties.java index 1a8baac9b4dae..b1ca9bfa255e5 100644 --- a/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/models/IotHubProperties.java +++ b/sdk/iothub/azure-resourcemanager-iothub/src/main/java/com/azure/resourcemanager/iothub/models/IotHubProperties.java @@ -25,6 +25,40 @@ public final class IotHubProperties { @JsonProperty(value = "authorizationPolicies") private List authorizationPolicies; + /* + * If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + * authentication. + */ + @JsonProperty(value = "disableLocalAuth") + private Boolean disableLocalAuth; + + /* + * If true, all device(including Edge devices but excluding modules) scoped + * SAS keys cannot be used for authentication. + */ + @JsonProperty(value = "disableDeviceSAS") + private Boolean disableDeviceSas; + + /* + * If true, all module scoped SAS keys cannot be used for authentication. + */ + @JsonProperty(value = "disableModuleSAS") + private Boolean disableModuleSas; + + /* + * If true, egress from IotHub will be restricted to only the allowed FQDNs + * that are configured via allowedFqdnList. + */ + @JsonProperty(value = "restrictOutboundNetworkAccess") + private Boolean restrictOutboundNetworkAccess; + + /* + * List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot + * Hub. + */ + @JsonProperty(value = "allowedFqdnList") + private List allowedFqdnList; + /* * Whether requests from Public Network are allowed */ @@ -160,6 +194,112 @@ public IotHubProperties withAuthorizationPolicies( return this; } + /** + * Get the disableLocalAuth property: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + * authentication. + * + * @return the disableLocalAuth value. + */ + public Boolean disableLocalAuth() { + return this.disableLocalAuth; + } + + /** + * Set the disableLocalAuth property: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + * authentication. + * + * @param disableLocalAuth the disableLocalAuth value to set. + * @return the IotHubProperties object itself. + */ + public IotHubProperties withDisableLocalAuth(Boolean disableLocalAuth) { + this.disableLocalAuth = disableLocalAuth; + return this; + } + + /** + * Get the disableDeviceSas property: If true, all device(including Edge devices but excluding modules) scoped SAS + * keys cannot be used for authentication. + * + * @return the disableDeviceSas value. + */ + public Boolean disableDeviceSas() { + return this.disableDeviceSas; + } + + /** + * Set the disableDeviceSas property: If true, all device(including Edge devices but excluding modules) scoped SAS + * keys cannot be used for authentication. + * + * @param disableDeviceSas the disableDeviceSas value to set. + * @return the IotHubProperties object itself. + */ + public IotHubProperties withDisableDeviceSas(Boolean disableDeviceSas) { + this.disableDeviceSas = disableDeviceSas; + return this; + } + + /** + * Get the disableModuleSas property: If true, all module scoped SAS keys cannot be used for authentication. + * + * @return the disableModuleSas value. + */ + public Boolean disableModuleSas() { + return this.disableModuleSas; + } + + /** + * Set the disableModuleSas property: If true, all module scoped SAS keys cannot be used for authentication. + * + * @param disableModuleSas the disableModuleSas value to set. + * @return the IotHubProperties object itself. + */ + public IotHubProperties withDisableModuleSas(Boolean disableModuleSas) { + this.disableModuleSas = disableModuleSas; + return this; + } + + /** + * Get the restrictOutboundNetworkAccess property: If true, egress from IotHub will be restricted to only the + * allowed FQDNs that are configured via allowedFqdnList. + * + * @return the restrictOutboundNetworkAccess value. + */ + public Boolean restrictOutboundNetworkAccess() { + return this.restrictOutboundNetworkAccess; + } + + /** + * Set the restrictOutboundNetworkAccess property: If true, egress from IotHub will be restricted to only the + * allowed FQDNs that are configured via allowedFqdnList. + * + * @param restrictOutboundNetworkAccess the restrictOutboundNetworkAccess value to set. + * @return the IotHubProperties object itself. + */ + public IotHubProperties withRestrictOutboundNetworkAccess(Boolean restrictOutboundNetworkAccess) { + this.restrictOutboundNetworkAccess = restrictOutboundNetworkAccess; + return this; + } + + /** + * Get the allowedFqdnList property: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot Hub. + * + * @return the allowedFqdnList value. + */ + public List allowedFqdnList() { + return this.allowedFqdnList; + } + + /** + * Set the allowedFqdnList property: List of allowed FQDNs(Fully Qualified Domain Name) for egress from Iot Hub. + * + * @param allowedFqdnList the allowedFqdnList value to set. + * @return the IotHubProperties object itself. + */ + public IotHubProperties withAllowedFqdnList(List allowedFqdnList) { + this.allowedFqdnList = allowedFqdnList; + return this; + } + /** * Get the publicNetworkAccess property: Whether requests from Public Network are allowed. *