|
| 1 | +// Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | +// Licensed under the MIT License. |
| 3 | +// Code generated by Microsoft (R) TypeSpec Code Generator. |
| 4 | + |
| 5 | +package com.azure.resourcemanager.computeschedule.fluent.models; |
| 6 | + |
| 7 | +import com.azure.core.annotation.Immutable; |
| 8 | +import com.azure.core.util.logging.ClientLogger; |
| 9 | +import com.azure.json.JsonReader; |
| 10 | +import com.azure.json.JsonSerializable; |
| 11 | +import com.azure.json.JsonToken; |
| 12 | +import com.azure.json.JsonWriter; |
| 13 | +import com.azure.resourcemanager.computeschedule.models.ResourceOperation; |
| 14 | +import java.io.IOException; |
| 15 | +import java.util.List; |
| 16 | + |
| 17 | +/** |
| 18 | + * The response from a create request. |
| 19 | + */ |
| 20 | +@Immutable |
| 21 | +public final class CreateResourceOperationResponseInner |
| 22 | + implements JsonSerializable<CreateResourceOperationResponseInner> { |
| 23 | + /* |
| 24 | + * The description of the operation response |
| 25 | + */ |
| 26 | + private String description; |
| 27 | + |
| 28 | + /* |
| 29 | + * The type of resources used in the create request eg virtual machines |
| 30 | + */ |
| 31 | + private String type; |
| 32 | + |
| 33 | + /* |
| 34 | + * The location of the start request eg westus |
| 35 | + */ |
| 36 | + private String location; |
| 37 | + |
| 38 | + /* |
| 39 | + * The results from the start request if no errors exist |
| 40 | + */ |
| 41 | + private List<ResourceOperation> results; |
| 42 | + |
| 43 | + /** |
| 44 | + * Creates an instance of CreateResourceOperationResponseInner class. |
| 45 | + */ |
| 46 | + private CreateResourceOperationResponseInner() { |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Get the description property: The description of the operation response. |
| 51 | + * |
| 52 | + * @return the description value. |
| 53 | + */ |
| 54 | + public String description() { |
| 55 | + return this.description; |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Get the type property: The type of resources used in the create request eg virtual machines. |
| 60 | + * |
| 61 | + * @return the type value. |
| 62 | + */ |
| 63 | + public String type() { |
| 64 | + return this.type; |
| 65 | + } |
| 66 | + |
| 67 | + /** |
| 68 | + * Get the location property: The location of the start request eg westus. |
| 69 | + * |
| 70 | + * @return the location value. |
| 71 | + */ |
| 72 | + public String location() { |
| 73 | + return this.location; |
| 74 | + } |
| 75 | + |
| 76 | + /** |
| 77 | + * Get the results property: The results from the start request if no errors exist. |
| 78 | + * |
| 79 | + * @return the results value. |
| 80 | + */ |
| 81 | + public List<ResourceOperation> results() { |
| 82 | + return this.results; |
| 83 | + } |
| 84 | + |
| 85 | + /** |
| 86 | + * Validates the instance. |
| 87 | + * |
| 88 | + * @throws IllegalArgumentException thrown if the instance is not valid. |
| 89 | + */ |
| 90 | + public void validate() { |
| 91 | + if (description() == null) { |
| 92 | + throw LOGGER.atError() |
| 93 | + .log(new IllegalArgumentException( |
| 94 | + "Missing required property description in model CreateResourceOperationResponseInner")); |
| 95 | + } |
| 96 | + if (type() == null) { |
| 97 | + throw LOGGER.atError() |
| 98 | + .log(new IllegalArgumentException( |
| 99 | + "Missing required property type in model CreateResourceOperationResponseInner")); |
| 100 | + } |
| 101 | + if (location() == null) { |
| 102 | + throw LOGGER.atError() |
| 103 | + .log(new IllegalArgumentException( |
| 104 | + "Missing required property location in model CreateResourceOperationResponseInner")); |
| 105 | + } |
| 106 | + if (results() != null) { |
| 107 | + results().forEach(e -> e.validate()); |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + private static final ClientLogger LOGGER = new ClientLogger(CreateResourceOperationResponseInner.class); |
| 112 | + |
| 113 | + /** |
| 114 | + * {@inheritDoc} |
| 115 | + */ |
| 116 | + @Override |
| 117 | + public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { |
| 118 | + jsonWriter.writeStartObject(); |
| 119 | + jsonWriter.writeStringField("description", this.description); |
| 120 | + jsonWriter.writeStringField("type", this.type); |
| 121 | + jsonWriter.writeStringField("location", this.location); |
| 122 | + jsonWriter.writeArrayField("results", this.results, (writer, element) -> writer.writeJson(element)); |
| 123 | + return jsonWriter.writeEndObject(); |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Reads an instance of CreateResourceOperationResponseInner from the JsonReader. |
| 128 | + * |
| 129 | + * @param jsonReader The JsonReader being read. |
| 130 | + * @return An instance of CreateResourceOperationResponseInner if the JsonReader was pointing to an instance of it, |
| 131 | + * or null if it was pointing to JSON null. |
| 132 | + * @throws IllegalStateException If the deserialized JSON object was missing any required properties. |
| 133 | + * @throws IOException If an error occurs while reading the CreateResourceOperationResponseInner. |
| 134 | + */ |
| 135 | + public static CreateResourceOperationResponseInner fromJson(JsonReader jsonReader) throws IOException { |
| 136 | + return jsonReader.readObject(reader -> { |
| 137 | + CreateResourceOperationResponseInner deserializedCreateResourceOperationResponseInner |
| 138 | + = new CreateResourceOperationResponseInner(); |
| 139 | + while (reader.nextToken() != JsonToken.END_OBJECT) { |
| 140 | + String fieldName = reader.getFieldName(); |
| 141 | + reader.nextToken(); |
| 142 | + |
| 143 | + if ("description".equals(fieldName)) { |
| 144 | + deserializedCreateResourceOperationResponseInner.description = reader.getString(); |
| 145 | + } else if ("type".equals(fieldName)) { |
| 146 | + deserializedCreateResourceOperationResponseInner.type = reader.getString(); |
| 147 | + } else if ("location".equals(fieldName)) { |
| 148 | + deserializedCreateResourceOperationResponseInner.location = reader.getString(); |
| 149 | + } else if ("results".equals(fieldName)) { |
| 150 | + List<ResourceOperation> results = reader.readArray(reader1 -> ResourceOperation.fromJson(reader1)); |
| 151 | + deserializedCreateResourceOperationResponseInner.results = results; |
| 152 | + } else { |
| 153 | + reader.skipChildren(); |
| 154 | + } |
| 155 | + } |
| 156 | + |
| 157 | + return deserializedCreateResourceOperationResponseInner; |
| 158 | + }); |
| 159 | + } |
| 160 | +} |
0 commit comments