<commit_before>﻿using NGitLab.Impl;

namespace NGitLab {
    public class GitLabClient {
        readonly Api api;
        public readonly INamespaceClient Groups;
        public readonly IIssueClient Issues;
        public readonly IProjectClient Projects;

        public readonly IUserClient Users;

        GitLabClient(string hostUrl, string apiToken) {
            api = new Api(hostUrl, apiToken);
            Users = new UserClient(api);
            Projects = new ProjectClient(api);
            Issues = new IssueClient(api);
            Groups = new NamespaceClient(api);
        }

        public static GitLabClient Connect(string hostUrl, string apiToken) {
            return new GitLabClient(hostUrl, apiToken);
        }

        public IRepositoryClient GetRepository(int projectId) {
            return new RepositoryClient(api, projectId);
        }

        public IMergeRequestClient GetMergeRequest(int projectId) {
            return new MergeRequestClient(api, projectId);
        }
    }
}<commit_msg>add connect by username and password<commit_after>﻿using NGitLab.Impl;
using NGitLab.Models;

namespace NGitLab {
    public class GitLabClient {
        readonly Api api;
        public readonly INamespaceClient Groups;
        public readonly IIssueClient Issues;
        public readonly IProjectClient Projects;

        public readonly IUserClient Users;

        GitLabClient(string hostUrl, string apiToken) {
            api = new Api(hostUrl, apiToken);
            Users = new UserClient(api);
            Projects = new ProjectClient(api);
            Issues = new IssueClient(api);
            Groups = new NamespaceClient(api);
        }

        public static GitLabClient Connect(string hostUrl, string username, string password)
        {
            var api = new Api(hostUrl, "");
            var session = api.Post().To<Session>($"/session?login={username}&password={password}");
            return Connect(hostUrl, session.PrivateToken);
        }
        public static GitLabClient Connect(string hostUrl, string apiToken) {
            return new GitLabClient(hostUrl, apiToken);
        }

        public IRepositoryClient GetRepository(int projectId) {
            return new RepositoryClient(api, projectId);
        }

        public IMergeRequestClient GetMergeRequest(int projectId) {
            return new MergeRequestClient(api, projectId);
        }
    }
}
{'fraction_non_alphanumeric': 0.07204968944099378, 'fraction_numerical': 0.0, 'mean_word_length': 2.426950354609929, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7565041', 'n_tokens_mistral': 632, 'n_tokens_neox': 598, 'n_words': 172}