// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.media.videoanalyzer.edge.models;

import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.UnsupportedEncodingException;


/** Creates a new pipeline topology or updates an existing one. */
@Fluent
public final class PipelineTopologySetRequest extends MethodRequest {
    /*
     * Pipeline topology describes the processing steps to be applied when
     * processing media for a particular outcome. The topology should be
     * defined according to the scenario to be achieved and can be reused
     * across many pipeline instances which share the same processing
     * characteristics. For instance, a pipeline topology which acquires data
     * from a RTSP camera, process it with an specific AI model and stored the
     * data on the cloud can be reused across many different cameras, as long
     * as the same processing should be applied across all the cameras.
     * Individual instance properties can be defined through the use of
     * user-defined parameters, which allow for a topology to be parameterized,
     * thus allowing individual pipelines to refer to different values, such as
     * individual cameras RTSP endpoints and credentials. Overall a topology is
     * composed of the following:
     *
     * - Parameters: list of user defined parameters that can be references
     * across the topology nodes.
     * - Sources: list of one or more data sources nodes such as an RTSP source
     * which allows for media to be ingested from cameras.
     * - Processors: list of nodes which perform data analysis or
     * transformations.
     * -Sinks: list of one or more data sinks which allow for data to be stored
     * or exported to other destinations.
     */
    @JsonProperty(value = "pipelineTopology", required = true)
    private PipelineTopology pipelineTopology;

    /*
     * method name
     */
    @JsonProperty(value = "methodName", required = true, access = JsonProperty.Access.WRITE_ONLY)
    private String methodName;

    /**
     * Creates an instance of PipelineTopologySetRequest class.
     *
     * @param pipelineTopology the pipelineTopology value to set.
     */
    @JsonCreator
    public PipelineTopologySetRequest(
            @JsonProperty(value = "pipelineTopology", required = true) PipelineTopology pipelineTopology) {
        methodName = "pipelineTopologySet";
        this.pipelineTopology = pipelineTopology;
    }

    /**
     * Get the pipelineTopology property: Pipeline topology describes the processing steps to be applied when processing
     * media for a particular outcome. The topology should be defined according to the scenario to be achieved and can
     * be reused across many pipeline instances which share the same processing characteristics. For instance, a
     * pipeline topology which acquires data from a RTSP camera, process it with an specific AI model and stored the
     * data on the cloud can be reused across many different cameras, as long as the same processing should be applied
     * across all the cameras. Individual instance properties can be defined through the use of user-defined parameters,
     * which allow for a topology to be parameterized, thus allowing individual pipelines to refer to different values,
     * such as individual cameras RTSP endpoints and credentials. Overall a topology is composed of the following:
     *
     * <p>- Parameters: list of user defined parameters that can be references across the topology nodes. - Sources:
     * list of one or more data sources nodes such as an RTSP source which allows for media to be ingested from cameras.
     * - Processors: list of nodes which perform data analysis or transformations. -Sinks: list of one or more data
     * sinks which allow for data to be stored or exported to other destinations.
     *
     * @return the pipelineTopology value.
     */
    public PipelineTopology getPipelineTopology() {
        return this.pipelineTopology;
    }

    /**
     * Get the methodName property: method name.
     *
     * @return the methodName value.
     */
    public String getMethodName() {
        return this.methodName;
    }

    /**
     * Get the payload as JSON: the serialized form of the request body
     *
     * @return the payload as JSON
     * @throws UnsupportedEncodingException UnsupportedEncodingException UnsupportedEncodingException
     */
    public String getPayloadAsJson() throws UnsupportedEncodingException {
        PipelineTopologySetRequestBody setRequestBody =
                new PipelineTopologySetRequestBody(this.pipelineTopology.getName());
        setRequestBody.setSystemData(this.pipelineTopology.getSystemData());
        setRequestBody.setProperties(this.pipelineTopology.getProperties());
        return setRequestBody.getPayloadAsJson();
    }
}
