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

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

import com.azure.core.annotation.Fluent;
import com.azure.resourcemanager.extendedlocation.models.ResourceSyncRulePropertiesSelector;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Properties for a resource sync rule. For an unmapped custom resource, its labels will be used to find out matching
 * resource sync rules using the selector property of the resource sync rule. If this resource sync rule has highest
 * priority among all matching rules, then the unmapped custom resource will be projected to the target resource group
 * associated with this resource sync rule.
 */
@Fluent
public final class ResourceSyncRuleProperties {
    /*
     * Priority represents a priority of the Resource Sync Rule
     */
    @JsonProperty(value = "priority")
    private Integer priority;

    /*
     * Provisioning State for the Resource Sync Rule.
     */
    @JsonProperty(value = "provisioningState", access = JsonProperty.Access.WRITE_ONLY)
    private String provisioningState;

    /*
     * A label selector is composed of two parts, matchLabels and
     * matchExpressions. The first part, matchLabels is a map of {key,value}
     * pairs. A single {key,value} in the matchLabels map is equivalent to an
     * element of matchExpressions, whose key field is 'key', the operator is
     * 'In', and the values array contains only 'value'. The second part,
     * matchExpressions is a list of resource selector requirements. Valid
     * operators include In, NotIn, Exists, and DoesNotExist. The values set
     * must be non-empty in the case of In and NotIn. The values set must be
     * empty in the case of Exists and DoesNotExist. All of the requirements,
     * from both matchLabels and matchExpressions must all be satisfied in
     * order to match.
     */
    @JsonProperty(value = "selector")
    private ResourceSyncRulePropertiesSelector selector;

    /*
     * For an unmapped custom resource, its labels will be used to find
     * matching resource sync rules. If this resource sync rule is one of the
     * matching rules with highest priority, then the unmapped custom resource
     * will be projected to the target resource group associated with this
     * resource sync rule. The user creating this resource sync rule should
     * have write permissions on the target resource group and this write
     * permission will be validated when creating the resource sync rule.
     */
    @JsonProperty(value = "targetResourceGroup")
    private String targetResourceGroup;

    /**
     * Get the priority property: Priority represents a priority of the Resource Sync Rule.
     *
     * @return the priority value.
     */
    public Integer priority() {
        return this.priority;
    }

    /**
     * Set the priority property: Priority represents a priority of the Resource Sync Rule.
     *
     * @param priority the priority value to set.
     * @return the ResourceSyncRuleProperties object itself.
     */
    public ResourceSyncRuleProperties withPriority(Integer priority) {
        this.priority = priority;
        return this;
    }

    /**
     * Get the provisioningState property: Provisioning State for the Resource Sync Rule.
     *
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.provisioningState;
    }

    /**
     * Get the selector property: A label selector is composed of two parts, matchLabels and matchExpressions. The first
     * part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an
     * element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only
     * 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include
     * In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set
     * must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and
     * matchExpressions must all be satisfied in order to match.
     *
     * @return the selector value.
     */
    public ResourceSyncRulePropertiesSelector selector() {
        return this.selector;
    }

    /**
     * Set the selector property: A label selector is composed of two parts, matchLabels and matchExpressions. The first
     * part, matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an
     * element of matchExpressions, whose key field is 'key', the operator is 'In', and the values array contains only
     * 'value'. The second part, matchExpressions is a list of resource selector requirements. Valid operators include
     * In, NotIn, Exists, and DoesNotExist. The values set must be non-empty in the case of In and NotIn. The values set
     * must be empty in the case of Exists and DoesNotExist. All of the requirements, from both matchLabels and
     * matchExpressions must all be satisfied in order to match.
     *
     * @param selector the selector value to set.
     * @return the ResourceSyncRuleProperties object itself.
     */
    public ResourceSyncRuleProperties withSelector(ResourceSyncRulePropertiesSelector selector) {
        this.selector = selector;
        return this;
    }

    /**
     * Get the targetResourceGroup property: For an unmapped custom resource, its labels will be used to find matching
     * resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the
     * unmapped custom resource will be projected to the target resource group associated with this resource sync rule.
     * The user creating this resource sync rule should have write permissions on the target resource group and this
     * write permission will be validated when creating the resource sync rule.
     *
     * @return the targetResourceGroup value.
     */
    public String targetResourceGroup() {
        return this.targetResourceGroup;
    }

    /**
     * Set the targetResourceGroup property: For an unmapped custom resource, its labels will be used to find matching
     * resource sync rules. If this resource sync rule is one of the matching rules with highest priority, then the
     * unmapped custom resource will be projected to the target resource group associated with this resource sync rule.
     * The user creating this resource sync rule should have write permissions on the target resource group and this
     * write permission will be validated when creating the resource sync rule.
     *
     * @param targetResourceGroup the targetResourceGroup value to set.
     * @return the ResourceSyncRuleProperties object itself.
     */
    public ResourceSyncRuleProperties withTargetResourceGroup(String targetResourceGroup) {
        this.targetResourceGroup = targetResourceGroup;
        return this;
    }

    /**
     * Validates the instance.
     *
     * @throws IllegalArgumentException thrown if the instance is not valid.
     */
    public void validate() {
        if (selector() != null) {
            selector().validate();
        }
    }
}
