com.azure.security.keyvault.certificates.implementation.models.LifetimeAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-security-keyvault-certificates Show documentation
Show all versions of azure-security-keyvault-certificates Show documentation
This module contains client library for Microsoft Azure KeyVault Certificates.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.security.keyvault.certificates.implementation.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;
/** Action and its trigger that will be performed by Key Vault over the lifetime of a certificate. */
@Fluent
public final class LifetimeAction implements JsonSerializable {
/*
* The condition that will execute the action.
*/
private Trigger trigger;
/*
* The action that will be executed.
*/
private Action action;
/** Creates an instance of LifetimeAction class. */
public LifetimeAction() {}
/**
* Get the trigger property: The condition that will execute the action.
*
* @return the trigger value.
*/
public Trigger getTrigger() {
return this.trigger;
}
/**
* Set the trigger property: The condition that will execute the action.
*
* @param trigger the trigger value to set.
* @return the LifetimeAction object itself.
*/
public LifetimeAction setTrigger(Trigger trigger) {
this.trigger = trigger;
return this;
}
/**
* Get the action property: The action that will be executed.
*
* @return the action value.
*/
public Action getAction() {
return this.action;
}
/**
* Set the action property: The action that will be executed.
*
* @param action the action value to set.
* @return the LifetimeAction object itself.
*/
public LifetimeAction setAction(Action action) {
this.action = action;
return this;
}
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeJsonField("trigger", this.trigger);
jsonWriter.writeJsonField("action", this.action);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of LifetimeAction from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of LifetimeAction 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 LifetimeAction.
*/
public static LifetimeAction fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(
reader -> {
LifetimeAction deserializedLifetimeAction = new LifetimeAction();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("trigger".equals(fieldName)) {
deserializedLifetimeAction.trigger = Trigger.fromJson(reader);
} else if ("action".equals(fieldName)) {
deserializedLifetimeAction.action = Action.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedLifetimeAction;
});
}
}