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

package com.azure.resourcemanager.videoanalyzer.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeName;

/** RTSP source allows for media from an RTSP camera or generic RTSP server to be ingested into a pipeline. */
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
@JsonTypeName("#Microsoft.VideoAnalyzer.RtspSource")
@Fluent
public final class RtspSource extends SourceNodeBase {
    /*
     * Network transport utilized by the RTSP and RTP exchange: TCP or HTTP.
     * When using TCP, the RTP packets are interleaved on the TCP RTSP
     * connection. When using HTTP, the RTSP messages are exchanged through
     * long lived HTTP connections, and the RTP packages are interleaved in the
     * HTTP connections alongside the RTSP messages.
     */
    @JsonProperty(value = "transport")
    private RtspTransport transport;

    /*
     * RTSP endpoint information for Video Analyzer to connect to. This
     * contains the required information for Video Analyzer to connect to RTSP
     * cameras and/or generic RTSP servers.
     */
    @JsonProperty(value = "endpoint", required = true)
    private EndpointBase endpoint;

    /**
     * Get the transport property: Network transport utilized by the RTSP and RTP exchange: TCP or HTTP. When using TCP,
     * the RTP packets are interleaved on the TCP RTSP connection. When using HTTP, the RTSP messages are exchanged
     * through long lived HTTP connections, and the RTP packages are interleaved in the HTTP connections alongside the
     * RTSP messages.
     *
     * @return the transport value.
     */
    public RtspTransport transport() {
        return this.transport;
    }

    /**
     * Set the transport property: Network transport utilized by the RTSP and RTP exchange: TCP or HTTP. When using TCP,
     * the RTP packets are interleaved on the TCP RTSP connection. When using HTTP, the RTSP messages are exchanged
     * through long lived HTTP connections, and the RTP packages are interleaved in the HTTP connections alongside the
     * RTSP messages.
     *
     * @param transport the transport value to set.
     * @return the RtspSource object itself.
     */
    public RtspSource withTransport(RtspTransport transport) {
        this.transport = transport;
        return this;
    }

    /**
     * Get the endpoint property: RTSP endpoint information for Video Analyzer to connect to. This contains the required
     * information for Video Analyzer to connect to RTSP cameras and/or generic RTSP servers.
     *
     * @return the endpoint value.
     */
    public EndpointBase endpoint() {
        return this.endpoint;
    }

    /**
     * Set the endpoint property: RTSP endpoint information for Video Analyzer to connect to. This contains the required
     * information for Video Analyzer to connect to RTSP cameras and/or generic RTSP servers.
     *
     * @param endpoint the endpoint value to set.
     * @return the RtspSource object itself.
     */
    public RtspSource withEndpoint(EndpointBase endpoint) {
        this.endpoint = endpoint;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public RtspSource withName(String name) {
        super.withName(name);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    @Override
    public void validate() {
        super.validate();
        if (endpoint() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property endpoint in model RtspSource"));
        } else {
            endpoint().validate();
        }
    }

    private static final ClientLogger LOGGER = new ClientLogger(RtspSource.class);
}
