All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.messaging.eventgrid.systemevents.ContainerRegistryArtifactEventData Maven / Gradle / Ivy

There is a newer version: 4.27.0
Show 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.messaging.eventgrid.systemevents;

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;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;

/**
 * The content of the event request message.
 */
@Fluent
public class ContainerRegistryArtifactEventData implements JsonSerializable {
    /*
     * The event ID.
     */
    private String id;

    /*
     * The time at which the event occurred.
     */
    private OffsetDateTime timestamp;

    /*
     * The action that encompasses the provided event.
     */
    private String action;

    /*
     * The location of the event.
     */
    private String location;

    /*
     * The target of the event.
     */
    private ContainerRegistryArtifactEventTarget target;

    /*
     * The connected registry information if the event is generated by a connected registry.
     */
    private ContainerRegistryEventConnectedRegistry connectedRegistry;

    /**
     * Creates an instance of ContainerRegistryArtifactEventData class.
     */
    public ContainerRegistryArtifactEventData() {
    }

    /**
     * Get the id property: The event ID.
     * 
     * @return the id value.
     */
    public String getId() {
        return this.id;
    }

    /**
     * Set the id property: The event ID.
     * 
     * @param id the id value to set.
     * @return the ContainerRegistryArtifactEventData object itself.
     */
    public ContainerRegistryArtifactEventData setId(String id) {
        this.id = id;
        return this;
    }

    /**
     * Get the timestamp property: The time at which the event occurred.
     * 
     * @return the timestamp value.
     */
    public OffsetDateTime getTimestamp() {
        return this.timestamp;
    }

    /**
     * Set the timestamp property: The time at which the event occurred.
     * 
     * @param timestamp the timestamp value to set.
     * @return the ContainerRegistryArtifactEventData object itself.
     */
    public ContainerRegistryArtifactEventData setTimestamp(OffsetDateTime timestamp) {
        this.timestamp = timestamp;
        return this;
    }

    /**
     * Get the action property: The action that encompasses the provided event.
     * 
     * @return the action value.
     */
    public String getAction() {
        return this.action;
    }

    /**
     * Set the action property: The action that encompasses the provided event.
     * 
     * @param action the action value to set.
     * @return the ContainerRegistryArtifactEventData object itself.
     */
    public ContainerRegistryArtifactEventData setAction(String action) {
        this.action = action;
        return this;
    }

    /**
     * Get the location property: The location of the event.
     * 
     * @return the location value.
     */
    public String getLocation() {
        return this.location;
    }

    /**
     * Set the location property: The location of the event.
     * 
     * @param location the location value to set.
     * @return the ContainerRegistryArtifactEventData object itself.
     */
    public ContainerRegistryArtifactEventData setLocation(String location) {
        this.location = location;
        return this;
    }

    /**
     * Get the target property: The target of the event.
     * 
     * @return the target value.
     */
    public ContainerRegistryArtifactEventTarget getTarget() {
        return this.target;
    }

    /**
     * Set the target property: The target of the event.
     * 
     * @param target the target value to set.
     * @return the ContainerRegistryArtifactEventData object itself.
     */
    public ContainerRegistryArtifactEventData setTarget(ContainerRegistryArtifactEventTarget target) {
        this.target = target;
        return this;
    }

    /**
     * Get the connectedRegistry property: The connected registry information if the event is generated by a connected
     * registry.
     * 
     * @return the connectedRegistry value.
     */
    public ContainerRegistryEventConnectedRegistry getConnectedRegistry() {
        return this.connectedRegistry;
    }

    /**
     * Set the connectedRegistry property: The connected registry information if the event is generated by a connected
     * registry.
     * 
     * @param connectedRegistry the connectedRegistry value to set.
     * @return the ContainerRegistryArtifactEventData object itself.
     */
    public ContainerRegistryArtifactEventData
        setConnectedRegistry(ContainerRegistryEventConnectedRegistry connectedRegistry) {
        this.connectedRegistry = connectedRegistry;
        return this;
    }

    @Override
    public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
        jsonWriter.writeStartObject();
        jsonWriter.writeStringField("id", this.id);
        jsonWriter.writeStringField("timestamp",
            this.timestamp == null ? null : DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(this.timestamp));
        jsonWriter.writeStringField("action", this.action);
        jsonWriter.writeStringField("location", this.location);
        jsonWriter.writeJsonField("target", this.target);
        jsonWriter.writeJsonField("connectedRegistry", this.connectedRegistry);
        return jsonWriter.writeEndObject();
    }

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

                if ("id".equals(fieldName)) {
                    deserializedContainerRegistryArtifactEventData.id = reader.getString();
                } else if ("timestamp".equals(fieldName)) {
                    deserializedContainerRegistryArtifactEventData.timestamp
                        = reader.getNullable(nonNullReader -> OffsetDateTime.parse(nonNullReader.getString()));
                } else if ("action".equals(fieldName)) {
                    deserializedContainerRegistryArtifactEventData.action = reader.getString();
                } else if ("location".equals(fieldName)) {
                    deserializedContainerRegistryArtifactEventData.location = reader.getString();
                } else if ("target".equals(fieldName)) {
                    deserializedContainerRegistryArtifactEventData.target
                        = ContainerRegistryArtifactEventTarget.fromJson(reader);
                } else if ("connectedRegistry".equals(fieldName)) {
                    deserializedContainerRegistryArtifactEventData.connectedRegistry
                        = ContainerRegistryEventConnectedRegistry.fromJson(reader);
                } else {
                    reader.skipChildren();
                }
            }

            return deserializedContainerRegistryArtifactEventData;
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy