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

package com.azure.resourcemanager.customerinsights.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.resourcemanager.customerinsights.fluent.models.InteractionResourceFormatInner;
import com.azure.resourcemanager.customerinsights.models.DataSourcePrecedence;
import com.azure.resourcemanager.customerinsights.models.DataSourceType;
import com.azure.resourcemanager.customerinsights.models.EntityTypes;
import com.azure.resourcemanager.customerinsights.models.InteractionResourceFormat;
import com.azure.resourcemanager.customerinsights.models.Participant;
import com.azure.resourcemanager.customerinsights.models.PropertyDefinition;
import com.azure.resourcemanager.customerinsights.models.ProvisioningStates;
import com.azure.resourcemanager.customerinsights.models.Status;
import com.azure.resourcemanager.customerinsights.models.SuggestRelationshipLinksResponse;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.List;
import java.util.Map;

public final class InteractionResourceFormatImpl
    implements InteractionResourceFormat, InteractionResourceFormat.Definition, InteractionResourceFormat.Update {
    private InteractionResourceFormatInner innerObject;

    private final com.azure.resourcemanager.customerinsights.CustomerInsightsManager serviceManager;

    public String id() {
        return this.innerModel().id();
    }

    public String name() {
        return this.innerModel().name();
    }

    public String type() {
        return this.innerModel().type();
    }

    public List<String> idPropertyNames() {
        List<String> inner = this.innerModel().idPropertyNames();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public List<Participant> participantProfiles() {
        List<Participant> inner = this.innerModel().participantProfiles();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public String primaryParticipantProfilePropertyName() {
        return this.innerModel().primaryParticipantProfilePropertyName();
    }

    public List<DataSourcePrecedence> dataSourcePrecedenceRules() {
        List<DataSourcePrecedence> inner = this.innerModel().dataSourcePrecedenceRules();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public Boolean isActivity() {
        return this.innerModel().isActivity();
    }

    public String namePropertiesName() {
        return this.innerModel().namePropertiesName();
    }

    public DataSourceType dataSourceType() {
        return this.innerModel().dataSourceType();
    }

    public Status status() {
        return this.innerModel().status();
    }

    public Integer idPropertiesId() {
        return this.innerModel().idPropertiesId();
    }

    public String dataSourceReferenceId() {
        return this.innerModel().dataSourceReferenceId();
    }

    public String apiEntitySetName() {
        return this.innerModel().apiEntitySetName();
    }

    public EntityTypes entityType() {
        return this.innerModel().entityType();
    }

    public List<PropertyDefinition> fields() {
        List<PropertyDefinition> inner = this.innerModel().fields();
        if (inner != null) {
            return Collections.unmodifiableList(inner);
        } else {
            return Collections.emptyList();
        }
    }

    public Integer instancesCount() {
        return this.innerModel().instancesCount();
    }

    public OffsetDateTime lastChangedUtc() {
        return this.innerModel().lastChangedUtc();
    }

    public ProvisioningStates provisioningState() {
        return this.innerModel().provisioningState();
    }

    public String schemaItemTypeLink() {
        return this.innerModel().schemaItemTypeLink();
    }

    public String tenantId() {
        return this.innerModel().tenantId();
    }

    public String timestampFieldName() {
        return this.innerModel().timestampFieldName();
    }

    public String typeName() {
        return this.innerModel().typeName();
    }

    public Map<String, List<String>> attributes() {
        Map<String, List<String>> inner = this.innerModel().attributes();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public Map<String, String> description() {
        Map<String, String> inner = this.innerModel().description();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public Map<String, String> displayName() {
        Map<String, String> inner = this.innerModel().displayName();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public Map<String, Map<String, String>> localizedAttributes() {
        Map<String, Map<String, String>> inner = this.innerModel().localizedAttributes();
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    public String smallImage() {
        return this.innerModel().smallImage();
    }

    public String mediumImage() {
        return this.innerModel().mediumImage();
    }

    public String largeImage() {
        return this.innerModel().largeImage();
    }

    public String resourceGroupName() {
        return resourceGroupName;
    }

    public InteractionResourceFormatInner innerModel() {
        return this.innerObject;
    }

    private com.azure.resourcemanager.customerinsights.CustomerInsightsManager manager() {
        return this.serviceManager;
    }

    private String resourceGroupName;

    private String hubName;

    private String interactionName;

    public InteractionResourceFormatImpl withExistingHub(String resourceGroupName, String hubName) {
        this.resourceGroupName = resourceGroupName;
        this.hubName = hubName;
        return this;
    }

    public InteractionResourceFormat create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInteractions()
                .createOrUpdate(resourceGroupName, hubName, interactionName, this.innerModel(), Context.NONE);
        return this;
    }

    public InteractionResourceFormat create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInteractions()
                .createOrUpdate(resourceGroupName, hubName, interactionName, this.innerModel(), context);
        return this;
    }

    InteractionResourceFormatImpl(
        String name, com.azure.resourcemanager.customerinsights.CustomerInsightsManager serviceManager) {
        this.innerObject = new InteractionResourceFormatInner();
        this.serviceManager = serviceManager;
        this.interactionName = name;
    }

    public InteractionResourceFormatImpl update() {
        return this;
    }

    public InteractionResourceFormat apply() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInteractions()
                .createOrUpdate(resourceGroupName, hubName, interactionName, this.innerModel(), Context.NONE);
        return this;
    }

    public InteractionResourceFormat apply(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInteractions()
                .createOrUpdate(resourceGroupName, hubName, interactionName, this.innerModel(), context);
        return this;
    }

    InteractionResourceFormatImpl(
        InteractionResourceFormatInner innerObject,
        com.azure.resourcemanager.customerinsights.CustomerInsightsManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
        this.resourceGroupName = Utils.getValueFromIdByName(innerObject.id(), "resourceGroups");
        this.hubName = Utils.getValueFromIdByName(innerObject.id(), "hubs");
        this.interactionName = Utils.getValueFromIdByName(innerObject.id(), "interactions");
    }

    public InteractionResourceFormat refresh() {
        String localLocaleCode = null;
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInteractions()
                .getWithResponse(resourceGroupName, hubName, interactionName, localLocaleCode, Context.NONE)
                .getValue();
        return this;
    }

    public InteractionResourceFormat refresh(Context context) {
        String localLocaleCode = null;
        this.innerObject =
            serviceManager
                .serviceClient()
                .getInteractions()
                .getWithResponse(resourceGroupName, hubName, interactionName, localLocaleCode, context)
                .getValue();
        return this;
    }

    public Response<SuggestRelationshipLinksResponse> suggestRelationshipLinksWithResponse(Context context) {
        return serviceManager
            .interactions()
            .suggestRelationshipLinksWithResponse(resourceGroupName, hubName, interactionName, context);
    }

    public SuggestRelationshipLinksResponse suggestRelationshipLinks() {
        return serviceManager.interactions().suggestRelationshipLinks(resourceGroupName, hubName, interactionName);
    }

    public InteractionResourceFormatImpl withIdPropertyNames(List<String> idPropertyNames) {
        this.innerModel().withIdPropertyNames(idPropertyNames);
        return this;
    }

    public InteractionResourceFormatImpl withParticipantProfiles(List<Participant> participantProfiles) {
        this.innerModel().withParticipantProfiles(participantProfiles);
        return this;
    }

    public InteractionResourceFormatImpl withPrimaryParticipantProfilePropertyName(
        String primaryParticipantProfilePropertyName) {
        this.innerModel().withPrimaryParticipantProfilePropertyName(primaryParticipantProfilePropertyName);
        return this;
    }

    public InteractionResourceFormatImpl withIsActivity(Boolean isActivity) {
        this.innerModel().withIsActivity(isActivity);
        return this;
    }

    public InteractionResourceFormatImpl withApiEntitySetName(String apiEntitySetName) {
        this.innerModel().withApiEntitySetName(apiEntitySetName);
        return this;
    }

    public InteractionResourceFormatImpl withEntityType(EntityTypes entityType) {
        this.innerModel().withEntityType(entityType);
        return this;
    }

    public InteractionResourceFormatImpl withFields(List<PropertyDefinition> fields) {
        this.innerModel().withFields(fields);
        return this;
    }

    public InteractionResourceFormatImpl withInstancesCount(Integer instancesCount) {
        this.innerModel().withInstancesCount(instancesCount);
        return this;
    }

    public InteractionResourceFormatImpl withSchemaItemTypeLink(String schemaItemTypeLink) {
        this.innerModel().withSchemaItemTypeLink(schemaItemTypeLink);
        return this;
    }

    public InteractionResourceFormatImpl withTimestampFieldName(String timestampFieldName) {
        this.innerModel().withTimestampFieldName(timestampFieldName);
        return this;
    }

    public InteractionResourceFormatImpl withTypeName(String typeName) {
        this.innerModel().withTypeName(typeName);
        return this;
    }

    public InteractionResourceFormatImpl withAttributes(Map<String, List<String>> attributes) {
        this.innerModel().withAttributes(attributes);
        return this;
    }

    public InteractionResourceFormatImpl withDescription(Map<String, String> description) {
        this.innerModel().withDescription(description);
        return this;
    }

    public InteractionResourceFormatImpl withDisplayName(Map<String, String> displayName) {
        this.innerModel().withDisplayName(displayName);
        return this;
    }

    public InteractionResourceFormatImpl withLocalizedAttributes(Map<String, Map<String, String>> localizedAttributes) {
        this.innerModel().withLocalizedAttributes(localizedAttributes);
        return this;
    }

    public InteractionResourceFormatImpl withSmallImage(String smallImage) {
        this.innerModel().withSmallImage(smallImage);
        return this;
    }

    public InteractionResourceFormatImpl withMediumImage(String mediumImage) {
        this.innerModel().withMediumImage(mediumImage);
        return this;
    }

    public InteractionResourceFormatImpl withLargeImage(String largeImage) {
        this.innerModel().withLargeImage(largeImage);
        return this;
    }
}
