### Install NGitLab via CLI Source: https://github.com/ubisoft/ngitlab/blob/main/README.md Use the dotnet CLI to add the NGitLab package to your project. ```PowerShell dotnet add package NGitLab ``` -------------------------------- ### GET /namespaces Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Search or retrieve namespaces. ```APIDOC ## GET /namespaces ### Description Search for namespaces or retrieve accessible ones. ### Method GET ### Parameters #### Query Parameters - **search** (string) - Optional - Search query for namespaces. ### Response #### Success Response (200) - **Namespace** (array) - A list of matching namespaces. ``` -------------------------------- ### Configure GitLab Mock with GitLabConfig Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/readme.md Instantiate and define a GitLabConfig by adding users and projects with commits and tags. This is the recommended setup method. ```csharp var config = new GitLabConfig() .WithUser("test") .WithProject("user-project", @namespace: "test", configure: project => project .WithCommit("init", user: "test", tags: new[] { "v1.0.0" })) .WithProject("SampleProject", @namespace: "testgroup"); ``` -------------------------------- ### Manage Users and Groups with NGitLab Source: https://context7.com/ubisoft/ngitlab/llms.txt Provides examples for user account management, impersonation tokens, and group hierarchy operations. ```csharp using NGitLab; using NGitLab.Models; var client = new GitLabClient("https://gitlab.example.com", "your_token"); // Get all users foreach (User user in client.Users.All) { Console.WriteLine($"{user.Id}: {user.Username} ({user.Email})"); } // Search for users foreach (User user in client.Users.Search("john")) { Console.WriteLine($"Found: {user.Username}"); } // Get a specific user User user = client.Users[123]; User userByName = await client.Users.GetByUserNameAsync("johndoe"); // Create a new user (admin only) User newUser = client.Users.Create(new UserUpsert { Username = "newuser", Email = "newuser@example.com", Name = "New User", Password = "SecurePassword123!", Admin = false }); // Update a user client.Users.Update(newUser.Id, new UserUpsert { Name = "Updated Name" }); // Activate/Deactivate users client.Users.Activate(userId); client.Users.Deactivate(userId); // Create impersonation token (admin only) UserToken token = client.Users.CreateToken(new UserTokenCreate { UserId = userId, Name = "automation-token", Scopes = new[] { "api", "read_user" }, ExpiresAt = DateTime.Now.AddYears(1) }); Console.WriteLine($"Token: {token.Token}"); // Work with groups foreach (Group group in client.Groups.Accessible) { Console.WriteLine($"{group.Id}: {group.FullPath}"); } // Search groups var groups = client.Groups.Search("engineering"); // Get group details Group group = client.Groups[456]; Console.WriteLine($"Group: {group.Name}"); Console.WriteLine($"Visibility: {group.Visibility}"); // Create a subgroup Group newGroup = client.Groups.Create(new GroupCreate { Name = "Frontend Team", Path = "frontend", ParentId = 456, // parent group ID for subgroups Description = "Frontend development team", Visibility = VisibilityLevel.Internal }); // Get subgroups var subgroups = client.Groups.GetSubgroupsAsync(456); // Get projects in a group var projects = client.Groups.SearchProjectsAsync(456, new GroupProjectsQuery { IncludeSubgroups = true, Search = "api" }); // Update group client.Groups.Update(newGroup.Id, new GroupUpdate { Description = "Updated frontend team description" }); // Delete a group client.Groups.Delete(groupId); ``` -------------------------------- ### Configure Mock GitLab Server Directly with Models Source: https://context7.com/ubisoft/ngitlab/llms.txt Instantiate GitLabServer and manually add users, groups, and projects using their respective models. This method offers granular control over the mock server setup. ```csharp using NGitLab; using NGitLab.Mock; using NGitLab.Models; // Method 2: Using models directly using var server2 = new GitLabServer(); // Create users var user = new User("developer") { Email = "dev@example.com" }; server2.Users.Add(user); var adminUser = new User("admin") { IsAdmin = true }; server2.Users.Add(adminUser); // Create a project with repository var project2 = user.Namespace.Projects.AddNew("test-project"); project2.Description = "Test project for unit tests"; project2.Repository.Commit(user, "Initial commit"); project2.Repository.CreateTag("v1.0.0"); project2.Repository.Commit(user, "Second commit"); // Create a group with projects var group = new Group("engineering"); server2.Groups.Add(group); var groupProject = new Project("shared-lib"); group.Projects.Add(groupProject); // Create client and test IGitLabClient testClient = server2.CreateClient(user); var tags = testClient.GetRepository("developer/test-project").Tags.All; foreach (var tag in tags) { Console.WriteLine($"Tag: {tag.Name}"); } ``` -------------------------------- ### NGitLab ProjectCreate Options Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt This section details the properties available when creating a new NGitLab project, including their data types and whether they are readable (get) or writable (set). ```APIDOC ## NGitLab ProjectCreate Options ### Description This section details the properties available when creating a new NGitLab project, including their data types and whether they are readable (get) or writable (set). ### Properties - **BuildTimeout** (int?) - get, set - **DefaultBranch** (string) - get, set - **Description** (string) - get, set - **ImportUrl** (string) - get, set - **InitializeWithReadme** (bool) - get, set - **IssuesAccessLevel** (string) - get, set - **IssuesEnabled** (bool) - get, set - **MergePipelinesEnabled** (bool) - get, set - **MergeRequestsAccessLevel** (string) - get, set - **MergeRequestsEnabled** (bool) - get, set - **MergeTrainsEnabled** (bool) - get, set - **Name** (string) - get, set - **NamespaceId** (long?) - get, set - **Path** (string) - get, set - **SnippetsAccessLevel** (string) - get, set ``` -------------------------------- ### NGitLab ProjectCreate Properties Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net472/PublicAPI.Unshipped.txt This section details the available properties for creating a new NGitLab project, including their data types and whether they are readable (get) or writable (set). ```APIDOC ## NGitLab ProjectCreate Properties ### Description This section details the available properties for creating a new NGitLab project, including their data types and whether they are readable (get) or writable (set). ### Properties - **BuildTimeout** (int?) - get, set - **DefaultBranch** (string) - get, set - **Description** (string) - get, set - **ImportUrl** (string) - get, set - **InitializeWithReadme** (bool) - get, set - **IssuesAccessLevel** (string) - get, set - **IssuesEnabled** (bool) - get, set - **MergePipelinesEnabled** (bool) - get, set - **MergeRequestsAccessLevel** (string) - get, set - **MergeRequestsEnabled** (bool) - get, set - **MergeTrainsEnabled** (bool) - get, set - **Name** (string) - get, set - **NamespaceId** (long?) - get, set - **Path** (string) - get, set - **SnippetsAccessLevel** (string) - get, set ``` -------------------------------- ### Define GitLab Configuration in YAML Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/readme.md Define the GitLab setup configuration, including users, projects, and commits, within a YAML file. ```yaml gitlab: users: - username: test projects: - name: user-project namespace: test commits: - message: init user: test tags: - v1.0.0 - name: SampleProject namespace: testgroup ``` -------------------------------- ### Initialize GitLab Mock Server Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/readme.md Instantiate a new GitLabServer to begin setting up the mock environment. ```csharp var server = new GitLabServer(); ``` -------------------------------- ### GitLabClient Initialization Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Demonstrates different ways to initialize the GitLabClient. ```APIDOC ## GitLabClient Initialization ### Description Initializes the GitLabClient with various authentication and configuration options. ### Methods - `GitLabClient(string hostUrl)` - `GitLabClient(string hostUrl, RequestOptions options)` - `GitLabClient(string hostUrl, string apiToken)` - `GitLabClient(string hostUrl, string apiToken, RequestOptions options)` - `GitLabClient(string hostUrl, string userName, string password)` - `GitLabClient(string hostUrl, string userName, string password, RequestOptions options)` ``` -------------------------------- ### GET /files/{filePath} Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Retrieves file content from the repository. ```APIDOC ## GET /files/{filePath} ### Description Retrieves the data of a specific file at a given reference (branch or tag). ### Method GET ### Endpoint /files/{filePath} ### Parameters #### Path Parameters - **filePath** (string) - Required - The path to the file. #### Query Parameters - **ref** (string) - Required - The branch or tag name. ### Response #### Success Response (200) - **FileData** - The file content and metadata. ``` -------------------------------- ### GET /wikis Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Retrieve or manage wiki pages for a project. ```APIDOC ## GET /wikis ### Description Retrieve all wiki pages associated with the project. ### Method GET ### Response #### Success Response (200) - **WikiPage** (array) - A list of all wiki pages. ``` -------------------------------- ### Build GitLab Server and Client from Config Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/readme.md Build the mocked GitLab server from the configuration and create a client instance. Remember to dispose of the server after tests. ```csharp var server = config.BuildServer(); var client = server.CreateClient("test"); ``` ```csharp server.Dispose(); ``` -------------------------------- ### Project Constructors Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/PublicAPI.Unshipped.txt Demonstrates the different ways to instantiate a Project object. ```APIDOC ## Project Constructors ### Description Shows the available constructors for creating a new Project object. ### Method Constructor ### Endpoint N/A ### Parameters - **Project()**: No parameters. - **Project(string name)**: - **name** (string) - The name of the project. - **Project(string name, string path)**: - **name** (string) - The name of the project. - **path** (string) - The path of the project. ### Response void (Constructor) ``` -------------------------------- ### GET /users Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Retrieve user information by username or ID. ```APIDOC ## GET /users ### Description Retrieve user information from GitLab. ### Method GET ### Parameters #### Query Parameters - **username** (string) - Optional - The username to search for. ### Response #### Success Response (200) - **User** (object) - Returns a collection of User objects. ``` -------------------------------- ### Initialize GitLabClient Source: https://github.com/ubisoft/ngitlab/blob/main/README.md Create a new instance of the GitLabClient using your GitLab URL and private access token. ```csharp var client = new GitLabClient("https://mygitlab.example.com", "your_private_token"); ``` -------------------------------- ### Get Subgroups by ID Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves subgroups of a group specified by its ID. ```APIDOC ## GET /api/groups/{id}/subgroups ### Description Retrieves subgroups of a group identified by its ID. ### Method GET ### Endpoint /api/groups/{id}/subgroups ### Parameters #### Path Parameters - **id** (long) - Required - The ID of the group. #### Query Parameters - **query** (NGitLab.Models.SubgroupQuery) - Optional - Query parameters for filtering subgroups. ### Response #### Success Response (200) - **GitLabCollectionResponse** (NGitLab.GitLabCollectionResponse) - A collection of subgroups. #### Response Example ```json { "data": [ { "id": 4, "name": "Subgroup D", "path": "subgroup-d" } ], "total": 1 } ``` ``` -------------------------------- ### Perform Repository Operations with NGitLab Source: https://context7.com/ubisoft/ngitlab/llms.txt Demonstrates how to initialize a GitLabClient and perform various repository tasks including listing tree items, managing commits, branches, tags, and file operations. ```csharp using NGitLab; using NGitLab.Models; var client = new GitLabClient("https://gitlab.example.com", "your_token"); var repo = client.GetRepository(12345); // List repository tree foreach (Tree item in repo.GetTree("src", "main", recursive: true)) { Console.WriteLine($"{item.Type}: {item.Path}"); } // Get commits foreach (Commit commit in repo.GetCommits("main", maxResults: 10)) { Console.WriteLine($"{commit.ShortId}: {commit.Title} by {commit.AuthorName}"); } // Get a specific commit Commit commit = repo.GetCommit(new Sha1("abc123def456")); Console.WriteLine($"Message: {commit.Message}"); Console.WriteLine($"Stats: +{commit.Stats.Additions} -{commit.Stats.Deletions}"); // Get commit diff foreach (Diff diff in repo.GetCommitDiff(new Sha1("abc123def456"))) { Console.WriteLine($"File: {diff.NewPath}"); } // Compare two branches CompareResults comparison = repo.Compare(new CompareQuery { From = "main", To = "feature-branch" }); Console.WriteLine($"Commits: {comparison.Commits.Length}, Diffs: {comparison.Diffs.Length}"); // Work with branches var branches = repo.Branches; foreach (Branch branch in branches.All) { Console.WriteLine($"Branch: {branch.Name}, Protected: {branch.Protected}"); } // Create a new branch Branch newBranch = branches.Create(new BranchCreate { Name = "feature/new-feature", Ref = "main" }); // Protect/Unprotect branches branches.Protect("feature/new-feature"); branches.Unprotect("feature/new-feature"); // Delete a branch branches.Delete("feature/old-feature"); // Work with tags var tags = repo.Tags; foreach (Tag tag in tags.All) { Console.WriteLine($"Tag: {tag.Name} -> {tag.Commit.ShortId}"); } // Create a tag Tag newTag = tags.Create(new TagCreate { Name = "v1.0.0", Ref = "main", Message = "Release version 1.0.0" }); // Work with files var files = repo.Files; // Get file content FileData fileData = files.Get("README.md", "main"); Console.WriteLine($"Content: {fileData.ContentDecoded}"); // Check if file exists bool exists = files.FileExists("src/app.cs", "main"); // Create a new file files.Create(new FileUpsert { Path = "docs/guide.md", Branch = "main", Content = "# User Guide\n\nWelcome to our application.", CommitMessage = "Add user guide documentation" }); // Update a file files.Update(new FileUpsert { Path = "README.md", Branch = "main", Content = "# Updated README\n\nNew content here.", CommitMessage = "Update README" }); // Delete a file files.Delete(new FileDelete { Path = "old-file.txt", Branch = "main", CommitMessage = "Remove old file" }); ``` -------------------------------- ### GET /merge_requests/approvals Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Methods for retrieving and managing merge request approvals. ```APIDOC ## GET /merge_requests/{iid}/approvals ### Description Retrieves the approval status of a merge request. ### Method GET ### Parameters #### Path Parameters - **mergeRequestIid** (long) - Required - The IID of the merge request. ### Response #### Success Response (200) - **MergeRequestApprovals** (object) - The approval details. ## POST /merge_requests/{iid}/approve ### Description Approves a merge request. ### Method POST ### Parameters #### Path Parameters - **mergeRequestIid** (long) - Required - The IID of the merge request. ### Request Body - **message** (MergeRequestApprove) - Required - Approval details. ``` -------------------------------- ### GET /jobs/job_token Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Retrieves job information using a job token. ```APIDOC ## GET /jobs/job_token ### Description Retrieves job details using a provided job token via the IGlobalJobClient. ### Method GET ### Endpoint /jobs/job_token ### Parameters #### Query Parameters - **token** (string) - Required - The job token for authentication. ### Response #### Success Response (200) - **job** (Job) - The job details associated with the token. ``` -------------------------------- ### Create GitLab Client from Server Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/readme.md Create an instance of IGitLabClient using the configured server and a specific user. ```csharp IGitLabClient client = server.CreateClient(user); ``` -------------------------------- ### GET /projects/{id}/forks Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves a list of forks for a specific project. ```APIDOC ## GET /projects/{id}/forks ### Description Retrieves a list of forks for a given project ID. ### Method GET ### Endpoint /projects/{id}/forks ### Parameters #### Path Parameters - **id** (string) - Required - The ID or URL-encoded path of the project. #### Query Parameters - **query** (ForkedProjectQuery) - Optional - Query parameters for filtering forks. ``` -------------------------------- ### Initialize GitLab Client Source: https://context7.com/ubisoft/ngitlab/llms.txt Instantiate the GitLabClient with your GitLab server URL and authentication credentials. Supports API tokens (recommended) or username/password. Custom request options like retries can also be configured. ```csharp using NGitLab; using NGitLab.Models; // Initialize with API token (recommended) var client = new GitLabClient("https://gitlab.example.com", "your_private_token"); // Initialize with username/password var clientWithPassword = new GitLabClient("https://gitlab.example.com", "username", "password"); // Initialize with custom request options var options = new RequestOptions { Retries = 3, IsIncremental = false }; var clientWithOptions = new GitLabClient("https://gitlab.example.com", "your_private_token", options); // Access the current authenticated user Session currentUser = client.Users.Current; Console.WriteLine($"Logged in as: {currentUser.Username}"); // Get GitLab server version GitLabVersion version = client.Version.Get(); Console.WriteLine($"GitLab Version: {version.Version}"); ``` -------------------------------- ### Files Client - Get File Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves the content of a specific file from the repository. ```APIDOC ## GET /projects/{repoPath}/repository/files/{filePath} ### Description Retrieves the content of a specific file from the repository. ### Method GET ### Endpoint /projects/{repoPath}/repository/files/{filePath} ### Parameters #### Path Parameters - **repoPath** (string) - Required - The path of the repository. - **filePath** (string) - Required - The path of the file. #### Query Parameters - **ref** (string) - Required - The commit SHA or branch name. ### Response #### Success Response (200) - **value** (FileData) - An object containing the file data. - **fileName** (string) - The name of the file. - **filePath** (string) - The path of the file. - **size** (long) - The size of the file in bytes. - **encoding** (string) - The encoding of the file content. - **content** (string) - The content of the file. - **ref** (string) - The commit SHA or branch name. - **blobId** (string) - The blob ID of the file. - **commitId** (string) - The commit ID associated with the file. - **lastCommitId** (string) - The ID of the last commit to the file. #### Response Example ```json { "fileName": "example.txt", "filePath": "path/to/example.txt", "size": 100, "encoding": "base64", "content": "SGVsbG8sIFdvcmxkIQ==", "ref": "main", "blobId": "a1b2c3d4e5f6", "commitId": "a1b2c3d4e5f6", "lastCommitId": "a1b2c3d4e5f6" } ``` ``` -------------------------------- ### GET /groups/{groupId}/epics Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net472/PublicAPI.Unshipped.txt Retrieves a list of epics for a specific group. ```APIDOC ## GET /groups/{groupId}/epics ### Description Retrieves a collection of epics associated with the specified group ID. ### Method GET ### Endpoint /groups/{groupId}/epics ### Parameters #### Path Parameters - **groupId** (long) - Required - The ID of the group. #### Request Body - **query** (EpicQuery) - Required - Query parameters for filtering epics. ### Response #### Success Response (200) - **IEnumerable** - A collection of epic objects. ``` -------------------------------- ### GitLab Client Constructors Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Initialize the GitLab client with different authentication and configuration options. ```APIDOC ## GitLab Client Constructors ### Description Initializes the NGitLab client with various configurations. ### Method Constructor ### Endpoints - `NGitLab.GitLabClient.GitLabClient(string hostUrl)` - `NGitLab.GitLabClient.GitLabClient(string hostUrl, NGitLab.RequestOptions options)` - `NGitLab.GitLabClient.GitLabClient(string hostUrl, string apiToken)` - `NGitLab.GitLabClient.GitLabClient(string hostUrl, string apiToken, NGitLab.RequestOptions options)` - `NGitLab.GitLabClient.GitLabClient(string hostUrl, string userName, string password)` - `NGitLab.GitLabClient.GitLabClient(string hostUrl, string userName, string password, NGitLab.RequestOptions options)` ### Parameters #### Path Parameters - **hostUrl** (string) - Required - The base URL of the GitLab instance. - **apiToken** (string) - Optional - The API token for authentication. - **userName** (string) - Optional - The username for basic authentication. - **password** (string) - Optional - The password for basic authentication. - **options** (NGitLab.RequestOptions) - Optional - Additional request options. ``` -------------------------------- ### GET /groups/{groupId}/badges Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Retrieves all badges associated with a specific group. ```APIDOC ## GET /groups/{groupId}/badges ### Description Retrieves all badges associated with a specific group using the IGroupBadgeClient. ### Method GET ### Endpoint /groups/{groupId}/badges ### Parameters #### Path Parameters - **groupId** (long) - Required - The ID of the group. ### Response #### Success Response (200) - **badges** (IEnumerable) - A list of badges associated with the group. ``` -------------------------------- ### User Profile Management Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net472/PublicAPI.Unshipped.txt Endpoints for getting and setting various user profile attributes. ```APIDOC ## User Profile Management ### Description Provides methods to get and set user profile details. ### Methods #### Get User Profile Attributes - **GET /users/{id}** Retrieves specific user profile attributes. - **Example**: Get LinkedIn profile ``` NGitLab.Models.User.Linkedin.get ``` #### Set User Profile Attributes - **PUT /users/{id}** Updates specific user profile attributes. - **Example**: Set Skype profile ``` NGitLab.Models.User.Skype.set ``` ### Available Attributes - **Linkedin**: string - **Location**: string - **Name**: string - **Note**: string - **Organization**: string - **PrivateProfile**: bool - **ProjectsLimit**: int - **ProvisionedByGroupId**: long - **PublicEmail**: string - **SharedRunnersMinutesLimit**: int - **Skype**: string - **State**: string - **ThemeId**: long - **Twitter**: string - **TwoFactorEnabled**: bool - **Username**: string - **UsingLicenseSeat**: bool - **WebsiteURL**: string - **WebURL**: string - **WorkInformation**: string ``` -------------------------------- ### Project Creation Settings Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net472/PublicAPI.Unshipped.txt Properties available for configuring project creation, including snippets, squash options, tags, topics, visibility, and wiki settings. ```APIDOC ## ProjectCreate Model ### Description Models the settings for creating or updating a project. ### Properties - **SnippetsEnabled** (bool) - Indicates if snippets are enabled for the project. - **SquashOption** (NGitLab.Models.SquashOption?) - The squash option for commits. - **Tags** (List) - A list of tags associated with the project. - **Topics** (List) - A list of topics associated with the project. - **VisibilityLevel** (NGitLab.Models.VisibilityLevel) - The visibility level of the project. - **WallEnabled** (bool) - Indicates if the project wall is enabled. - **WikiAccessLevel** (string) - The access level for the project wiki. - **WikiEnabled** (bool) - Indicates if the project wiki is enabled. ``` -------------------------------- ### Get Subgroups Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Retrieves a collection of subgroups for a given group, with optional query parameters. ```APIDOC ## GET /api/groups/{groupId}/subgroups ### Description Retrieves a collection of subgroups for a given group. ### Method GET ### Endpoint /api/groups/{groupId}/subgroups ### Parameters #### Path Parameters - **groupId** (NGitLab.Models.GroupId) - Required - The identifier of the group whose subgroups are to be retrieved. #### Query Parameters - **query** (NGitLab.Models.SubgroupQuery) - Optional - Query parameters for filtering and sorting subgroups. ### Response #### Success Response (200) - **GitLabCollectionResponse** (NGitLab.GitLabCollectionResponse) - A collection of subgroups. #### Response Example ```json [ { "id": 2, "name": "Subgroup Beta", "path": "subgroup-beta" } ] ``` ``` -------------------------------- ### Get Group by ID (Index Operator) Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves a group using the indexer with its ID. ```APIDOC ## GET /api/groups/{id} ### Description Retrieves a group using its ID via the indexer. ### Method GET ### Endpoint /api/groups/{id} ### Parameters #### Path Parameters - **id** (long) - Required - The ID of the group. ### Response #### Success Response (200) - **Group** (NGitLab.Models.Group) - The retrieved group object. #### Response Example ```json { "id": 9, "name": "Group by Index", "path": "group-index" } ``` ``` -------------------------------- ### NGitLab Mock Configuration Helpers Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/PublicAPI.Unshipped.txt Utility methods for deserializing GitLab configurations and building clients/servers. ```APIDOC ## NGitLab Mock Configuration Helpers ### Description Utility methods for deserializing GitLab configurations and building clients/servers. ### Methods - **Deserialize GitLab Config** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabConfig.Deserialize(string content) - **Returns**: NGitLab.Mock.Config.GitLabConfig - **As Default User** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.AsDefaultUser(this NGitLab.Mock.Config.GitLabUser user) - **Returns**: NGitLab.Mock.Config.GitLabUser - **Build Client from Config** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.BuildClient(this NGitLab.Mock.Config.GitLabConfig config, string username = null) - **Returns**: NGitLab.IGitLabClient - **Build Server from Config** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.BuildServer(this NGitLab.Mock.Config.GitLabConfig config) - **Returns**: NGitLab.Mock.GitLabServer - **Configure GitLab Commit** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabCommit commit, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabCommit - **Configure GitLab Config** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabConfig config, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabConfig - **Configure GitLab Group** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabGroup group, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabGroup - **Configure GitLab Issue** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabIssue issue, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabIssue - **Configure GitLab Merge Request** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabMergeRequest mergeRequest, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabMergeRequest - **Configure GitLab Pipeline** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabPipeline pipeline, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabPipeline - **Configure GitLab Project** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabProject project, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabProject - **Configure GitLab User** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.Configure(this NGitLab.Mock.Config.GitLabUser user, System.Action configure) - **Returns**: NGitLab.Mock.Config.GitLabUser - **Create Client from Server** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.CreateClient(this NGitLab.Mock.GitLabServer server, string username = null) - **Returns**: NGitLab.IGitLabClient - **Set Default Branch** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.SetDefaultBranch(this NGitLab.Mock.Config.GitLabConfig config, string branchName) - **Returns**: NGitLab.Mock.Config.GitLabConfig - **Set Default User** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.SetDefaultUser(this NGitLab.Mock.Config.GitLabConfig config, string username) - **Returns**: NGitLab.Mock.Config.GitLabConfig - **Set Default Visibility** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.SetDefaultVisibility(this NGitLab.Mock.Config.GitLabConfig config, NGitLab.Models.VisibilityLevel visibility) - **Returns**: NGitLab.Mock.Config.GitLabConfig - **To Config from Server** - **Method**: static - **Endpoint**: NGitLab.Mock.Config.GitLabHelpers.ToConfig(this NGitLab.Mock.GitLabServer server) - **Returns**: NGitLab.Mock.Config.GitLabConfig ``` -------------------------------- ### NGitLab.Mock.Project Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/PublicAPI.Unshipped.txt Methods for managing project-level configurations and runners. ```APIDOC ## Project Methods ### AddRunner - **Method**: AddRunner(string name, string description, bool paused, bool locked, bool isShared) - **Returns**: NGitLab.Mock.Runner ### AddRunner (Overload 1) - **Method**: AddRunner(string name, string description, bool paused, bool locked, bool isShared, bool runUntagged) - **Returns**: NGitLab.Mock.Runner ### AddRunner (Overload 2) - **Method**: AddRunner(string name, string description, bool paused, bool locked, bool isShared, bool runUntagged, long id) - **Returns**: NGitLab.Mock.Runner ``` -------------------------------- ### Get Subgroups by Full Path Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves subgroups of a group specified by its full path. ```APIDOC ## GET /api/groups/{fullPath}/subgroups ### Description Retrieves subgroups of a group identified by its full path. ### Method GET ### Endpoint /api/groups/{fullPath}/subgroups ### Parameters #### Path Parameters - **fullPath** (string) - Required - The full path of the group. #### Query Parameters - **query** (NGitLab.Models.SubgroupQuery) - Optional - Query parameters for filtering subgroups. ### Response #### Success Response (200) - **GitLabCollectionResponse** (NGitLab.GitLabCollectionResponse) - A collection of subgroups. #### Response Example ```json { "data": [ { "id": 3, "name": "Subgroup C", "path": "subgroup-c" } ], "total": 1 } ``` ``` -------------------------------- ### Groups Client - Get Group by Full Path Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves a group by its full path. ```APIDOC ## GET /groups?full_path={fullPath} ### Description Retrieves a group by its full path. ### Method GET ### Endpoint /groups ### Parameters #### Query Parameters - **fullPath** (string) - Required - The full path of the group (e.g., "group/subgroup"). ### Response #### Success Response (200) - **value** (Group) - The group object matching the full path. #### Response Example ```json { "id": 1, "name": "Example Group", "path": "example-group", "description": "This is an example group.", "parent_id": null, "createdAt": "2023-01-01T12:00:00Z" } ``` ``` -------------------------------- ### GitLab Mock Configuration Helpers Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/PublicAPI.Unshipped.txt A collection of static helper methods to build and configure mock GitLab objects. ```APIDOC ## Mock Configuration Methods ### Description These methods allow for the fluent configuration of mock GitLab entities including projects, issues, merge requests, and groups. ### Methods - **WithApprover**: Adds an approver to a GitLabMergeRequest. - **WithComment**: Adds a comment to a GitLabIssue or GitLabMergeRequest. - **WithCommit**: Adds a commit to a GitLabProject. - **WithFile**: Adds a file to a GitLabCommit. - **WithGroup**: Creates or configures a group within the GitLabConfig. - **WithGroupPermission**: Sets access levels for groups on projects or other groups. - **WithIssue**: Adds an issue to a GitLabProject. - **WithJob**: Adds a job to a GitLabPipeline. ``` -------------------------------- ### Groups Client - Get Groups Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves a collection of groups based on the provided query. ```APIDOC ## GET /groups ### Description Retrieves a collection of groups based on the provided query. ### Method GET ### Endpoint /groups ### Parameters #### Query Parameters - **query** (GroupQuery) - Required - An object containing query parameters for filtering groups. ### Response #### Success Response (200) - **value** (IEnumerable) - An enumerable collection of groups. #### Response Example ```json [ { "id": 1, "name": "Example Group", "path": "example-group", "description": "This is an example group.", "parent_id": null, "createdAt": "2023-01-01T12:00:00Z" } ] ``` ``` -------------------------------- ### NGitLab Mock Clients and Extensions Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab.Mock/PublicAPI.Unshipped.txt Extension methods for converting LibGit2Sharp objects to NGitLab client objects. ```APIDOC ## NGitLab Mock Clients and Extensions ### Description Extension methods for converting LibGit2Sharp objects to NGitLab client objects. ### Methods - **To Branch Client** - **Method**: static - **Endpoint**: NGitLab.Mock.Clients.LibGit2SharpExtensions.ToBranchClient(this LibGit2Sharp.Branch branch, NGitLab.Mock.Project project) - **Returns**: NGitLab.Models.Branch - **To Commit Client** - **Method**: static - **Endpoint**: NGitLab.Mock.Clients.LibGit2SharpExtensions.ToCommitClient(this LibGit2Sharp.Commit commit, NGitLab.Mock.Project project) - **Returns**: NGitLab.Models.Commit - **To Commit Info** - **Method**: static - **Endpoint**: NGitLab.Mock.Clients.LibGit2SharpExtensions.ToCommitInfo(this LibGit2Sharp.Commit commit) - **Returns**: NGitLab.Models.CommitInfo ``` -------------------------------- ### Group Hooks Client - Get All Hooks Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves all group hooks for a given group. ```APIDOC ## GET /groups/{groupId}/hooks ### Description Retrieves all group hooks for a given group. ### Method GET ### Endpoint /groups/{groupId}/hooks ### Parameters #### Path Parameters - **groupId** (GroupId) - Required - The ID of the group. ### Response #### Success Response (200) - **value** (IEnumerable) - An enumerable collection of group hooks. #### Response Example ```json [ { "id": 1, "url": "http://example.com/hook", "createdAt": "2023-01-01T12:00:00Z", "pushEvents": true, "mergeRequestsEvents": false, "tagPushEvents": false, "issuesEvents": false, "noteEvents": false } ] ``` ``` -------------------------------- ### Manage Pipelines and Jobs with NGitLab Source: https://context7.com/ubisoft/ngitlab/llms.txt Use IPipelineClient and IJobClient to interact with GitLab CI/CD resources. Ensure a valid GitLabClient instance is initialized with a token. ```csharp using NGitLab; using NGitLab.Models; var client = new GitLabClient("https://gitlab.example.com", "your_token"); var pipelineClient = client.GetPipelines(12345); var jobClient = client.GetJobs(12345); // List all pipelines foreach (PipelineBasic pipeline in pipelineClient.All) { Console.WriteLine($"Pipeline {pipeline.Id}: {pipeline.Status} ({pipeline.Ref})"); } // Get pipeline details Pipeline pipeline = pipelineClient[98765]; Console.WriteLine($"Pipeline: {pipeline.Id}"); Console.WriteLine($"Status: {pipeline.Status}"); Console.WriteLine($"Duration: {pipeline.Duration}s"); // Search pipelines with filters var pipelines = pipelineClient.Search(new PipelineQuery { Ref = "main", Status = PipelineStatus.success, OrderBy = "updated_at", Sort = "desc" }); // Create a new pipeline Pipeline newPipeline = pipelineClient.Create(new PipelineCreate { Ref = "main", Variables = { { "DEPLOY_ENV", "staging" }, { "DEBUG", "true" } } }); Console.WriteLine($"Started pipeline: {newPipeline.Id}"); // Trigger pipeline with token Pipeline triggeredPipeline = pipelineClient.CreatePipelineWithTrigger( "trigger_token_here", "main", new Dictionary { { "BUILD_TYPE", "release" } } ); // Get pipeline jobs Job[] jobs = pipelineClient.GetJobs(newPipeline.Id); foreach (Job job in jobs) { Console.WriteLine($"Job {job.Id}: {job.Name} - {job.Status}"); } // Get job details Job job = jobClient.Get(123456); Console.WriteLine($"Job: {job.Name}"); Console.WriteLine($"Stage: {job.Stage}"); Console.WriteLine($"Duration: {job.Duration}s"); // Get job trace (logs) string trace = jobClient.GetTrace(123456); Console.WriteLine($"Job output:\n{trace}"); // Run job actions (retry, cancel, play) Job retriedJob = jobClient.RunAction(123456, JobAction.Retry); Job cancelledJob = jobClient.RunAction(123456, JobAction.Cancel); Job playedJob = jobClient.RunAction(123456, JobAction.Play); // for manual jobs // Get job artifacts byte[] artifacts = jobClient.GetJobArtifacts(123456); File.WriteAllBytes("artifacts.zip", artifacts); // Get specific artifact file byte[] artifactFile = jobClient.GetJobArtifact(123456, "build/output.exe"); // Delete job artifacts await jobClient.DeleteJobArtifactsAsync(123456); // Get pipeline test reports TestReport testReport = pipelineClient.GetTestReports(newPipeline.Id); Console.WriteLine($"Total tests: {testReport.TotalCount}"); Console.WriteLine($"Failed: {testReport.FailedCount}"); Console.WriteLine($"Success: {testReport.SuccessCount}"); // Retry a pipeline await pipelineClient.RetryAsync(newPipeline.Id); // Delete a pipeline pipelineClient.Delete(oldPipelineId); ``` -------------------------------- ### Event Client - Get Events Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net8.0/PublicAPI.Unshipped.txt Retrieves a list of events based on the provided query. ```APIDOC ## GET /events ### Description Retrieves a list of events based on the provided query. ### Method GET ### Endpoint /events ### Parameters #### Query Parameters - **query** (EventQuery) - Required - An object containing query parameters for filtering events. ### Response #### Success Response (200) - **value** (IEnumerable) - An enumerable collection of events. #### Response Example ```json [ { "id": 1, "actionName": "created", "targetType": "issue", "targetUrl": "/group/project/-/issues/1", "author": { "id": 1, "name": "John Doe", "username": "johndoe" }, "createdAt": "2023-01-01T12:00:00Z" } ] ``` ``` -------------------------------- ### GET /merge_requests Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Retrieves a list of merge requests based on provided query parameters. ```APIDOC ## GET /merge_requests ### Description Retrieves a collection of merge requests. ### Method GET ### Endpoint /merge_requests ### Parameters #### Query Parameters - **query** (MergeRequestQuery) - Required - The query object containing filter criteria. ### Response #### Success Response (200) - **IEnumerable** - A list of merge requests matching the query. ``` -------------------------------- ### Configure Mock GitLab Server with GitLabConfig Source: https://context7.com/ubisoft/ngitlab/llms.txt Use GitLabConfig to set up users, projects, and commits for a mock GitLab server. This is the recommended approach for unit testing. ```csharp using NGitLab; using NGitLab.Mock; using NGitLab.Mock.Config; using NGitLab.Models; // Method 1: Using GitLabConfig (recommended) var config = new GitLabConfig() .WithUser("testuser", isAdmin: false) .WithUser("admin", isAdmin: true) .WithProject("my-project", @namespace: "testuser", configure: project => project .WithCommit("Initial commit", user: "testuser", tags: new[] { "v1.0.0" }) .WithCommit("Add feature", user: "testuser")); using var server = config.BuildServer(); IGitLabClient client = server.CreateClient("testuser"); // Use the client as you would with a real GitLab server Project project = client.Projects["testuser/my-project"]; Console.WriteLine($"Project: {project.Name}"); ``` -------------------------------- ### Get Group Projects Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Retrieves a collection of projects associated with a specific group, with options for querying. ```APIDOC ## GET /api/groups/{groupId}/projects ### Description Retrieves a collection of projects associated with a specific group. ### Method GET ### Endpoint /api/groups/{groupId}/projects ### Parameters #### Path Parameters - **groupId** (long) - Required - The ID of the group whose projects are to be retrieved. #### Query Parameters - **query** (NGitLab.Models.GroupProjectsQuery) - Optional - Query parameters for filtering and sorting projects. ### Response #### Success Response (200) - **GitLabCollectionResponse** (NGitLab.GitLabCollectionResponse) - A collection of projects within the group. #### Response Example ```json [ { "id": 10, "name": "Project Alpha", "path": "project-alpha" } ] ``` ``` -------------------------------- ### POST /pipelines Source: https://github.com/ubisoft/ngitlab/blob/main/NGitLab/PublicAPI/net10.0/PublicAPI.Unshipped.txt Create a new pipeline in the project. ```APIDOC ## POST /pipelines ### Description Creates a new pipeline for a specific reference. ### Method POST ### Request Body - **createOptions** (PipelineCreate) - Required - Configuration for the new pipeline. ### Response #### Success Response (200) - **Pipeline** (object) - The created pipeline object. ```