Skip to content

Commit

Permalink
CodeGen from PR 18918 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
updated examples, resource name description (Azure#18918)
  • Loading branch information
SDKAuto committed May 7, 2022
1 parent 4f4d399 commit c378ff1
Show file tree
Hide file tree
Showing 43 changed files with 1,292 additions and 412 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Release History

## 1.0.0-beta.2 (Unreleased)
## 1.0.0-beta.1 (2022-05-07)

- Azure Resource Manager LoadTest client library for Java. This package contains Microsoft Azure SDK for LoadTest Management SDK. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2022-04-15-preview. For documentation on how to use this package, please see [Azure Management Libraries for Java](https://aka.ms/azsdk/java/mgmt).

### Features Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Azure Resource Manager LoadTest client library for Java.

This package contains Microsoft Azure SDK for LoadTest Management SDK. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2021-12-01-preview. 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 LoadTest Management SDK. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2022-04-15-preview. 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

Expand Down Expand Up @@ -32,7 +32,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-loadtestservice</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand Down
69 changes: 59 additions & 10 deletions sdk/loadtestservice/azure-resourcemanager-loadtestservice/SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,19 @@
### LoadTests_CreateOrUpdate

```java
import com.azure.resourcemanager.loadtestservice.models.EncryptionProperties;
import com.azure.resourcemanager.loadtestservice.models.EncryptionPropertiesIdentity;
import com.azure.resourcemanager.loadtestservice.models.ManagedServiceIdentity;
import com.azure.resourcemanager.loadtestservice.models.ManagedServiceIdentityType;
import com.azure.resourcemanager.loadtestservice.models.Type;
import com.azure.resourcemanager.loadtestservice.models.UserAssignedIdentity;
import java.util.HashMap;
import java.util.Map;

/** Samples for LoadTests CreateOrUpdate. */
public final class LoadTestsCreateOrUpdateSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_CreateOrUpdate.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_CreateOrUpdate.json
*/
/**
* Sample code: LoadTests_CreateOrUpdate.
Expand All @@ -36,7 +42,22 @@ public final class LoadTestsCreateOrUpdateSamples {
.withRegion("westus")
.withExistingResourceGroup("dummyrg")
.withTags(mapOf("Team", "Dev Exp"))
.withIdentity(
new ManagedServiceIdentity()
.withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(
mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1",
new UserAssignedIdentity())))
.withDescription("This is new load test resource")
.withEncryption(
new EncryptionProperties()
.withIdentity(
new EncryptionPropertiesIdentity()
.withType(Type.USER_ASSIGNED)
.withResourceId(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"))
.withKeyUrl("https://dummy.vault.azure.net/keys/dummykey1"))
.create();
}

Expand All @@ -61,7 +82,7 @@ import com.azure.core.util.Context;
/** Samples for LoadTests Delete. */
public final class LoadTestsDeleteSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Delete.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_Delete.json
*/
/**
* Sample code: LoadTests_Delete.
Expand All @@ -82,7 +103,7 @@ import com.azure.core.util.Context;
/** Samples for LoadTests GetByResourceGroup. */
public final class LoadTestsGetByResourceGroupSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Get.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_Get.json
*/
/**
* Sample code: LoadTests_Get.
Expand All @@ -103,7 +124,7 @@ import com.azure.core.util.Context;
/** Samples for LoadTests List. */
public final class LoadTestsListSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListBySubscription.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_ListBySubscription.json
*/
/**
* Sample code: LoadTests_ListBySubscription.
Expand All @@ -124,7 +145,7 @@ import com.azure.core.util.Context;
/** Samples for LoadTests ListByResourceGroup. */
public final class LoadTestsListByResourceGroupSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListByResourceGroup.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_ListByResourceGroup.json
*/
/**
* Sample code: LoadTests_ListByResourceGroup.
Expand All @@ -143,14 +164,21 @@ public final class LoadTestsListByResourceGroupSamples {
import com.azure.core.management.serializer.SerializerFactory;
import com.azure.core.util.Context;
import com.azure.core.util.serializer.SerializerEncoding;
import com.azure.resourcemanager.loadtestservice.models.EncryptionProperties;
import com.azure.resourcemanager.loadtestservice.models.EncryptionPropertiesIdentity;
import com.azure.resourcemanager.loadtestservice.models.LoadTestResource;
import com.azure.resourcemanager.loadtestservice.models.LoadTestResourcePatchRequestBodyProperties;
import com.azure.resourcemanager.loadtestservice.models.ManagedServiceIdentity;
import com.azure.resourcemanager.loadtestservice.models.ManagedServiceIdentityType;
import com.azure.resourcemanager.loadtestservice.models.Type;
import com.azure.resourcemanager.loadtestservice.models.UserAssignedIdentity;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/** Samples for LoadTests Update. */
public final class LoadTestsUpdateSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Update.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/LoadTests_Update.json
*/
/**
* Sample code: LoadTests_Update.
Expand All @@ -167,10 +195,31 @@ public final class LoadTestsUpdateSamples {
SerializerFactory
.createDefaultManagementSerializerAdapter()
.deserialize("{\"Division\":\"LT\",\"Team\":\"Dev Exp\"}", Object.class, SerializerEncoding.JSON))
.withProperties(
new LoadTestResourcePatchRequestBodyProperties().withDescription("This is new load test resource"))
.withIdentity(
new ManagedServiceIdentity()
.withType(ManagedServiceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)
.withUserAssignedIdentities(
mapOf(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1",
new UserAssignedIdentity())))
.withDescription("This is new load test resource")
.withEncryption(
new EncryptionProperties()
.withIdentity(new EncryptionPropertiesIdentity().withType(Type.SYSTEM_ASSIGNED))
.withKeyUrl("https://dummy.vault.azure.net/keys/dummykey1"))
.apply();
}

@SuppressWarnings("unchecked")
private static <T> Map<String, T> mapOf(Object... inputs) {
Map<String, T> map = new HashMap<>();
for (int i = 0; i < inputs.length; i += 2) {
String key = (String) inputs[i];
T value = (T) inputs[i + 1];
map.put(key, value);
}
return map;
}
}
```

Expand All @@ -182,7 +231,7 @@ import com.azure.core.util.Context;
/** Samples for Operations List. */
public final class OperationsListSamples {
/*
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/Operations_List.json
* x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2022-04-15-preview/examples/Operations_List.json
*/
/**
* Sample code: Operations_List.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<packaging>jar</packaging>

<name>Microsoft Azure SDK for LoadTest Management</name>
<description>This package contains Microsoft Azure SDK for LoadTest Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2021-12-01-preview.</description>
<description>This package contains Microsoft Azure SDK for LoadTest Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. LoadTest client provides access to LoadTest Resource and it's status operations. Package tag package-2022-04-15-preview.</description>
<url>https://github.com/Azure/azure-sdk-for-java</url>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
import com.azure.core.http.HttpPipelineBuilder;
import com.azure.core.http.HttpPipelinePosition;
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
import com.azure.core.http.policy.RetryOptions;
import com.azure.core.http.policy.RetryPolicy;
import com.azure.core.http.policy.UserAgentPolicy;
import com.azure.core.management.http.policy.ArmChallengeAuthenticationPolicy;
Expand Down Expand Up @@ -67,6 +69,19 @@ public static LoadTestManager authenticate(TokenCredential credential, AzureProf
return configure().authenticate(credential, profile);
}

/**
* Creates an instance of LoadTest service API entry point.
*
* @param httpPipeline the {@link HttpPipeline} configured with Azure authentication credential.
* @param profile the Azure profile for client.
* @return the LoadTest service API instance.
*/
public static LoadTestManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
return new LoadTestManager(httpPipeline, profile, null);
}

/**
* Gets a Configurable instance that can be used to create LoadTestManager with optional configuration.
*
Expand All @@ -78,13 +93,14 @@ public static Configurable configure() {

/** The Configurable allowing configurations to be set. */
public static final class Configurable {
private final ClientLogger logger = new ClientLogger(Configurable.class);
private static final ClientLogger LOGGER = new ClientLogger(Configurable.class);

private HttpClient httpClient;
private HttpLogOptions httpLogOptions;
private final List<HttpPipelinePolicy> policies = new ArrayList<>();
private final List<String> scopes = new ArrayList<>();
private RetryPolicy retryPolicy;
private RetryOptions retryOptions;
private Duration defaultPollInterval;

private Configurable() {
Expand Down Expand Up @@ -145,16 +161,31 @@ public Configurable withRetryPolicy(RetryPolicy retryPolicy) {
return this;
}

/**
* Sets the retry options for the HTTP pipeline retry policy.
*
* <p>This setting has no effect, if retry policy is set via {@link #withRetryPolicy(RetryPolicy)}.
*
* @param retryOptions the retry options for the HTTP pipeline retry policy.
* @return the configurable object itself.
*/
public Configurable withRetryOptions(RetryOptions retryOptions) {
this.retryOptions = Objects.requireNonNull(retryOptions, "'retryOptions' cannot be null.");
return this;
}

/**
* Sets the default poll interval, used when service does not provide "Retry-After" header.
*
* @param defaultPollInterval the default poll interval.
* @return the configurable object itself.
*/
public Configurable withDefaultPollInterval(Duration defaultPollInterval) {
this.defaultPollInterval = Objects.requireNonNull(defaultPollInterval, "'retryPolicy' cannot be null.");
this.defaultPollInterval =
Objects.requireNonNull(defaultPollInterval, "'defaultPollInterval' cannot be null.");
if (this.defaultPollInterval.isNegative()) {
throw logger.logExceptionAsError(new IllegalArgumentException("'httpPipeline' cannot be negative"));
throw LOGGER
.logExceptionAsError(new IllegalArgumentException("'defaultPollInterval' cannot be negative"));
}
return this;
}
Expand Down Expand Up @@ -194,10 +225,15 @@ public LoadTestManager authenticate(TokenCredential credential, AzureProfile pro
scopes.add(profile.getEnvironment().getManagementEndpoint() + "/.default");
}
if (retryPolicy == null) {
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
if (retryOptions != null) {
retryPolicy = new RetryPolicy(retryOptions);
} else {
retryPolicy = new RetryPolicy("Retry-After", ChronoUnit.SECONDS);
}
}
List<HttpPipelinePolicy> policies = new ArrayList<>();
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
policies.add(new AddHeadersFromContextPolicy());
policies.add(new RequestIdPolicy());
policies
.addAll(
Expand Down Expand Up @@ -228,15 +264,23 @@ public LoadTestManager authenticate(TokenCredential credential, AzureProfile pro
}
}

/** @return Resource collection API of Operations. */
/**
* Gets the resource collection API of Operations.
*
* @return Resource collection API of Operations.
*/
public Operations operations() {
if (this.operations == null) {
this.operations = new OperationsImpl(clientObject.getOperations(), this);
}
return operations;
}

/** @return Resource collection API of LoadTests. */
/**
* Gets the resource collection API of LoadTests.
*
* @return Resource collection API of LoadTests.
*/
public LoadTests loadTests() {
if (this.loadTests == null) {
this.loadTests = new LoadTestsImpl(clientObject.getLoadTests(), this);
Expand Down
Loading

0 comments on commit c378ff1

Please sign in to comment.