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

package com.azure.resourcemanager.devhub.implementation;

import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.devhub.fluent.ResourceProvidersClient;
import com.azure.resourcemanager.devhub.fluent.models.ArtifactGenerationProperties;
import com.azure.resourcemanager.devhub.fluent.models.GitHubOAuthInfoResponseInner;
import com.azure.resourcemanager.devhub.fluent.models.GitHubOAuthListResponseInner;
import com.azure.resourcemanager.devhub.fluent.models.GitHubOAuthResponseInner;
import com.azure.resourcemanager.devhub.models.GitHubOAuthCallRequest;
import com.azure.resourcemanager.devhub.models.GitHubOAuthInfoResponse;
import com.azure.resourcemanager.devhub.models.GitHubOAuthListResponse;
import com.azure.resourcemanager.devhub.models.GitHubOAuthResponse;
import com.azure.resourcemanager.devhub.models.ResourceProviders;
import java.util.Collections;
import java.util.Map;

public final class ResourceProvidersImpl implements ResourceProviders {
    private static final ClientLogger LOGGER = new ClientLogger(ResourceProvidersImpl.class);

    private final ResourceProvidersClient innerClient;

    private final com.azure.resourcemanager.devhub.DevHubManager serviceManager;

    public ResourceProvidersImpl(
        ResourceProvidersClient innerClient, com.azure.resourcemanager.devhub.DevHubManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public Response<GitHubOAuthInfoResponse> gitHubOAuthWithResponse(
        String location, GitHubOAuthCallRequest parameters, Context context) {
        Response<GitHubOAuthInfoResponseInner> inner =
            this.serviceClient().gitHubOAuthWithResponse(location, parameters, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new GitHubOAuthInfoResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public GitHubOAuthInfoResponse gitHubOAuth(String location) {
        GitHubOAuthInfoResponseInner inner = this.serviceClient().gitHubOAuth(location);
        if (inner != null) {
            return new GitHubOAuthInfoResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<GitHubOAuthResponse> gitHubOAuthCallbackWithResponse(
        String location, String code, String state, Context context) {
        Response<GitHubOAuthResponseInner> inner =
            this.serviceClient().gitHubOAuthCallbackWithResponse(location, code, state, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new GitHubOAuthResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public GitHubOAuthResponse gitHubOAuthCallback(String location, String code, String state) {
        GitHubOAuthResponseInner inner = this.serviceClient().gitHubOAuthCallback(location, code, state);
        if (inner != null) {
            return new GitHubOAuthResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<GitHubOAuthListResponse> listGitHubOAuthWithResponse(String location, Context context) {
        Response<GitHubOAuthListResponseInner> inner =
            this.serviceClient().listGitHubOAuthWithResponse(location, context);
        if (inner != null) {
            return new SimpleResponse<>(
                inner.getRequest(),
                inner.getStatusCode(),
                inner.getHeaders(),
                new GitHubOAuthListResponseImpl(inner.getValue(), this.manager()));
        } else {
            return null;
        }
    }

    public GitHubOAuthListResponse listGitHubOAuth(String location) {
        GitHubOAuthListResponseInner inner = this.serviceClient().listGitHubOAuth(location);
        if (inner != null) {
            return new GitHubOAuthListResponseImpl(inner, this.manager());
        } else {
            return null;
        }
    }

    public Response<Map<String, String>> generatePreviewArtifactsWithResponse(
        String location, ArtifactGenerationProperties parameters, Context context) {
        return this.serviceClient().generatePreviewArtifactsWithResponse(location, parameters, context);
    }

    public Map<String, String> generatePreviewArtifacts(String location, ArtifactGenerationProperties parameters) {
        Map<String, String> inner = this.serviceClient().generatePreviewArtifacts(location, parameters);
        if (inner != null) {
            return Collections.unmodifiableMap(inner);
        } else {
            return Collections.emptyMap();
        }
    }

    private ResourceProvidersClient serviceClient() {
        return this.innerClient;
    }

    private com.azure.resourcemanager.devhub.DevHubManager manager() {
        return this.serviceManager;
    }
}
