Skip to content
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

mgmt azure-json, migration for azure-resourcemanager-compute #41407

Merged
merged 7 commits into from
Aug 6, 2024
Merged
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion sdk/resourcemanager/api-specs.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"dir": "azure-resourcemanager-compute",
"source": "specification/compute/resource-manager/readme.md",
"package": "com.azure.resourcemanager.compute",
"args": "--tag=package-2024-03-02 --modelerfour.lenient-model-deduplication=true --rename-model=UserAssignedIdentitiesValue:VirtualMachineIdentityUserAssignedIdentities,VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue:VirtualMachineScaleSetIdentityUserAssignedIdentities --preserve-model=AvailabilitySetSkuTypes --remove-inner=StorageProfile --stream-style-serialization=false"
"args": "--tag=package-2024-03-02 --modelerfour.lenient-model-deduplication=true --rename-model=UserAssignedIdentitiesValue:VirtualMachineIdentityUserAssignedIdentities,VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue:VirtualMachineScaleSetIdentityUserAssignedIdentities --preserve-model=AvailabilitySetSkuTypes --remove-inner=StorageProfile"
},
"compute-hybrid": {
"dir": "../resourcemanagerhybrid/azure-resourcemanager-compute",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

### Other Changes

- Replaced `Jackson` with `azure-json` for serialization/deserialization.

## 2.41.0 (2024-07-25)

### Breaking Changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,25 @@
package com.azure.resourcemanager.compute.fluent.models;

import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;

/**
* A disk access SAS uri.
*/
@Immutable
public final class AccessUriInner {
public final class AccessUriInner implements JsonSerializable<AccessUriInner> {
/*
* A SAS uri for accessing a disk.
*/
@JsonProperty(value = "accessSAS", access = JsonProperty.Access.WRITE_ONLY)
private String accessSas;

/*
* A SAS uri for accessing a VM guest state.
*/
@JsonProperty(value = "securityDataAccessSAS", access = JsonProperty.Access.WRITE_ONLY)
private String securityDataAccessSas;

/**
Expand Down Expand Up @@ -55,4 +57,41 @@ public String securityDataAccessSas() {
*/
public void validate() {
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
return jsonWriter.writeEndObject();
}

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

if ("accessSAS".equals(fieldName)) {
deserializedAccessUriInner.accessSas = reader.getString();
} else if ("securityDataAccessSAS".equals(fieldName)) {
deserializedAccessUriInner.securityDataAccessSas = reader.getString();
} else {
reader.skipChildren();
}
}

return deserializedAccessUriInner;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@
import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.management.SubResource;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.compute.models.InstanceViewStatus;
import com.azure.resourcemanager.compute.models.Sku;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.util.List;
import java.util.Map;

Expand All @@ -27,17 +30,30 @@ public final class AvailabilitySetInner extends Resource {
/*
* The instance view of a resource.
*/
@JsonProperty(value = "properties")
private AvailabilitySetProperties innerProperties;

/*
* Sku of the availability set, only name is required to be set. See AvailabilitySetSkuTypes for possible set of
* values. Use 'Aligned' for virtual machines with managed disks and 'Classic' for virtual machines with unmanaged
* disks. Default value is 'Classic'.
*/
@JsonProperty(value = "sku")
private Sku sku;

/*
* 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 AvailabilitySetInner class.
*/
Expand Down Expand Up @@ -77,6 +93,36 @@ public AvailabilitySetInner withSku(Sku sku) {
return this;
}

/**
* 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 @@ -211,4 +257,57 @@ public void validate() {
sku().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.innerProperties);
jsonWriter.writeJsonField("sku", this.sku);
return jsonWriter.writeEndObject();
}

/**
* Reads an instance of AvailabilitySetInner from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of AvailabilitySetInner 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 AvailabilitySetInner.
*/
public static AvailabilitySetInner fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
AvailabilitySetInner deserializedAvailabilitySetInner = new AvailabilitySetInner();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();

if ("id".equals(fieldName)) {
deserializedAvailabilitySetInner.id = reader.getString();
} else if ("name".equals(fieldName)) {
deserializedAvailabilitySetInner.name = reader.getString();
} else if ("type".equals(fieldName)) {
deserializedAvailabilitySetInner.type = reader.getString();
} else if ("location".equals(fieldName)) {
deserializedAvailabilitySetInner.withLocation(reader.getString());
} else if ("tags".equals(fieldName)) {
Map<String, String> tags = reader.readMap(reader1 -> reader1.getString());
deserializedAvailabilitySetInner.withTags(tags);
} else if ("properties".equals(fieldName)) {
deserializedAvailabilitySetInner.innerProperties = AvailabilitySetProperties.fromJson(reader);
} else if ("sku".equals(fieldName)) {
deserializedAvailabilitySetInner.sku = Sku.fromJson(reader);
} else {
reader.skipChildren();
}
}

return deserializedAvailabilitySetInner;
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,43 @@

import com.azure.core.annotation.Fluent;
import com.azure.core.management.SubResource;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.compute.models.InstanceViewStatus;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.IOException;
import java.util.List;

/**
* The instance view of a resource.
*/
@Fluent
public final class AvailabilitySetProperties {
public final class AvailabilitySetProperties implements JsonSerializable<AvailabilitySetProperties> {
/*
* Update Domain count.
*/
@JsonProperty(value = "platformUpdateDomainCount")
private Integer platformUpdateDomainCount;

/*
* Fault Domain count.
*/
@JsonProperty(value = "platformFaultDomainCount")
private Integer platformFaultDomainCount;

/*
* A list of references to all virtual machines in the availability set.
*/
@JsonProperty(value = "virtualMachines")
private List<SubResource> virtualMachines;

/*
* Specifies information about the proximity placement group that the availability set should be assigned to.
* Minimum api-version: 2018-04-01.
*/
@JsonProperty(value = "proximityPlacementGroup")
private SubResource proximityPlacementGroup;

/*
* The resource status information.
*/
@JsonProperty(value = "statuses", access = JsonProperty.Access.WRITE_ONLY)
private List<InstanceViewStatus> statuses;

/**
Expand Down Expand Up @@ -153,4 +152,57 @@ public void validate() {
statuses().forEach(e -> e.validate());
}
}

/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeNumberField("platformUpdateDomainCount", this.platformUpdateDomainCount);
jsonWriter.writeNumberField("platformFaultDomainCount", this.platformFaultDomainCount);
jsonWriter.writeArrayField("virtualMachines", this.virtualMachines,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeJsonField("proximityPlacementGroup", this.proximityPlacementGroup);
return jsonWriter.writeEndObject();
}

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

if ("platformUpdateDomainCount".equals(fieldName)) {
deserializedAvailabilitySetProperties.platformUpdateDomainCount
= reader.getNullable(JsonReader::getInt);
} else if ("platformFaultDomainCount".equals(fieldName)) {
deserializedAvailabilitySetProperties.platformFaultDomainCount
= reader.getNullable(JsonReader::getInt);
} else if ("virtualMachines".equals(fieldName)) {
List<SubResource> virtualMachines = reader.readArray(reader1 -> SubResource.fromJson(reader1));
deserializedAvailabilitySetProperties.virtualMachines = virtualMachines;
} else if ("proximityPlacementGroup".equals(fieldName)) {
deserializedAvailabilitySetProperties.proximityPlacementGroup = SubResource.fromJson(reader);
} else if ("statuses".equals(fieldName)) {
List<InstanceViewStatus> statuses
= reader.readArray(reader1 -> InstanceViewStatus.fromJson(reader1));
deserializedAvailabilitySetProperties.statuses = statuses;
} else {
reader.skipChildren();
}
}

return deserializedAvailabilitySetProperties;
});
}
}
Loading
Loading