// 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.core.management.Resource;
import com.azure.core.management.SystemData;
import com.azure.resourcemanager.extendedlocation.models.ResourceSyncRulePropertiesSelector;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;

/** Resource Sync Rules definition. */
@Fluent
public final class ResourceSyncRuleInner extends Resource {
    /*
     * The set of properties specific to a Resource Sync Rule
     */
    @JsonProperty(value = "properties")
    private ResourceSyncRuleProperties innerProperties;

    /*
     * Metadata pertaining to creation and last modification of the resource
     */
    @JsonProperty(value = "systemData", access = JsonProperty.Access.WRITE_ONLY)
    private SystemData systemData;

    /**
     * Get the innerProperties property: The set of properties specific to a Resource Sync Rule.
     *
     * @return the innerProperties value.
     */
    private ResourceSyncRuleProperties innerProperties() {
        return this.innerProperties;
    }

    /**
     * Get the systemData property: Metadata pertaining to creation and last modification of the resource.
     *
     * @return the systemData value.
     */
    public SystemData systemData() {
        return this.systemData;
    }

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

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

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

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

    /**
     * Get the provisioningState property: Provisioning State for the Resource Sync Rule.
     *
     * @return the provisioningState value.
     */
    public String provisioningState() {
        return this.innerProperties() == null ? null : this.innerProperties().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.innerProperties() == null ? null : this.innerProperties().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 ResourceSyncRuleInner object itself.
     */
    public ResourceSyncRuleInner withSelector(ResourceSyncRulePropertiesSelector selector) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ResourceSyncRuleProperties();
        }
        this.innerProperties().withSelector(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.innerProperties() == null ? null : this.innerProperties().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 ResourceSyncRuleInner object itself.
     */
    public ResourceSyncRuleInner withTargetResourceGroup(String targetResourceGroup) {
        if (this.innerProperties() == null) {
            this.innerProperties = new ResourceSyncRuleProperties();
        }
        this.innerProperties().withTargetResourceGroup(targetResourceGroup);
        return this;
    }

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