Skip to content

Commit c8b49aa

Browse files
author
SDKAuto
committed
CodeGen from PR 17626 in Azure/azure-rest-api-specs
Merge b45aaf4f9be1b4ad5c53fd6ec3c5f55901a6503d into 83359713f73971bf895e84b23c09617cccec88b4
1 parent a3add55 commit c8b49aa

File tree

12 files changed

+347
-73
lines changed

12 files changed

+347
-73
lines changed

sdk/changeanalysis/azure-resourcemanager-changeanalysis/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# Release History
22

3-
## 1.1.0-beta.1 (Unreleased)
3+
## 1.0.0-beta.1 (2022-02-09)
44

5+
- Azure Resource Manager AzureChangeAnalysis client library for Java. This package contains Microsoft Azure SDK for AzureChangeAnalysis Management SDK. Package tag package-2021-04-01. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).
56

67
## 1.0.0 (2021-04-21)
78

sdk/changeanalysis/azure-resourcemanager-changeanalysis/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Various documentation is available to help you get started
3232
<dependency>
3333
<groupId>com.azure.resourcemanager</groupId>
3434
<artifactId>azure-resourcemanager-changeanalysis</artifactId>
35-
<version>1.0.0</version>
35+
<version>1.1.0-beta.1</version>
3636
</dependency>
3737
```
3838
[//]: # ({x-version-update-end})
@@ -74,6 +74,9 @@ See [API design][design] for general introduction on design and key concepts on
7474

7575
## Examples
7676

77+
[Code snippets and samples](https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/changeanalysis/azure-resourcemanager-changeanalysis/SAMPLE.md)
78+
79+
7780
## Troubleshooting
7881

7982
## Next steps
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# Code snippets and samples
2+
3+
4+
## Changes
5+
6+
- [List](#changes_list)
7+
- [ListByResourceGroup](#changes_listbyresourcegroup)
8+
9+
## Operations
10+
11+
- [List](#operations_list)
12+
13+
## ResourceChanges
14+
15+
- [List](#resourcechanges_list)
16+
### Changes_List
17+
18+
```java
19+
import com.azure.core.util.Context;
20+
import java.time.OffsetDateTime;
21+
22+
/** Samples for Changes List. */
23+
public final class ChangesListSamples {
24+
/*
25+
* x-ms-original-file: specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ChangesListChangesBySubscription.json
26+
*/
27+
/**
28+
* Sample code: Changes_ListChangesBySubscription.
29+
*
30+
* @param manager Entry point to AzureChangeAnalysisManager.
31+
*/
32+
public static void changesListChangesBySubscription(
33+
com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager manager) {
34+
manager
35+
.changes()
36+
.list(
37+
OffsetDateTime.parse("2021-04-25T12:09:03.141Z"),
38+
OffsetDateTime.parse("2021-04-26T12:09:03.141Z"),
39+
null,
40+
Context.NONE);
41+
}
42+
}
43+
```
44+
45+
### Changes_ListByResourceGroup
46+
47+
```java
48+
import com.azure.core.util.Context;
49+
import java.time.OffsetDateTime;
50+
51+
/** Samples for Changes ListByResourceGroup. */
52+
public final class ChangesListByResourceGroupSamples {
53+
/*
54+
* x-ms-original-file: specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ChangesListChangesByResourceGroup.json
55+
*/
56+
/**
57+
* Sample code: Changes_ListChangesByResourceGroup.
58+
*
59+
* @param manager Entry point to AzureChangeAnalysisManager.
60+
*/
61+
public static void changesListChangesByResourceGroup(
62+
com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager manager) {
63+
manager
64+
.changes()
65+
.listByResourceGroup(
66+
"MyResourceGroup",
67+
OffsetDateTime.parse("2021-04-25T12:09:03.141Z"),
68+
OffsetDateTime.parse("2021-04-26T12:09:03.141Z"),
69+
null,
70+
Context.NONE);
71+
}
72+
}
73+
```
74+
75+
### Operations_List
76+
77+
```java
78+
import com.azure.core.util.Context;
79+
80+
/** Samples for Operations List. */
81+
public final class OperationsListSamples {
82+
/*
83+
* x-ms-original-file: specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/OperationsList.json
84+
*/
85+
/**
86+
* Sample code: Operations_List.
87+
*
88+
* @param manager Entry point to AzureChangeAnalysisManager.
89+
*/
90+
public static void operationsList(com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager manager) {
91+
manager.operations().list(null, Context.NONE);
92+
}
93+
}
94+
```
95+
96+
### ResourceChanges_List
97+
98+
```java
99+
import com.azure.core.util.Context;
100+
import java.time.OffsetDateTime;
101+
102+
/** Samples for ResourceChanges List. */
103+
public final class ResourceChangesListSamples {
104+
/*
105+
* x-ms-original-file: specification/changeanalysis/resource-manager/Microsoft.ChangeAnalysis/stable/2021-04-01/examples/ResourceChangesList.json
106+
*/
107+
/**
108+
* Sample code: ResourceChanges_List.
109+
*
110+
* @param manager Entry point to AzureChangeAnalysisManager.
111+
*/
112+
public static void resourceChangesList(
113+
com.azure.resourcemanager.changeanalysis.AzureChangeAnalysisManager manager) {
114+
manager
115+
.resourceChanges()
116+
.list(
117+
"subscriptions/4d962866-1e3f-47f2-bd18-450c08f914c1/resourceGroups/MyResourceGroup/providers/Microsoft.Web/sites/mysite",
118+
OffsetDateTime.parse("2021-04-25T12:09:03.141Z"),
119+
OffsetDateTime.parse("2021-04-26T12:09:03.141Z"),
120+
null,
121+
Context.NONE);
122+
}
123+
}
124+
```
125+
Lines changed: 49 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
2-
<modelVersion>4.0.0</modelVersion>
3-
<parent>
4-
<groupId>com.azure</groupId>
5-
<artifactId>azure-client-sdk-parent</artifactId>
6-
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
7-
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
8-
</parent>
2+
<modelVersion>4.0.0</modelVersion>
3+
<parent>
4+
<groupId>com.azure</groupId>
5+
<artifactId>azure-client-sdk-parent</artifactId>
6+
<version>1.7.0</version> <!-- {x-version-update;com.azure:azure-client-sdk-parent;current} -->
7+
<relativePath>../../parents/azure-client-sdk-parent</relativePath>
8+
</parent>
99

10-
<groupId>com.azure.resourcemanager</groupId>
11-
<artifactId>azure-resourcemanager-changeanalysis</artifactId>
12-
<version>1.1.0-beta.1</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-changeanalysis;current} -->
13-
<packaging>jar</packaging>
10+
<groupId>com.azure.resourcemanager</groupId>
11+
<artifactId>azure-resourcemanager-changeanalysis</artifactId>
12+
<version>1.1.0-beta.1</version> <!-- {x-version-update;com.azure.resourcemanager:azure-resourcemanager-changeanalysis;current} -->
13+
<packaging>jar</packaging>
1414

15-
<name>Microsoft Azure SDK for AzureChangeAnalysis Management</name>
16-
<description>This package contains Microsoft Azure SDK for AzureChangeAnalysis Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2021-04-01.</description>
17-
<url>https://github.com/Azure/azure-sdk-for-java</url>
15+
<name>Microsoft Azure SDK for AzureChangeAnalysis Management</name>
16+
<description>This package contains Microsoft Azure SDK for AzureChangeAnalysis Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Package tag package-2021-04-01.</description>
17+
<url>https://github.com/Azure/azure-sdk-for-java</url>
1818

19-
<licenses>
20-
<license>
21-
<name>The MIT License (MIT)</name>
22-
<url>http://opensource.org/licenses/MIT</url>
23-
<distribution>repo</distribution>
24-
</license>
25-
</licenses>
19+
<licenses>
20+
<license>
21+
<name>The MIT License (MIT)</name>
22+
<url>http://opensource.org/licenses/MIT</url>
23+
<distribution>repo</distribution>
24+
</license>
25+
</licenses>
2626

27-
<scm>
28-
<url>https://github.com/Azure/azure-sdk-for-java</url>
29-
<connection>scm:git:[email protected]:Azure/azure-sdk-for-java.git</connection>
30-
<developerConnection>scm:git:[email protected]:Azure/azure-sdk-for-java.git</developerConnection>
31-
<tag>HEAD</tag>
32-
</scm>
33-
<developers>
34-
<developer>
35-
<id>microsoft</id>
36-
<name>Microsoft</name>
37-
</developer>
38-
</developers>
39-
<properties>
40-
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
41-
<jacoco.skip>true</jacoco.skip>
42-
</properties>
43-
<dependencies>
44-
<dependency>
45-
<groupId>com.azure</groupId>
46-
<artifactId>azure-core</artifactId>
47-
<version>1.25.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
48-
</dependency>
49-
<dependency>
50-
<groupId>com.azure</groupId>
51-
<artifactId>azure-core-management</artifactId>
52-
<version>1.5.2</version> <!-- {x-version-update;com.azure:azure-core-management;dependency} -->
53-
</dependency>
54-
</dependencies>
27+
<scm>
28+
<url>https://github.com/Azure/azure-sdk-for-java</url>
29+
<connection>scm:git:[email protected]:Azure/azure-sdk-for-java.git</connection>
30+
<developerConnection>scm:git:[email protected]:Azure/azure-sdk-for-java.git</developerConnection>
31+
<tag>HEAD</tag>
32+
</scm>
33+
<developers>
34+
<developer>
35+
<id>microsoft</id>
36+
<name>Microsoft</name>
37+
</developer>
38+
</developers>
39+
<properties>
40+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
41+
<jacoco.skip>true</jacoco.skip>
42+
</properties>
43+
<dependencies>
44+
<dependency>
45+
<groupId>com.azure</groupId>
46+
<artifactId>azure-core</artifactId>
47+
<version>1.25.0</version> <!-- {x-version-update;com.azure:azure-core;dependency} -->
48+
</dependency>
49+
<dependency>
50+
<groupId>com.azure</groupId>
51+
<artifactId>azure-core-management</artifactId>
52+
<version>1.5.2</version> <!-- {x-version-update;com.azure:azure-core-management;dependency} -->
53+
</dependency>
54+
</dependencies>
5555
</project>

sdk/changeanalysis/azure-resourcemanager-changeanalysis/src/main/java/com/azure/resourcemanager/changeanalysis/AzureChangeAnalysisManager.java

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@
88
import com.azure.core.http.HttpClient;
99
import com.azure.core.http.HttpPipeline;
1010
import com.azure.core.http.HttpPipelineBuilder;
11+
import com.azure.core.http.HttpPipelinePosition;
1112
import com.azure.core.http.policy.AddDatePolicy;
12-
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
1313
import com.azure.core.http.policy.HttpLogOptions;
1414
import com.azure.core.http.policy.HttpLoggingPolicy;
1515
import com.azure.core.http.policy.HttpPipelinePolicy;
1616
import com.azure.core.http.policy.HttpPolicyProviders;
1717
import com.azure.core.http.policy.RequestIdPolicy;
1818
import com.azure.core.http.policy.RetryPolicy;
1919
import com.azure.core.http.policy.UserAgentPolicy;
20+
import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy;
2021
import com.azure.core.management.profile.AzureProfile;
2122
import com.azure.core.util.Configuration;
2223
import com.azure.core.util.logging.ClientLogger;
@@ -33,6 +34,7 @@
3334
import java.util.ArrayList;
3435
import java.util.List;
3536
import java.util.Objects;
37+
import java.util.stream.Collectors;
3638

3739
/** Entry point to AzureChangeAnalysisManager. */
3840
public final class AzureChangeAnalysisManager {
@@ -85,6 +87,7 @@ public static final class Configurable {
8587
private HttpClient httpClient;
8688
private HttpLogOptions httpLogOptions;
8789
private final List<HttpPipelinePolicy> policies = new ArrayList<>();
90+
private final List<String> scopes = new ArrayList<>();
8891
private RetryPolicy retryPolicy;
8992
private Duration defaultPollInterval;
9093

@@ -124,6 +127,17 @@ public Configurable withPolicy(HttpPipelinePolicy policy) {
124127
return this;
125128
}
126129

130+
/**
131+
* Adds the scope to permission sets.
132+
*
133+
* @param scope the scope.
134+
* @return the configurable object itself.
135+
*/
136+
public Configurable withScope(String scope) {
137+
this.scopes.add(Objects.requireNonNull(scope, "'scope' cannot be null."));
138+
return this;
139+
}
140+
127141
/**
128142
* Sets the retry policy to the HTTP pipeline.
129143
*
@@ -166,7 +180,7 @@ public AzureChangeAnalysisManager authenticate(TokenCredential credential, Azure
166180
.append("-")
167181
.append("com.azure.resourcemanager.changeanalysis")
168182
.append("/")
169-
.append("1.0.0");
183+
.append("1.0.0-beta.1");
170184
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
171185
userAgentBuilder
172186
.append(" (")
@@ -180,20 +194,33 @@ public AzureChangeAnalysisManager authenticate(TokenCredential credential, Azure
180194
userAgentBuilder.append(" (auto-generated)");
181195
}
182196

197+
if (scopes.isEmpty()) {
198+
scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default");
199+
}
183200
if (retryPolicy == null) {
184201
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
185202
}
186203
List<HttpPipelinePolicy> policies = new ArrayList<>();
187204
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
188205
policies.add(new RequestIdPolicy());
206+
policies
207+
.addAll(
208+
this
209+
.policies
210+
.stream()
211+
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
212+
.collect(Collectors.toList()));
189213
HttpPolicyProviders.addBeforeRetryPolicies(policies);
190214
policies.add(retryPolicy);
191215
policies.add(new AddDatePolicy());
216+
policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0])));
192217
policies
193-
.add(
194-
new BearerTokenAuthenticationPolicy(
195-
credential, profile.getEnvironment().getManagementEndpoint() + "/.default"));
196-
policies.addAll(this.policies);
218+
.addAll(
219+
this
220+
.policies
221+
.stream()
222+
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
223+
.collect(Collectors.toList()));
197224
HttpPolicyProviders.addAfterRetryPolicies(policies);
198225
policies.add(new HttpLoggingPolicy(httpLogOptions));
199226
HttpPipeline httpPipeline =

0 commit comments

Comments
 (0)