Skip to content

[AutoPR azure-resourcemanager-largeinstance] Updated typespecs for sdk gen testing #11615

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 (2024-08-09)

- Azure Resource Manager Large Instance client library for Java. This package contains Microsoft Azure SDK for Large Instance Management SDK. The AzureLargeInstance Management client. Package tag package-2023-07-20-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
13 changes: 5 additions & 8 deletions sdk/largeinstance/azure-resourcemanager-largeinstance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Various documentation is available to help you get started
<dependency>
<groupId>com.azure.resourcemanager</groupId>
<artifactId>azure-resourcemanager-largeinstance</artifactId>
<version>1.0.0-beta.1</version>
<version>1.0.0-beta.2</version>
</dependency>
```
[//]: # ({x-version-update-end})
Expand All @@ -45,15 +45,11 @@ Azure Management Libraries require a `TokenCredential` implementation for authen

### Authentication

By default, Microsoft Entra ID token authentication depends on correct configuration of the following environment variables.
Microsoft Entra ID token authentication relies on the [credential class][azure_identity_credentials] from [Azure Identity][azure_identity] package.

- `AZURE_CLIENT_ID` for Azure client ID.
- `AZURE_TENANT_ID` for Azure tenant ID.
- `AZURE_CLIENT_SECRET` or `AZURE_CLIENT_CERTIFICATE_PATH` for client secret or client certificate.
Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

In addition, Azure subscription ID can be configured via `AZURE_SUBSCRIPTION_ID` environment variable.

With above configuration, `azure` client can be authenticated using the following code:
Assuming the use of the `DefaultAzureCredential` credential class, the client can be authenticated using the following code:

```java
AzureProfile profile = new AzureProfile(AzureEnvironment.AZURE);
Expand Down Expand Up @@ -97,6 +93,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m
[jdk]: https://learn.microsoft.com/azure/developer/java/fundamentals/
[azure_subscription]: https://azure.microsoft.com/free/
[azure_identity]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/identity/azure-identity
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/identity/azure-identity#credentials
[azure_core_http_netty]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core-http-netty
[authenticate]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/AUTH.md
[design]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/resourcemanager/docs/DESIGN.md
Expand Down
30 changes: 16 additions & 14 deletions sdk/largeinstance/azure-resourcemanager-largeinstance/SAMPLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ public final class AzureLargeInstanceGetByResourceGroupSamples {
* @param manager Entry point to LargeInstanceManager.
*/
public static void azureLargeInstanceGet(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeInstances().getByResourceGroupWithResponse("myResourceGroup", "myAzureLargeInstance",
com.azure.core.util.Context.NONE);
manager.azureLargeInstances()
.getByResourceGroupWithResponse("myResourceGroup", "myAzureLargeInstance",
com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -112,8 +113,8 @@ public final class AzureLargeInstanceRestartSamples {
* @param manager Entry point to LargeInstanceManager.
*/
public static void azureLargeInstanceRestart(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeInstances().restart("myResourceGroup", "myALInstance", null,
com.azure.core.util.Context.NONE);
manager.azureLargeInstances()
.restart("myResourceGroup", "myALInstance", null, com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -185,8 +186,8 @@ public final class AzureLargeInstanceUpdateSamples {
*/
public static void
azureLargeInstanceUpdateTag(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeInstances().updateWithResponse("myResourceGroup", "myALInstance", null,
com.azure.core.util.Context.NONE);
manager.azureLargeInstances()
.updateWithResponse("myResourceGroup", "myALInstance", null, com.azure.core.util.Context.NONE);
}

/*
Expand All @@ -201,8 +202,8 @@ public final class AzureLargeInstanceUpdateSamples {
*/
public static void
azureLargeInstanceDeleteTag(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeInstances().updateWithResponse("myResourceGroup", "myALInstance", null,
com.azure.core.util.Context.NONE);
manager.azureLargeInstances()
.updateWithResponse("myResourceGroup", "myALInstance", null, com.azure.core.util.Context.NONE);
}
}
```
Expand All @@ -226,8 +227,9 @@ public final class AzureLargeStorageInstanceGetByResourceGroupSamples {
*/
public static void
azureLargeStorageInstanceGet(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeStorageInstances().getByResourceGroupWithResponse("myResourceGroup",
"myAzureLargeStorageInstance", com.azure.core.util.Context.NONE);
manager.azureLargeStorageInstances()
.getByResourceGroupWithResponse("myResourceGroup", "myAzureLargeStorageInstance",
com.azure.core.util.Context.NONE);
}
}
```
Expand Down Expand Up @@ -300,8 +302,8 @@ public final class AzureLargeStorageInstanceUpdateSamples {
*/
public static void
azureLargeStorageInstanceDeleteTag(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeStorageInstances().updateWithResponse("myResourceGroup", "myALSInstance", null,
com.azure.core.util.Context.NONE);
manager.azureLargeStorageInstances()
.updateWithResponse("myResourceGroup", "myALSInstance", null, com.azure.core.util.Context.NONE);
}

/*
Expand All @@ -316,8 +318,8 @@ public final class AzureLargeStorageInstanceUpdateSamples {
*/
public static void
azureLargeStorageInstanceUpdateTag(com.azure.resourcemanager.largeinstance.LargeInstanceManager manager) {
manager.azureLargeStorageInstances().updateWithResponse("myResourceGroup", "myALSInstance", null,
com.azure.core.util.Context.NONE);
manager.azureLargeStorageInstances()
.updateWithResponse("myResourceGroup", "myALSInstance", null, com.azure.core.util.Context.NONE);
}
}
```
Expand Down
5 changes: 5 additions & 0 deletions sdk/largeinstance/azure-resourcemanager-largeinstance/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<revapi.skip>true</revapi.skip>
</properties>
<dependencies>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-json</artifactId>
<version>1.2.0</version> <!-- {x-version-update;com.azure:azure-json;dependency} -->
</dependency>
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
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.HttpLogOptions;
import com.azure.core.http.policy.HttpPipelinePolicy;
import com.azure.core.http.policy.HttpPolicyProviders;
import com.azure.core.http.policy.RequestIdPolicy;
Expand Down Expand Up @@ -55,8 +55,10 @@ private LargeInstanceManager(HttpPipeline httpPipeline, AzureProfile profile, Du
Objects.requireNonNull(httpPipeline, "'httpPipeline' cannot be null.");
Objects.requireNonNull(profile, "'profile' cannot be null.");
this.clientObject = new LargeInstanceMgmtClientBuilder().pipeline(httpPipeline)
.endpoint(profile.getEnvironment().getResourceManagerEndpoint()).subscriptionId(profile.getSubscriptionId())
.defaultPollInterval(defaultPollInterval).buildClient();
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.defaultPollInterval(defaultPollInterval)
.buildClient();
}

/**
Expand Down Expand Up @@ -207,12 +209,19 @@ public LargeInstanceManager authenticate(TokenCredential credential, AzureProfil
Objects.requireNonNull(profile, "'profile' cannot be null.");

StringBuilder userAgentBuilder = new StringBuilder();
userAgentBuilder.append("azsdk-java").append("-").append("com.azure.resourcemanager.largeinstance")
.append("/").append("1.0.0-beta.1");
userAgentBuilder.append("azsdk-java")
.append("-")
.append("com.azure.resourcemanager.largeinstance")
.append("/")
.append("1.0.0-beta.1");
if (!Configuration.getGlobalConfiguration().get("AZURE_TELEMETRY_DISABLED", false)) {
userAgentBuilder.append(" (").append(Configuration.getGlobalConfiguration().get("java.version"))
.append("; ").append(Configuration.getGlobalConfiguration().get("os.name")).append("; ")
.append(Configuration.getGlobalConfiguration().get("os.version")).append("; auto-generated)");
userAgentBuilder.append(" (")
.append(Configuration.getGlobalConfiguration().get("java.version"))
.append("; ")
.append(Configuration.getGlobalConfiguration().get("os.name"))
.append("; ")
.append(Configuration.getGlobalConfiguration().get("os.version"))
.append("; auto-generated)");
} else {
userAgentBuilder.append(" (auto-generated)");
}
Expand All @@ -231,18 +240,21 @@ public LargeInstanceManager authenticate(TokenCredential credential, AzureProfil
policies.add(new UserAgentPolicy(userAgentBuilder.toString()));
policies.add(new AddHeadersFromContextPolicy());
policies.add(new RequestIdPolicy());
policies.addAll(this.policies.stream().filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
policies.addAll(this.policies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_CALL)
.collect(Collectors.toList()));
HttpPolicyProviders.addBeforeRetryPolicies(policies);
policies.add(retryPolicy);
policies.add(new AddDatePolicy());
policies.add(new ArmChallengeAuthenticationPolicy(credential, scopes.toArray(new String[0])));
policies.addAll(this.policies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY).collect(Collectors.toList()));
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.collect(Collectors.toList()));
HttpPolicyProviders.addAfterRetryPolicies(policies);
policies.add(new HttpLoggingPolicy(httpLogOptions));
HttpPipeline httpPipeline = new HttpPipelineBuilder().httpClient(httpClient)
.policies(policies.toArray(new HttpPipelinePolicy[0])).build();
.policies(policies.toArray(new HttpPipelinePolicy[0]))
.build();
return new LargeInstanceManager(httpPipeline, profile, defaultPollInterval);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@
import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.management.SystemData;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.largeinstance.models.AzureLargeInstanceProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.util.Map;

/**
Expand All @@ -20,15 +23,28 @@ public final class AzureLargeInstanceInner extends Resource {
/*
* The resource-specific properties for this resource.
*/
@JsonProperty(value = "properties")
private AzureLargeInstanceProperties properties;

/*
* Azure Resource Manager metadata containing createdBy and modifiedBy information.
*/
@JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
private SystemData systemData;

/*
* Fully qualified resource Id for the resource.
*/
private String id;

/*
* The name of the resource.
*/
private String name;

/*
* The type of the resource.
*/
private String type;

/**
* Creates an instance of AzureLargeInstanceInner class.
*/
Expand Down Expand Up @@ -64,6 +80,36 @@ public SystemData systemData() {
return this.systemData;
}

/**
* Get the id property: Fully qualified resource Id for the resource.
*
* @return the id value.
*/
@Override
public String id() {
return this.id;
}

/**
* Get the name property: The name of the resource.
*
* @return the name value.
*/
@Override
public String name() {
return this.name;
}

/**
* Get the type property: The type of the resource.
*
* @return the type value.
*/
@Override
public String type() {
return this.type;
}

/**
* {@inheritDoc}
*/
Expand Down Expand Up @@ -92,4 +138,56 @@ public void validate() {
properties().validate();
}
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("location", location());
jsonWriter.writeMapField("tags", tags(), (writer, element) -> writer.writeString(element));
jsonWriter.writeJsonField("properties", this.properties);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of AzureLargeInstanceInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AzureLargeInstanceInner if the JsonReader was pointing to an instance of it, or null if it
* was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the AzureLargeInstanceInner.
*/
public static AzureLargeInstanceInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AzureLargeInstanceInner deserializedAzureLargeInstanceInner = new AzureLargeInstanceInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("id".equals(fieldName)) {
deserializedAzureLargeInstanceInner.id = reader.getString();
} else if ("name".equals(fieldName)) {
deserializedAzureLargeInstanceInner.name = reader.getString();
} else if ("type".equals(fieldName)) {
deserializedAzureLargeInstanceInner.type = reader.getString();
} else if ("location".equals(fieldName)) {
deserializedAzureLargeInstanceInner.withLocation(reader.getString());
} else if ("tags".equals(fieldName)) {
Map<String, String> tags = reader.readMap(reader1 -> reader1.getString());
deserializedAzureLargeInstanceInner.withTags(tags);
} else if ("properties".equals(fieldName)) {
deserializedAzureLargeInstanceInner.properties = AzureLargeInstanceProperties.fromJson(reader);
} else if ("systemData".equals(fieldName)) {
deserializedAzureLargeInstanceInner.systemData = SystemData.fromJson(reader);
} else {
reader.skipChildren();
}
}

return deserializedAzureLargeInstanceInner;
});
}
}
Loading