com.azure.resourcemanager.databoxedge.models.Authentication Maven / Gradle / Ivy
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.databoxedge.models;
import com.azure.core.annotation.Fluent;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
/**
* Authentication mechanism for IoT devices.
*/
@Fluent
public final class Authentication implements JsonSerializable {
/*
* Symmetric key for authentication.
*/
private SymmetricKey symmetricKey;
/**
* Creates an instance of Authentication class.
*/
public Authentication() {
}
/**
* Get the symmetricKey property: Symmetric key for authentication.
*
* @return the symmetricKey value.
*/
public SymmetricKey symmetricKey() {
return this.symmetricKey;
}
/**
* Set the symmetricKey property: Symmetric key for authentication.
*
* @param symmetricKey the symmetricKey value to set.
* @return the Authentication object itself.
*/
public Authentication withSymmetricKey(SymmetricKey symmetricKey) {
this.symmetricKey = symmetricKey;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (symmetricKey() != null) {
symmetricKey().validate();
}
}
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("symmetricKey", this.symmetricKey);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of Authentication from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of Authentication 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 Authentication.
*/
public static Authentication fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
Authentication deserializedAuthentication = new Authentication();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("symmetricKey".equals(fieldName)) {
deserializedAuthentication.symmetricKey = SymmetricKey.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedAuthentication;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy