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

package com.azure.resourcemanager.securityinsights.fluent.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.securityinsights.models.DataConnectorTenantId;
import com.azure.resourcemanager.securityinsights.models.PollingFrequency;
import com.azure.resourcemanager.securityinsights.models.TiTaxiiDataConnectorDataTypes;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.OffsetDateTime;

/** Threat Intelligence TAXII data connector properties. */
@Fluent
public final class TiTaxiiDataConnectorProperties extends DataConnectorTenantId {
    /*
     * The workspace id.
     */
    @JsonProperty(value = "workspaceId")
    private String workspaceId;

    /*
     * The friendly name for the TAXII server.
     */
    @JsonProperty(value = "friendlyName")
    private String friendlyName;

    /*
     * The API root for the TAXII server.
     */
    @JsonProperty(value = "taxiiServer")
    private String taxiiServer;

    /*
     * The collection id of the TAXII server.
     */
    @JsonProperty(value = "collectionId")
    private String collectionId;

    /*
     * The userName for the TAXII server.
     */
    @JsonProperty(value = "userName")
    private String username;

    /*
     * The password for the TAXII server.
     */
    @JsonProperty(value = "password")
    private String password;

    /*
     * The lookback period for the TAXII server.
     */
    @JsonProperty(value = "taxiiLookbackPeriod")
    private OffsetDateTime taxiiLookbackPeriod;

    /*
     * The polling frequency for the TAXII server.
     */
    @JsonProperty(value = "pollingFrequency", required = true)
    private PollingFrequency pollingFrequency;

    /*
     * The available data types for Threat Intelligence TAXII data connector.
     */
    @JsonProperty(value = "dataTypes", required = true)
    private TiTaxiiDataConnectorDataTypes dataTypes;

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

    /**
     * Set the workspaceId property: The workspace id.
     *
     * @param workspaceId the workspaceId value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withWorkspaceId(String workspaceId) {
        this.workspaceId = workspaceId;
        return this;
    }

    /**
     * Get the friendlyName property: The friendly name for the TAXII server.
     *
     * @return the friendlyName value.
     */
    public String friendlyName() {
        return this.friendlyName;
    }

    /**
     * Set the friendlyName property: The friendly name for the TAXII server.
     *
     * @param friendlyName the friendlyName value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withFriendlyName(String friendlyName) {
        this.friendlyName = friendlyName;
        return this;
    }

    /**
     * Get the taxiiServer property: The API root for the TAXII server.
     *
     * @return the taxiiServer value.
     */
    public String taxiiServer() {
        return this.taxiiServer;
    }

    /**
     * Set the taxiiServer property: The API root for the TAXII server.
     *
     * @param taxiiServer the taxiiServer value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withTaxiiServer(String taxiiServer) {
        this.taxiiServer = taxiiServer;
        return this;
    }

    /**
     * Get the collectionId property: The collection id of the TAXII server.
     *
     * @return the collectionId value.
     */
    public String collectionId() {
        return this.collectionId;
    }

    /**
     * Set the collectionId property: The collection id of the TAXII server.
     *
     * @param collectionId the collectionId value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withCollectionId(String collectionId) {
        this.collectionId = collectionId;
        return this;
    }

    /**
     * Get the username property: The userName for the TAXII server.
     *
     * @return the username value.
     */
    public String username() {
        return this.username;
    }

    /**
     * Set the username property: The userName for the TAXII server.
     *
     * @param username the username value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withUsername(String username) {
        this.username = username;
        return this;
    }

    /**
     * Get the password property: The password for the TAXII server.
     *
     * @return the password value.
     */
    public String password() {
        return this.password;
    }

    /**
     * Set the password property: The password for the TAXII server.
     *
     * @param password the password value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withPassword(String password) {
        this.password = password;
        return this;
    }

    /**
     * Get the taxiiLookbackPeriod property: The lookback period for the TAXII server.
     *
     * @return the taxiiLookbackPeriod value.
     */
    public OffsetDateTime taxiiLookbackPeriod() {
        return this.taxiiLookbackPeriod;
    }

    /**
     * Set the taxiiLookbackPeriod property: The lookback period for the TAXII server.
     *
     * @param taxiiLookbackPeriod the taxiiLookbackPeriod value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withTaxiiLookbackPeriod(OffsetDateTime taxiiLookbackPeriod) {
        this.taxiiLookbackPeriod = taxiiLookbackPeriod;
        return this;
    }

    /**
     * Get the pollingFrequency property: The polling frequency for the TAXII server.
     *
     * @return the pollingFrequency value.
     */
    public PollingFrequency pollingFrequency() {
        return this.pollingFrequency;
    }

    /**
     * Set the pollingFrequency property: The polling frequency for the TAXII server.
     *
     * @param pollingFrequency the pollingFrequency value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withPollingFrequency(PollingFrequency pollingFrequency) {
        this.pollingFrequency = pollingFrequency;
        return this;
    }

    /**
     * Get the dataTypes property: The available data types for Threat Intelligence TAXII data connector.
     *
     * @return the dataTypes value.
     */
    public TiTaxiiDataConnectorDataTypes dataTypes() {
        return this.dataTypes;
    }

    /**
     * Set the dataTypes property: The available data types for Threat Intelligence TAXII data connector.
     *
     * @param dataTypes the dataTypes value to set.
     * @return the TiTaxiiDataConnectorProperties object itself.
     */
    public TiTaxiiDataConnectorProperties withDataTypes(TiTaxiiDataConnectorDataTypes dataTypes) {
        this.dataTypes = dataTypes;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public TiTaxiiDataConnectorProperties withTenantId(String tenantId) {
        super.withTenantId(tenantId);
        return this;
    }

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

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