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

package com.azure.resourcemanager.securityinsights.implementation;

import com.azure.core.http.rest.PagedIterable;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.securityinsights.fluent.SourceControlsClient;
import com.azure.resourcemanager.securityinsights.fluent.models.RepoInner;
import com.azure.resourcemanager.securityinsights.models.Repo;
import com.azure.resourcemanager.securityinsights.models.RepoType;
import com.azure.resourcemanager.securityinsights.models.SourceControls;

public final class SourceControlsImpl implements SourceControls {
    private static final ClientLogger LOGGER = new ClientLogger(SourceControlsImpl.class);

    private final SourceControlsClient innerClient;

    private final com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager;

    public SourceControlsImpl(
        SourceControlsClient innerClient,
        com.azure.resourcemanager.securityinsights.SecurityInsightsManager serviceManager) {
        this.innerClient = innerClient;
        this.serviceManager = serviceManager;
    }

    public PagedIterable<Repo> listRepositories(String resourceGroupName, String workspaceName, RepoType repoType) {
        PagedIterable<RepoInner> inner =
            this.serviceClient().listRepositories(resourceGroupName, workspaceName, repoType);
        return Utils.mapPage(inner, inner1 -> new RepoImpl(inner1, this.manager()));
    }

    public PagedIterable<Repo> listRepositories(
        String resourceGroupName, String workspaceName, RepoType repoType, Context context) {
        PagedIterable<RepoInner> inner =
            this.serviceClient().listRepositories(resourceGroupName, workspaceName, repoType, context);
        return Utils.mapPage(inner, inner1 -> new RepoImpl(inner1, this.manager()));
    }

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

    private com.azure.resourcemanager.securityinsights.SecurityInsightsManager manager() {
        return this.serviceManager;
    }
}
