Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
dae1ec3
Add generated files + modified test base
chejiang-msft Aug 22, 2023
c4eece8
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Aug 29, 2023
2039516
Fix compile errors
chejiang-msft Aug 29, 2023
fb3a24b
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Sep 8, 2023
894a534
First set of changes for gets
chejiang-msft Sep 21, 2023
8c9ce39
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Sep 21, 2023
a91dc2a
Finished update client
chejiang-msft Sep 22, 2023
4a5a37f
Finish management client + cleanup
chejiang-msft Sep 22, 2023
c22bb60
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Sep 22, 2023
72a2d7d
Remove config file
chejiang-msft Sep 22, 2023
99d8c06
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Sep 25, 2023
17f9808
Modify pom file to run record mode
chejiang-msft Sep 25, 2023
09fd230
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Sep 28, 2023
a982e22
Regenerate sdks + add new assets
chejiang-msft Sep 28, 2023
cac49b8
Fix docs
chejiang-msft Sep 28, 2023
af829e5
Fix breaking change error
chejiang-msft Oct 2, 2023
dac45f0
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Oct 2, 2023
486e252
PR comments
chejiang-msft Oct 4, 2023
8255da8
Merge remote-tracking branch 'origin/main' into user/chejiang/device-…
chejiang-msft Oct 4, 2023
82a584f
Put jacoco check back to try to fix build
chejiang-msft Oct 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/deviceupdate/azure-iot-deviceupdate/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/deviceupdate/azure-iot-deviceupdate",
"Tag": "java/deviceupdate/azure-iot-deviceupdate_6e7c02a488"
"Tag": "java/deviceupdate/azure-iot-deviceupdate_e6c0b7421b"
}
30 changes: 30 additions & 0 deletions sdk/deviceupdate/azure-iot-deviceupdate/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use: '@autorest/[email protected]'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be in sdk/deviceupdate/azure-iot-deviceupdate/swagger directory. The file should be named README.md and the contents of this file should be wrapped in ```yaml quotes. See example here

input-file: https://github.com/Azure/azure-rest-api-specs/blob/main/specification/deviceupdate/data-plane/Microsoft.DeviceUpdate/stable/2022-10-01/deviceupdate.json
java: true
output-folder: ./
enable-sync-stack: true
generate-tests: true
regenerate-pom: false
title: DeviceUpdateClient
generate-sync-async-clients: true
generate-client-as-impl: true
generate-client-interfaces: false
service-interface-as-public: true
add-context-parameter: true
artifact-id: azure-iot-deviceupdate
data-plane: true
sync-methods: all
generate-samples: true
license-header: MICROSOFT_MIT_SMALL
namespace: com.azure.iot.deviceupdate
service-name: DeviceUpdate
context-client-method-parameter: true
azure-arm: false
credential-types: tokencredential
credential-scopes: https://api.adu.microsoft.com/.default
service-versions:
- '2022-10-01'
polling:
default:
strategy: >-
new OperationResourcePollingStrategyWithEndpoint<>({httpPipeline}, "https://" + this.client.getEndpoint(), null, null, {context})
4 changes: 4 additions & 0 deletions sdk/deviceupdate/azure-iot-deviceupdate/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
<properties>
<jacoco.min.linecoverage>0.25</jacoco.min.linecoverage>
<jacoco.min.branchcoverage>0.1</jacoco.min.branchcoverage>
<!-- Configures the Java 9+ run to perform the required module exports, opens, and reads that are necessary for testing but shouldn't be part of the module-info. -->
<javaModulesSurefireArgLine>
--add-opens com.azure.core/com.azure.core.implementation.util=ALL-UNNAMED
</javaModulesSurefireArgLine>
</properties>

<dependencies>
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Objects;

/** A builder for creating a new instance of the DeviceManagementClient type. */
@ServiceClientBuilder(serviceClients = {DeviceManagementClient.class, DeviceManagementAsyncClient.class})
Expand All @@ -54,7 +54,7 @@ public final class DeviceManagementClientBuilder
@Generated private static final String[] DEFAULT_SCOPES = new String[] {"https://api.adu.microsoft.com/.default"};

@Generated
private final Map<String, String> properties = CoreUtils.getProperties("azure-iot-deviceupdate.properties");
private static final Map<String, String> PROPERTIES = CoreUtils.getProperties("azure-iot-deviceupdate.properties");

@Generated private final List<HttpPipelinePolicy> pipelinePolicies;

Expand Down Expand Up @@ -133,6 +133,7 @@ public DeviceManagementClientBuilder retryOptions(RetryOptions retryOptions) {
@Generated
@Override
public DeviceManagementClientBuilder addPolicy(HttpPipelinePolicy customPolicy) {
Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null.");
pipelinePolicies.add(customPolicy);
return this;
}
Expand Down Expand Up @@ -251,46 +252,40 @@ private DeviceUpdateClientImpl buildInnerClient() {
private HttpPipeline createHttpPipeline() {
Configuration buildConfiguration =
(configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
if (httpLogOptions == null) {
httpLogOptions = new HttpLogOptions();
}
if (clientOptions == null) {
clientOptions = new ClientOptions();
}
HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions;
ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions;
List<HttpPipelinePolicy> policies = new ArrayList<>();
String clientName = properties.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion");
String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions);
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion");
String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions);
policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration));
policies.add(new RequestIdPolicy());
policies.add(new AddHeadersFromContextPolicy());
HttpHeaders headers = new HttpHeaders();
clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue()));
localClientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue()));
if (headers.getSize() > 0) {
policies.add(new AddHeadersPolicy(headers));
}
policies.addAll(
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.collect(Collectors.toList()));
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy()));
policies.add(new AddDatePolicy());
policies.add(new CookiePolicy());
if (tokenCredential != null) {
policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES));
}
policies.addAll(
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.collect(Collectors.toList()));
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
HttpPipeline httpPipeline =
new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.clientOptions(clientOptions)
.clientOptions(localClientOptions)
.build();
return httpPipeline;
}
Expand All @@ -312,6 +307,6 @@ public DeviceManagementAsyncClient buildAsyncClient() {
*/
@Generated
public DeviceManagementClient buildClient() {
return new DeviceManagementClient(new DeviceManagementAsyncClient(buildInnerClient().getDeviceManagements()));
return new DeviceManagementClient(buildInnerClient().getDeviceManagements());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import com.azure.core.util.polling.SyncPoller;
import com.azure.iot.deviceupdate.implementation.DeviceUpdatesImpl;

/** Initializes a new instance of the synchronous DeviceUpdateClient type. */
@ServiceClient(builder = DeviceUpdateClientBuilder.class)
public final class DeviceUpdateClient {
@Generated private final DeviceUpdateAsyncClient client;
@Generated private final DeviceUpdatesImpl serviceClient;

/**
* Initializes an instance of DeviceUpdateClient class.
*
* @param client the async client.
* @param serviceClient the service client implementation.
*/
@Generated
DeviceUpdateClient(DeviceUpdateAsyncClient client) {
this.client = client;
DeviceUpdateClient(DeviceUpdatesImpl serviceClient) {
this.serviceClient = serviceClient;
}

/**
Expand Down Expand Up @@ -107,7 +108,7 @@ public final class DeviceUpdateClient {
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<BinaryData> listUpdates(RequestOptions requestOptions) {
return new PagedIterable<>(this.client.listUpdates(requestOptions));
return this.serviceClient.listUpdates(requestOptions);
}

/**
Expand Down Expand Up @@ -194,7 +195,7 @@ public PagedIterable<BinaryData> listUpdates(RequestOptions requestOptions) {
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<BinaryData, BinaryData> beginImportUpdate(
BinaryData updateToImport, RequestOptions requestOptions) {
return this.client.beginImportUpdate(updateToImport, requestOptions).getSyncPoller();
return this.serviceClient.beginImportUpdate(updateToImport, requestOptions);
}

/**
Expand Down Expand Up @@ -268,7 +269,7 @@ public SyncPoller<BinaryData, BinaryData> beginImportUpdate(
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> getUpdateWithResponse(
String provider, String name, String version, RequestOptions requestOptions) {
return this.client.getUpdateWithResponse(provider, name, version, requestOptions).block();
return this.serviceClient.getUpdateWithResponse(provider, name, version, requestOptions);
}

/**
Expand All @@ -289,7 +290,7 @@ public Response<BinaryData> getUpdateWithResponse(
@ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
public SyncPoller<BinaryData, BinaryData> beginDeleteUpdate(
String provider, String name, String version, RequestOptions requestOptions) {
return this.client.beginDeleteUpdate(provider, name, version, requestOptions).getSyncPoller();
return this.serviceClient.beginDeleteUpdate(provider, name, version, requestOptions);
}

/**
Expand Down Expand Up @@ -317,7 +318,7 @@ public SyncPoller<BinaryData, BinaryData> beginDeleteUpdate(
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<BinaryData> listProviders(RequestOptions requestOptions) {
return new PagedIterable<>(this.client.listProviders(requestOptions));
return this.serviceClient.listProviders(requestOptions);
}

/**
Expand Down Expand Up @@ -346,7 +347,7 @@ public PagedIterable<BinaryData> listProviders(RequestOptions requestOptions) {
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<BinaryData> listNames(String provider, RequestOptions requestOptions) {
return new PagedIterable<>(this.client.listNames(provider, requestOptions));
return this.serviceClient.listNames(provider, requestOptions);
}

/**
Expand Down Expand Up @@ -386,7 +387,7 @@ public PagedIterable<BinaryData> listNames(String provider, RequestOptions reque
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<BinaryData> listVersions(String provider, String name, RequestOptions requestOptions) {
return new PagedIterable<>(this.client.listVersions(provider, name, requestOptions));
return this.serviceClient.listVersions(provider, name, requestOptions);
}

/**
Expand Down Expand Up @@ -418,7 +419,7 @@ public PagedIterable<BinaryData> listVersions(String provider, String name, Requ
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<BinaryData> listFiles(
String provider, String name, String version, RequestOptions requestOptions) {
return new PagedIterable<>(this.client.listFiles(provider, name, version, requestOptions));
return this.serviceClient.listFiles(provider, name, version, requestOptions);
}

/**
Expand Down Expand Up @@ -487,7 +488,7 @@ public PagedIterable<BinaryData> listFiles(
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> getFileWithResponse(
String provider, String name, String version, String fileId, RequestOptions requestOptions) {
return this.client.getFileWithResponse(provider, name, version, fileId, requestOptions).block();
return this.serviceClient.getFileWithResponse(provider, name, version, fileId, requestOptions);
}

/**
Expand Down Expand Up @@ -558,7 +559,7 @@ public Response<BinaryData> getFileWithResponse(
@Generated
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<BinaryData> listOperationStatuses(RequestOptions requestOptions) {
return new PagedIterable<>(this.client.listOperationStatuses(requestOptions));
return this.serviceClient.listOperationStatuses(requestOptions);
}

/**
Expand Down Expand Up @@ -623,6 +624,6 @@ public PagedIterable<BinaryData> listOperationStatuses(RequestOptions requestOpt
@Generated
@ServiceMethod(returns = ReturnType.SINGLE)
public Response<BinaryData> getOperationStatusWithResponse(String operationId, RequestOptions requestOptions) {
return this.client.getOperationStatusWithResponse(operationId, requestOptions).block();
return this.serviceClient.getOperationStatusWithResponse(operationId, requestOptions);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.Objects;

/** A builder for creating a new instance of the DeviceUpdateClient type. */
@ServiceClientBuilder(serviceClients = {DeviceUpdateClient.class, DeviceUpdateAsyncClient.class})
Expand All @@ -54,7 +54,7 @@ public final class DeviceUpdateClientBuilder
@Generated private static final String[] DEFAULT_SCOPES = new String[] {"https://api.adu.microsoft.com/.default"};

@Generated
private final Map<String, String> properties = CoreUtils.getProperties("azure-iot-deviceupdate.properties");
private static final Map<String, String> PROPERTIES = CoreUtils.getProperties("azure-iot-deviceupdate.properties");

@Generated private final List<HttpPipelinePolicy> pipelinePolicies;

Expand Down Expand Up @@ -133,6 +133,7 @@ public DeviceUpdateClientBuilder retryOptions(RetryOptions retryOptions) {
@Generated
@Override
public DeviceUpdateClientBuilder addPolicy(HttpPipelinePolicy customPolicy) {
Objects.requireNonNull(customPolicy, "'customPolicy' cannot be null.");
pipelinePolicies.add(customPolicy);
return this;
}
Expand Down Expand Up @@ -251,46 +252,40 @@ private DeviceUpdateClientImpl buildInnerClient() {
private HttpPipeline createHttpPipeline() {
Configuration buildConfiguration =
(configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
if (httpLogOptions == null) {
httpLogOptions = new HttpLogOptions();
}
if (clientOptions == null) {
clientOptions = new ClientOptions();
}
HttpLogOptions localHttpLogOptions = this.httpLogOptions == null ? new HttpLogOptions() : this.httpLogOptions;
ClientOptions localClientOptions = this.clientOptions == null ? new ClientOptions() : this.clientOptions;
List<HttpPipelinePolicy> policies = new ArrayList<>();
String clientName = properties.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = properties.getOrDefault(SDK_VERSION, "UnknownVersion");
String applicationId = CoreUtils.getApplicationId(clientOptions, httpLogOptions);
String clientName = PROPERTIES.getOrDefault(SDK_NAME, "UnknownName");
String clientVersion = PROPERTIES.getOrDefault(SDK_VERSION, "UnknownVersion");
String applicationId = CoreUtils.getApplicationId(localClientOptions, localHttpLogOptions);
policies.add(new UserAgentPolicy(applicationId, clientName, clientVersion, buildConfiguration));
policies.add(new RequestIdPolicy());
policies.add(new AddHeadersFromContextPolicy());
HttpHeaders headers = new HttpHeaders();
clientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue()));
localClientOptions.getHeaders().forEach(header -> headers.set(header.getName(), header.getValue()));
if (headers.getSize() > 0) {
policies.add(new AddHeadersPolicy(headers));
}
policies.addAll(
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.collect(Collectors.toList()));
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(ClientBuilderUtil.validateAndGetRetryPolicy(retryPolicy, retryOptions, new RetryPolicy()));
policies.add(new AddDatePolicy());
policies.add(new CookiePolicy());
if (tokenCredential != null) {
policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES));
}
policies.addAll(
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.collect(Collectors.toList()));
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.forEach(p -> policies.add(p));
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
HttpPipeline httpPipeline =
new HttpPipelineBuilder()
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.httpClient(httpClient)
.clientOptions(clientOptions)
.clientOptions(localClientOptions)
.build();
return httpPipeline;
}
Expand All @@ -312,6 +307,6 @@ public DeviceUpdateAsyncClient buildAsyncClient() {
*/
@Generated
public DeviceUpdateClient buildClient() {
return new DeviceUpdateClient(new DeviceUpdateAsyncClient(buildInnerClient().getDeviceUpdates()));
return new DeviceUpdateClient(buildInnerClient().getDeviceUpdates());
}
}
Loading