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

package com.azure.resourcemanager.healthcareapis.models;

import com.azure.core.annotation.Fluent;
import com.azure.core.management.Resource;
import com.azure.core.util.logging.ClientLogger;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** The common properties of a service. */
@Fluent
public class ServicesResource extends Resource {
    /*
     * The kind of the service.
     */
    @JsonProperty(value = "kind", required = true)
    private Kind kind;

    /*
     * An etag associated with the resource, used for optimistic concurrency
     * when editing it.
     */
    @JsonProperty(value = "etag")
    private String etag;

    /*
     * Setting indicating whether the service has a managed identity associated
     * with it.
     */
    @JsonProperty(value = "identity")
    private ServicesResourceIdentity identity;

    /**
     * Get the kind property: The kind of the service.
     *
     * @return the kind value.
     */
    public Kind kind() {
        return this.kind;
    }

    /**
     * Set the kind property: The kind of the service.
     *
     * @param kind the kind value to set.
     * @return the ServicesResource object itself.
     */
    public ServicesResource withKind(Kind kind) {
        this.kind = kind;
        return this;
    }

    /**
     * Get the etag property: An etag associated with the resource, used for optimistic concurrency when editing it.
     *
     * @return the etag value.
     */
    public String etag() {
        return this.etag;
    }

    /**
     * Set the etag property: An etag associated with the resource, used for optimistic concurrency when editing it.
     *
     * @param etag the etag value to set.
     * @return the ServicesResource object itself.
     */
    public ServicesResource withEtag(String etag) {
        this.etag = etag;
        return this;
    }

    /**
     * Get the identity property: Setting indicating whether the service has a managed identity associated with it.
     *
     * @return the identity value.
     */
    public ServicesResourceIdentity identity() {
        return this.identity;
    }

    /**
     * Set the identity property: Setting indicating whether the service has a managed identity associated with it.
     *
     * @param identity the identity value to set.
     * @return the ServicesResource object itself.
     */
    public ServicesResource withIdentity(ServicesResourceIdentity identity) {
        this.identity = identity;
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ServicesResource withLocation(String location) {
        super.withLocation(location);
        return this;
    }

    /** {@inheritDoc} */
    @Override
    public ServicesResource withTags(Map<String, String> tags) {
        super.withTags(tags);
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (kind() == null) {
            throw LOGGER
                .logExceptionAsError(
                    new IllegalArgumentException("Missing required property kind in model ServicesResource"));
        }
        if (identity() != null) {
            identity().validate();
        }
    }

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