com.azure.resourcemanager.automation.models.WebhookCreateOrUpdateParameters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-automation Show documentation
Show all versions of azure-resourcemanager-automation Show documentation
This package contains Microsoft Azure SDK for Automation Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. Automation Client. Package tag package-2022-02-22.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.automation.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonSerializable;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import com.azure.resourcemanager.automation.fluent.models.WebhookCreateOrUpdateProperties;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Map;
/**
* The parameters supplied to the create or update webhook operation.
*/
@Fluent
public final class WebhookCreateOrUpdateParameters implements JsonSerializable {
/*
* Gets or sets the name of the webhook.
*/
private String name;
/*
* Gets or sets the properties of the webhook.
*/
private WebhookCreateOrUpdateProperties innerProperties = new WebhookCreateOrUpdateProperties();
/**
* Creates an instance of WebhookCreateOrUpdateParameters class.
*/
public WebhookCreateOrUpdateParameters() {
}
/**
* Get the name property: Gets or sets the name of the webhook.
*
* @return the name value.
*/
public String name() {
return this.name;
}
/**
* Set the name property: Gets or sets the name of the webhook.
*
* @param name the name value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withName(String name) {
this.name = name;
return this;
}
/**
* Get the innerProperties property: Gets or sets the properties of the webhook.
*
* @return the innerProperties value.
*/
private WebhookCreateOrUpdateProperties innerProperties() {
return this.innerProperties;
}
/**
* Get the isEnabled property: Gets or sets the value of the enabled flag of webhook.
*
* @return the isEnabled value.
*/
public Boolean isEnabled() {
return this.innerProperties() == null ? null : this.innerProperties().isEnabled();
}
/**
* Set the isEnabled property: Gets or sets the value of the enabled flag of webhook.
*
* @param isEnabled the isEnabled value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withIsEnabled(Boolean isEnabled) {
if (this.innerProperties() == null) {
this.innerProperties = new WebhookCreateOrUpdateProperties();
}
this.innerProperties().withIsEnabled(isEnabled);
return this;
}
/**
* Get the uri property: Gets or sets the uri.
*
* @return the uri value.
*/
public String uri() {
return this.innerProperties() == null ? null : this.innerProperties().uri();
}
/**
* Set the uri property: Gets or sets the uri.
*
* @param uri the uri value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withUri(String uri) {
if (this.innerProperties() == null) {
this.innerProperties = new WebhookCreateOrUpdateProperties();
}
this.innerProperties().withUri(uri);
return this;
}
/**
* Get the expiryTime property: Gets or sets the expiry time.
*
* @return the expiryTime value.
*/
public OffsetDateTime expiryTime() {
return this.innerProperties() == null ? null : this.innerProperties().expiryTime();
}
/**
* Set the expiryTime property: Gets or sets the expiry time.
*
* @param expiryTime the expiryTime value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withExpiryTime(OffsetDateTime expiryTime) {
if (this.innerProperties() == null) {
this.innerProperties = new WebhookCreateOrUpdateProperties();
}
this.innerProperties().withExpiryTime(expiryTime);
return this;
}
/**
* Get the parameters property: Gets or sets the parameters of the job.
*
* @return the parameters value.
*/
public Map parameters() {
return this.innerProperties() == null ? null : this.innerProperties().parameters();
}
/**
* Set the parameters property: Gets or sets the parameters of the job.
*
* @param parameters the parameters value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withParameters(Map parameters) {
if (this.innerProperties() == null) {
this.innerProperties = new WebhookCreateOrUpdateProperties();
}
this.innerProperties().withParameters(parameters);
return this;
}
/**
* Get the runbook property: Gets or sets the runbook.
*
* @return the runbook value.
*/
public RunbookAssociationProperty runbook() {
return this.innerProperties() == null ? null : this.innerProperties().runbook();
}
/**
* Set the runbook property: Gets or sets the runbook.
*
* @param runbook the runbook value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withRunbook(RunbookAssociationProperty runbook) {
if (this.innerProperties() == null) {
this.innerProperties = new WebhookCreateOrUpdateProperties();
}
this.innerProperties().withRunbook(runbook);
return this;
}
/**
* Get the runOn property: Gets or sets the name of the hybrid worker group the webhook job will run on.
*
* @return the runOn value.
*/
public String runOn() {
return this.innerProperties() == null ? null : this.innerProperties().runOn();
}
/**
* Set the runOn property: Gets or sets the name of the hybrid worker group the webhook job will run on.
*
* @param runOn the runOn value to set.
* @return the WebhookCreateOrUpdateParameters object itself.
*/
public WebhookCreateOrUpdateParameters withRunOn(String runOn) {
if (this.innerProperties() == null) {
this.innerProperties = new WebhookCreateOrUpdateProperties();
}
this.innerProperties().withRunOn(runOn);
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
public void validate() {
if (name() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property name in model WebhookCreateOrUpdateParameters"));
}
if (innerProperties() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property innerProperties in model WebhookCreateOrUpdateParameters"));
} else {
innerProperties().validate();
}
}
private static final ClientLogger LOGGER = new ClientLogger(WebhookCreateOrUpdateParameters.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("name", this.name);
jsonWriter.writeJsonField("properties", this.innerProperties);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of WebhookCreateOrUpdateParameters from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of WebhookCreateOrUpdateParameters 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 WebhookCreateOrUpdateParameters.
*/
public static WebhookCreateOrUpdateParameters fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
WebhookCreateOrUpdateParameters deserializedWebhookCreateOrUpdateParameters
= new WebhookCreateOrUpdateParameters();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("name".equals(fieldName)) {
deserializedWebhookCreateOrUpdateParameters.name = reader.getString();
} else if ("properties".equals(fieldName)) {
deserializedWebhookCreateOrUpdateParameters.innerProperties
= WebhookCreateOrUpdateProperties.fromJson(reader);
} else {
reader.skipChildren();
}
}
return deserializedWebhookCreateOrUpdateParameters;
});
}
}