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

package com.azure.resourcemanager.security.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.util.Context;
import com.azure.resourcemanager.security.fluent.models.IngestionSettingInner;
import com.azure.resourcemanager.security.models.ConnectionStrings;
import com.azure.resourcemanager.security.models.IngestionSetting;
import com.azure.resourcemanager.security.models.IngestionSettingToken;

public final class IngestionSettingImpl implements IngestionSetting, IngestionSetting.Definition {
    private IngestionSettingInner innerObject;

    private final com.azure.resourcemanager.security.SecurityManager serviceManager;

    IngestionSettingImpl(
        IngestionSettingInner innerObject, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = innerObject;
        this.serviceManager = serviceManager;
    }

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

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

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

    public Object properties() {
        return this.innerModel().properties();
    }

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

    private com.azure.resourcemanager.security.SecurityManager manager() {
        return this.serviceManager;
    }

    private String ingestionSettingName;

    public IngestionSetting create() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getIngestionSettings()
                .createWithResponse(ingestionSettingName, this.innerModel(), Context.NONE)
                .getValue();
        return this;
    }

    public IngestionSetting create(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getIngestionSettings()
                .createWithResponse(ingestionSettingName, this.innerModel(), context)
                .getValue();
        return this;
    }

    IngestionSettingImpl(String name, com.azure.resourcemanager.security.SecurityManager serviceManager) {
        this.innerObject = new IngestionSettingInner();
        this.serviceManager = serviceManager;
        this.ingestionSettingName = name;
    }

    public IngestionSetting refresh() {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getIngestionSettings()
                .getWithResponse(ingestionSettingName, Context.NONE)
                .getValue();
        return this;
    }

    public IngestionSetting refresh(Context context) {
        this.innerObject =
            serviceManager
                .serviceClient()
                .getIngestionSettings()
                .getWithResponse(ingestionSettingName, context)
                .getValue();
        return this;
    }

    public Response<IngestionSettingToken> listTokensWithResponse(Context context) {
        return serviceManager.ingestionSettings().listTokensWithResponse(ingestionSettingName, context);
    }

    public IngestionSettingToken listTokens() {
        return serviceManager.ingestionSettings().listTokens(ingestionSettingName);
    }

    public Response<ConnectionStrings> listConnectionStringsWithResponse(Context context) {
        return serviceManager.ingestionSettings().listConnectionStringsWithResponse(ingestionSettingName, context);
    }

    public ConnectionStrings listConnectionStrings() {
        return serviceManager.ingestionSettings().listConnectionStrings(ingestionSettingName);
    }

    public IngestionSettingImpl withProperties(Object properties) {
        this.innerModel().withProperties(properties);
        return this;
    }
}
