### Get User Repositories Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Lists repositories associated with the authenticated user or a specific user account. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get authenticated user's repositories repos, response = get_user_repos(gh) for repo in repos println("$(repo.name) - $(repo.stargazers_count) stars") end # GitLab - get user's projects using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) projects, response = get_user_repos(gl) for project in projects println("$(project.name) ($(project.visibility))") end ``` -------------------------------- ### GET /users Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve a list of all users from the forge. ```APIDOC ## GET /users ### Description Get all users from the forge (requires admin permissions on some platforms). ### Method GET ### Endpoint /users ### Response #### Success Response (200) - **users** (Array) - A list of user objects. - **response** (Object) - The raw HTTP response. ``` -------------------------------- ### Get GitHub User Information Source: https://github.com/juliaweb/gitforge.jl/blob/master/README.md Demonstrates how to initialize a GitHub API client and retrieve user details. Asserts the HTTP status code and the user's login name. ```julia julia> using GitForge, GitForge.GitHub julia> gh = GitHubAPI(); julia> user, resp = get_user(gh, "christopher-dG"); julia> @assert resp.status == 200 julia> @assert user.login == "christopher-dG" ``` -------------------------------- ### Get Branch Information Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Fetches metadata for a specific branch in a repository. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get branch details branch, response = get_branch(gh, "owner", "repo", "main") println("Branch: $(branch.name)") println("Protected: $(branch.protected)") println("Commit SHA: $(branch.commit.sha)") ``` -------------------------------- ### Get Commit Details Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve information about a specific commit by its SHA. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get commit by SHA commit, response = get_commit(gh, "owner", "repo", "abc123def456") println("Message: $(commit.message)") println("Author: $(commit.author.name)") println("Date: $(commit.author.date)") ``` -------------------------------- ### Get Pull Request Details Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Fetch specific pull request information for GitHub or GitLab. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get specific PR pr, response = get_pull_request(gh, "JuliaLang", "julia", 12345) println("Title: $(pr.title)") println("State: $(pr.state)") println("Mergeable: $(pr.mergeable)") println("Additions: $(pr.additions), Deletions: $(pr.deletions)") println("Changed files: $(pr.changed_files)") # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) mr, response = get_pull_request(gl, 12345, 1) # project_id, mr_iid println("Title: $(mr.title)") println("Source: $(mr.source_branch) -> $(mr.target_branch)") println("Work in progress: $(mr.work_in_progress)") ``` -------------------------------- ### Get File Contents Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves and decodes file content from a repository, handling base64 encoding where necessary. ```julia using GitForge using GitForge.GitHub using Base64 gh = GitHubAPI(token=Token("your_token")) # Get file from repository file, response = get_file_contents(gh, "owner", "repo", "README.md") println("File: $(file.name)") println("Size: $(file.size) bytes") println("SHA: $(file.sha)") # Decode base64 content content = String(base64decode(file.content)) println("Content: $content") # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) # Get file by project ID file, response = get_file_contents(gl, 12345, "src/main.jl") content = String(base64decode(file.content)) println("File content: $content") # Get file by owner/repo file, response = get_file_contents(gl, "owner", "repo", "README.md") println("Commit ID: $(file.commit_id)") ``` -------------------------------- ### Get Repository Information Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves repository details from GitHub or GitLab using various identifiers like owner/name or project ID. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get repo by owner/repo string repo, response = get_repo(gh, "JuliaLang/julia") println("Repository: $(repo.full_name)") println("Stars: $(repo.stargazers_count)") println("Forks: $(repo.forks_count)") println("Default branch: $(repo.default_branch)") # Get repo by owner and repo separately repo, response = get_repo(gh, "JuliaLang", "julia") println("Description: $(repo.description)") println("Language: $(repo.language)") # GitLab examples using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) # Get project by path project, response = get_repo(gl, "gitlab-org/gitlab") println("Project: $(project.name)") println("Visibility: $(project.visibility)") # Get project with subgroup project, response = get_repo(gl, "group", "subgroup", "project") println("Full path: $(project.path_with_namespace)") ``` -------------------------------- ### Repository Operations Source: https://context7.com/juliaweb/gitforge.jl/llms.txt APIs for managing repositories, including getting repository details, listing user repositories, creating new repositories, and retrieving file contents. ```APIDOC ## GET /repos/{owner}/{repo} ### Description Retrieves information about a specific repository. ### Method GET ### Endpoint `/repos/{owner}/{repo}` ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. ### Request Example ```julia # GitHub example using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) repo, response = get_repo(gh, "JuliaLang/julia") println("Repository: $(repo.full_name)") # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) project, response = get_repo(gl, "gitlab-org/gitlab") println("Project: $(project.name)") ``` ### Response #### Success Response (200) - **full_name** (string) - The full name of the repository (e.g., 'owner/repo'). - **stargazers_count** (integer) - The number of stars the repository has. - **forks_count** (integer) - The number of forks the repository has. - **default_branch** (string) - The default branch of the repository. - **description** (string) - The description of the repository. - **language** (string) - The primary programming language of the repository. - **visibility** (string) - The visibility level of the project (GitLab specific). ``` ```APIDOC ## GET /user/repos ### Description Retrieves a list of repositories for the authenticated user or a specified user. ### Method GET ### Endpoint `/user/repos` ### Parameters #### Query Parameters - **username** (string) - Optional - The username of the user whose repositories to retrieve. If not provided, repositories of the authenticated user are returned. ### Request Example ```julia # GitHub example using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) repos, response = get_user_repos(gh) for repo in repos println("$(repo.name) - $(repo.stargazers_count) stars") end # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) projects, response = get_user_repos(gl) for project in projects println("$(project.name) ($(project.visibility))") end ``` ### Response #### Success Response (200) - **name** (string) - The name of the repository. - **stargazers_count** (integer) - The number of stars the repository has. - **visibility** (string) - The visibility level of the project (GitLab specific). ``` ```APIDOC ## POST /user/repos ### Description Creates a new repository for the authenticated user or within an organization. ### Method POST ### Endpoint `/user/repos` ### Parameters #### Path Parameters - **org** (string) - Optional - The name of the organization to create the repository in. If not provided, a personal repository is created. #### Request Body - **name** (string) - Required - The name of the new repository. - **description** (string) - Optional - A description for the repository. - **private** (boolean) - Optional - Whether the repository should be private (defaults to false for GitHub, 'private' for GitLab). - **auto_init** (boolean) - Optional - Whether to initialize the repository with a README (GitHub specific, defaults to false). - **gitignore_template** (string) - Optional - Specifies a gitignore template to apply (GitHub specific). - **visibility** (string) - Optional - Visibility level for GitLab projects (e.g., 'private', 'internal', 'public'). - **initialize_with_readme** (boolean) - Optional - Whether to initialize the project with a README (GitLab specific). ### Request Example ```julia # GitHub example (personal repository) using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) repo, response = create_repo(gh; name="my-new-repo", description="A new repository", private=false, auto_init=true, gitignore_template="Julia") println("Created: $(repo.html_url)") # GitHub example (organization repository) repo, response = create_repo(gh, "my-org"; name="org-repo", description="Organization repository", private=true) println("Created: $(repo.full_name)") # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) project, response = create_repo(gl; name="my-project", description="A new GitLab project", visibility="private", initialize_with_readme=true) println("Created project ID: $(project.id)") ``` ### Response #### Success Response (201) - **html_url** (string) - The URL of the created repository. - **full_name** (string) - The full name of the created repository. - **id** (integer) - The unique identifier of the created project (GitLab specific). ``` ```APIDOC ## GET /repos/{owner}/{repo}/contents/{path} ### Description Retrieves the contents of a file within a repository. ### Method GET ### Endpoint `/repos/{owner}/{repo}/contents/{path}` ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **path** (string) - Required - The path to the file within the repository. - **project_id** (integer) - Required (GitLab specific) - The ID of the project. ### Request Example ```julia # GitHub example using GitForge using GitForge.GitHub using Base64 gh = GitHubAPI(token=Token("your_token")) file, response = get_file_contents(gh, "owner", "repo", "README.md") println("File: $(file.name)") content = String(base64decode(file.content)) println("Content:\n$content") # GitLab example (by project ID) using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) file, response = get_file_contents(gl, 12345, "src/main.jl") content = String(base64decode(file.content)) println("File content:\n$content") ``` ### Response #### Success Response (200) - **name** (string) - The name of the file. - **size** (integer) - The size of the file in bytes. - **sha** (string) - The SHA of the file. - **content** (string) - The base64 encoded content of the file. - **commit_id** (string) - The commit ID of the file (GitLab specific). ``` -------------------------------- ### GET /user Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve the currently authenticated user or a specific user by name or ID. ```APIDOC ## GET /user ### Description Get the currently authenticated user or retrieve a user by name or ID. ### Method GET ### Endpoint /user ### Parameters #### Path Parameters - **username/id** (String/Int) - Optional - The username or ID of the user to retrieve. ### Response #### Success Response (200) - **user** (Object) - The user object containing details like login, email, name, bio, etc. - **response** (Object) - The raw HTTP response. ``` -------------------------------- ### GET /api/commits/{sha} Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves details about a specific commit. ```APIDOC ## GET /api/commits/{sha} ### Description Get details about a specific commit. ### Method GET ### Endpoint `/api/commits/{sha}` ### Parameters #### Path Parameters - **sha** (string) - Required - The SHA of the commit. - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. ### Response #### Success Response (200) - **commit** (object) - The commit object. - **response** (object) - The HTTP response object. #### Response Example ```json { "sha": "abc123def456", "message": "Fix bug #123", "author": {"name": "Author Name", "date": "2023-01-01T12:00:00Z"} } ``` ``` -------------------------------- ### Get All GitLab Users Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve a list of all users on the GitLab forge. This operation typically requires administrator privileges. ```julia using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("admin_token")) users, response = get_users(gl) for user in users println("$(user.username) ($(user.state))") end ``` -------------------------------- ### Get All GitHub Users Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve a list of all users on the GitHub forge. This operation may require administrative privileges on some platforms. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get list of users users, response = get_users(gh) for user in users println("$(user.login) - $(user.html_url)") end ``` -------------------------------- ### Get GitHub User Information Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve the currently authenticated user or a specific user by their username. Requires a GitHub API client instance. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get authenticated user user, response = get_user(gh) println("Logged in as: $(user.login)") println("Email: $(user.email)") println("Public repos: $(user.public_repos)") # Get user by username user, response = get_user(gh, "octocat") println("User: $(user.name)") println("Bio: $(user.bio)") println("Followers: $(user.followers)") ``` -------------------------------- ### GET /api/pull_requests/{id} Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves a specific pull request by its ID. ```APIDOC ## GET /api/pull_requests/{id} ### Description Get a specific pull request by number. ### Method GET ### Endpoint `/api/pull_requests/{id}` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the pull request. - **project_id** (integer) - Required - The ID of the project (for GitLab). - **mr_iid** (integer) - Required - The internal ID of the merge request (for GitLab). - **owner** (string) - Required - The owner of the repository (for GitHub). - **repo** (string) - Required - The name of the repository (for GitHub). ### Request Example ```json { "owner": "JuliaLang", "repo": "julia", "id": 12345 } ``` ### Response #### Success Response (200) - **pr** (object) - The pull request object. - **response** (object) - The HTTP response object. #### Response Example ```json { "title": "Update README", "state": "open", "mergeable": true, "additions": 10, "deletions": 5, "changed_files": 2 } ``` ``` -------------------------------- ### GET /api/pull_requests/{id}/comments Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves all comments on a pull request. ```APIDOC ## GET /api/pull_requests/{id}/comments ### Description Get all comments on a pull request. ### Method GET ### Endpoint `/api/pull_requests/{id}/comments` ### Parameters #### Path Parameters - **id** (integer) - Required - The ID of the pull request. - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. ### Response #### Success Response (200) - **comments** (array) - A list of comment objects. - **response** (object) - The HTTP response object. #### Response Example ```json [ { "id": 1, "user": {"login": "user1"}, "body": "LGTM!", "created_at": "2023-01-01T12:00:00Z" } ] ``` ``` -------------------------------- ### Get GitLab User Information by ID Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve a GitLab user by their unique ID. Requires a GitLab API client instance. ```julia using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) user, response = get_user(gl, 12345) println("Username: $(user.username)") println("State: $(user.state)") ``` -------------------------------- ### GET /api/pull_requests Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves a list of pull requests for a given project ID or owner/repository combination. ```APIDOC ## GET /api/pull_requests ### Description Retrieves a list of pull requests for a given project ID or owner/repository combination. ### Method GET ### Endpoint `/api/pull_requests` ### Parameters #### Query Parameters - **project_id** (integer) - Required - The ID of the project. - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. ### Request Example ```json { "project_id": 12345 } ``` ### Response #### Success Response (200) - **mrs** (array) - A list of pull request objects. - **response** (object) - The HTTP response object. #### Response Example ```json { "mrs": [ { "iid": 1, "title": "Initial commit", "author": {"username": "user1"}, "merge_status": "can_be_merged" } ], "response": {} } ``` ``` -------------------------------- ### Branch Operations Source: https://context7.com/juliaweb/gitforge.jl/llms.txt APIs for managing branches within a repository, including getting branch information, listing all branches, and deleting branches. ```APIDOC ## GET /repos/{owner}/{repo}/branches/{branch} ### Description Retrieves information about a specific branch in a repository. ### Method GET ### Endpoint `/repos/{owner}/{repo}/branches/{branch}` ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **branch** (string) - Required - The name of the branch. ### Request Example ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) branch, response = get_branch(gh, "owner", "repo", "main") println("Branch: $(branch.name)") println("Protected: $(branch.protected)") println("Commit SHA: $(branch.commit.sha)") ``` ### Response #### Success Response (200) - **name** (string) - The name of the branch. - **protected** (boolean) - Indicates if the branch is protected. - **commit.sha** (string) - The SHA of the latest commit on the branch. ``` ```APIDOC ## GET /repos/{owner}/{repo}/branches ### Description Retrieves a list of all branches for a repository. ### Method GET ### Endpoint `/repos/{owner}/{repo}/branches` ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. ### Request Example ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) branches, response = get_branches(gh, "owner", "repo") for branch in branches println("$(branch.name) - $(branch.commit.sha[1:7])") end ``` ### Response #### Success Response (200) - **name** (string) - The name of the branch. - **commit.sha** (string) - The SHA of the latest commit on the branch. ``` ```APIDOC ## DELETE /repos/{owner}/{repo}/branches/{branch} ### Description Deletes a specific branch from a repository. ### Method DELETE ### Endpoint `/repos/{owner}/{repo}/branches/{branch}` ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **branch** (string) - Required - The name of the branch to delete. ### Request Example ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) delete_branch(gh, "owner", "repo", "feature-branch") println("Branch deleted") ``` ### Response #### Success Response (204) No content is returned upon successful deletion. ``` -------------------------------- ### Create Repository Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Initializes a new repository or project on GitHub or GitLab with specified configuration options. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Create personal repository repo, response = create_repo(gh; name="my-new-repo", description="A new repository", private=false, auto_init=true, gitignore_template="Julia" ) println("Created: $(repo.html_url)") # Create repository in organization repo, response = create_repo(gh, "my-org"; name="org-repo", description="Organization repository", private=true ) println("Created: $(repo.full_name)") # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) project, response = create_repo(gl; name="my-project", description="A new GitLab project", visibility="private", initialize_with_readme=true ) println("Created project ID: $(project.id)") ``` -------------------------------- ### POST /users Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Create a new user account (GitLab admin only). ```APIDOC ## POST /users ### Description Create a new user (GitLab admin only). ### Method POST ### Endpoint /users ### Request Body - **email** (String) - Required - User email address - **username** (String) - Required - Unique username - **name** (String) - Required - Full name - **password** (String) - Required - User password - **skip_confirmation** (Bool) - Optional - Skip email confirmation ### Response #### Success Response (200) - **user** (Object) - The created user object. - **response** (Object) - The raw HTTP response. ``` -------------------------------- ### Create GitLab API Client Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Instantiate a GitLab API client. Supports unauthenticated access, personal access tokens, OAuth2 bearer tokens, and custom URLs for self-hosted GitLab instances. Rate limit handling can be configured. ```julia using GitForge using GitForge.GitLab # Unauthenticated client gl = GitLabAPI() # With personal access token gl = GitLabAPI(token=PersonalAccessToken("glpat-xxxxxxxxxxxx")) # With OAuth2 bearer token gl = GitLabAPI(token=OAuth2Token("oauth2_bearer_token")) # Self-hosted GitLab instance gl = GitLabAPI( token=PersonalAccessToken("your_token"), url="https://gitlab.mycompany.com/api/v4" ) # Configure rate limit handling gl = GitLabAPI( token=PersonalAccessToken("your_token"), has_rate_limits=true, on_rate_limit=ORL_THROW # Throw RateLimitedError when rate limited ) ``` -------------------------------- ### Configure Rate Limiting Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Sets up behavior for handling API rate limits, including throwing errors or automatic waiting. ```julia using GitForge using GitForge.GitHub # Throw error when rate limited (default) gh = GitHubAPI( token=Token("your_token"), has_rate_limits=true, on_rate_limit=ORL_THROW ) # Automatic waiting when rate limited gh = GitHubAPI( token=Token("your_token"), has_rate_limits=true, on_rate_limit=ORL_WAIT ) # Handle rate limit errors try users, response = get_users(gh) catch e if e isa RateLimitedError println("Rate limited! Wait $(e.period) before retrying") else rethrow(e) end end # Disable rate limit checking (for internal/unlimited APIs) gh = GitHubAPI( token=Token("your_token"), url="https://internal-github.company.com/api/v3", has_rate_limits=false ) ``` -------------------------------- ### Handle API Exceptions Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Demonstrates catching and inspecting specific API error types. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) try repo, response = get_repo(gh, "nonexistent", "repo") catch e if e isa HTTPError println("HTTP Error: $(e.response.status)") println("Message: $(String(e.response.body))") elseif e isa PostProcessorError println("Failed to parse response") println("Raw body: $(String(e.response.body))") elseif e isa RateLimitedError println("Rate limited for $(e.period)") else rethrow(e) end end # Check response status directly user, response = get_user(gh) println("Status: $(response.status)") println("Headers: $(response.headers)") ``` -------------------------------- ### Create GitHub API Client Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Instantiate a GitHub API client. Supports unauthenticated access, personal access tokens, OAuth2 tokens, JWT for GitHub Apps, and custom URLs for GitHub Enterprise. Rate limit behavior can also be configured. ```julia using GitForge using GitForge.GitHub # Unauthenticated client (public data only) gh = GitHubAPI() # With personal access token gh = GitHubAPI(token=Token("ghp_your_token_here")) # With OAuth2 token gh = GitHubAPI(token=Token("oauth2_access_token")) # With JWT for GitHub Apps gh = GitHubAPI(token=JWT("eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...")) # GitHub Enterprise with custom URL gh = GitHubAPI( token=Token("your_token"), url="https://github.mycompany.com/api/v3" ) # Configure rate limit behavior gh = GitHubAPI( token=Token("your_token"), has_rate_limits=true, on_rate_limit=ORL_WAIT # Wait instead of throwing error ) ``` -------------------------------- ### Retrieve Repository Tags Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Fetches all tags from a repository for both GitHub and GitLab providers. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # List tags tags, response = get_tags(gh, "JuliaLang", "julia") for tag in tags println("$(tag.name) - $(tag.commit.sha[1:7])") end # GitLab example using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) tags, response = get_tags(gl, 12345) for tag in tags println("$(tag.name): $(tag.message)") end ``` -------------------------------- ### Create GitLab User Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Create a new user account on a GitLab instance. This function is restricted to GitLab administrators. ```julia using GitForge using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("admin_token")) # Create new user user, response = create_user(gl; email="newuser@example.com", username="newuser", name="New User", password="securepassword123", skip_confirmation=true ) println("Created user ID: $(user.id)") ``` -------------------------------- ### Custom Endpoints Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Creating and using custom API endpoint configurations. ```APIDOC ## Custom Endpoints ### Endpoint Configuration Create custom endpoint configurations for advanced use cases. ### Description Allows defining custom HTTP methods, paths, headers, and query parameters for making specific API requests. ### Usage ```julia using GitForge using GitForge: Endpoint, request using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Create custom endpoint ep = Endpoint( :GET, "/repos/owner/repo/stargazers"; headers=["Accept" => "application/vnd.github.v3.star+json"], query=Dict("per_page" => 100) ) # Make request with custom endpoint result, response = request(gh, get_user, ep) println("Request completed with status: $(response.status)") ``` ### Endpoint Definition - **method** (:GET, :POST, etc.) - The HTTP method for the request. - **path** (string) - The endpoint path. - **headers** (Dict) - Optional headers for the request. - **query** (Dict) - Optional query parameters for the request. ``` -------------------------------- ### List Repository Branches Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves a list of all branches available in a repository. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # List all branches branches, response = get_branches(gh, "owner", "repo") for branch in branches println("$(branch.name) - $(branch.commit.sha[1:7])") end ``` -------------------------------- ### Create Pull Request Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Create a new pull request or merge request with specified parameters. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Create pull request pr, response = create_pull_request(gh, "owner", "repo"; title="Add new feature", body="This PR adds a new feature\n\n- Feature 1\n- Feature 2", head="feature-branch", base="main", draft=false ) println("Created PR #$(pr.number): $(pr.html_url)") # GitLab merge request using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) mr, response = create_pull_request(gl, 12345; title="Add new feature", description="Detailed description of changes", source_branch="feature-branch", target_branch="main", remove_source_branch=true ) println("Created MR !$(mr.iid): $(mr.web_url)") ``` -------------------------------- ### Pagination Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Utilities for handling paginated API results. ```APIDOC ## Pagination ### @paginate Macro Iterate through paginated API results using the `@paginate` macro. ### Description The `@paginate` macro simplifies fetching paginated data by automatically handling page increments and response parsing. ### Usage ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Paginate through all users paginator = @paginate get_users(gh) per_page=50 # Iterate through results count = 0 for (user, response) in paginator count += 1 println("$count: $(user.login)") count >= 200 && break # Stop after 200 users end # Collect all results into array repos = collect(@paginate get_user_repos(gh) per_page=100) println("Total repos: $(length(repos))") # Paginate with starting page paginator = @paginate get_pull_requests(gh, "owner", "repo") page=2 per_page=30 for (pr, response) in paginator println("#$(pr.number): $(pr.title)") end ``` ``` -------------------------------- ### List Pull Requests Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieve pull requests by project ID or by owner and repository name. ```julia # By project ID mrs, response = get_pull_requests(gl, 12345) for mr in mrs println("!$(mr.iid): $(mr.title)") println(" Author: $(mr.author.username)") println(" Status: $(mr.merge_status)") end # By owner/repo mrs, response = get_pull_requests(gl, "owner", "repo") ``` -------------------------------- ### Retrieve GitLab Commit Details Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Fetches commit information from a GitLab repository using a personal access token. ```julia using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) commit, response = get_commit(gl, 12345, "abc123def456") println("Title: $(commit.title)") println("Stats: +$(commit.stats.additions) -$(commit.stats.deletions)") ``` -------------------------------- ### Repository and Pull Request Endpoints Source: https://github.com/juliaweb/gitforge.jl/blob/master/docs/src/index.md Functions for interacting with repositories, branches, files, and pull requests. ```APIDOC ## GET /get_repo ### Description Retrieves details for a specific repository. ### Method GET ### Endpoint get_repo(api::Forge, repo) ## GET /get_pull_requests ### Description Retrieves a list of pull requests for a repository. ### Method GET ### Endpoint get_pull_requests(api::Forge, repo) ## POST /create_pull_request ### Description Creates a new pull request in a repository. ### Method POST ### Endpoint create_pull_request(api::Forge, repo, pr_data) ## GET /get_file_contents ### Description Retrieves the contents of a file from a repository. ### Method GET ### Endpoint get_file_contents(api::Forge, repo, path) ``` -------------------------------- ### Paginate API Results Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Iterates through paginated API responses using the @paginate macro. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Paginate through all users paginator = @paginate get_users(gh) per_page=50 # Iterate through results count = 0 for (user, response) in paginator count += 1 println("$count: $(user.login)") count >= 200 && break # Stop after 200 users end # Collect all results into array repos = collect(@paginate get_user_repos(gh) per_page=100) println("Total repos: $(length(repos))") # Paginate with starting page paginator = @paginate get_pull_requests(gh, "owner", "repo") page=2 per_page=30 for (pr, response) in paginator println("#$(pr.number): $(pr.title)") end ``` -------------------------------- ### PUT /user Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Update user profile information. ```APIDOC ## PUT /user ### Description Update user information. ### Method PUT ### Endpoint /user ### Parameters #### Path Parameters - **id** (Int) - Optional - User ID for admin updates. ### Request Body - **name** (String) - Optional - New name - **bio** (String) - Optional - New bio - **company** (String) - Optional - New company - **location** (String) - Optional - New location - **blog** (String) - Optional - New blog URL ### Response #### Success Response (200) - **user** (Object) - The updated user object. - **response** (Object) - The raw HTTP response. ``` -------------------------------- ### User Management Endpoints Source: https://github.com/juliaweb/gitforge.jl/blob/master/docs/src/index.md Functions for retrieving, updating, creating, and deleting user information across supported forges. ```APIDOC ## GET /get_user ### Description Retrieves information for a specific user. ### Method GET ### Endpoint get_user(api::Forge, user) ### Response - **T** (User) - The user object specific to the forge. - **HTTP.Response** - The raw HTTP response. ## GET /get_users ### Description Retrieves a list of users. ### Method GET ### Endpoint get_users(api::Forge) ## POST /create_user ### Description Creates a new user account. ### Method POST ### Endpoint create_user(api::Forge, user_data) ## PUT /update_user ### Description Updates an existing user's information. ### Method PUT ### Endpoint update_user(api::Forge, user, user_data) ## DELETE /delete_user ### Description Deletes a user account. ### Method DELETE ### Endpoint delete_user(api::Forge, user) ``` -------------------------------- ### List Pull Requests Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Retrieves pull requests or merge requests for a repository, optionally filtered by state. ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Get open pull requests prs, response = get_pull_requests(gh, "JuliaLang", "julia"; state="open") for pr in prs println("#$(pr.number): $(pr.title)") println(" By: $(pr.user.login)") println(" State: $(pr.state)") end # GitLab merge requests using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) ``` -------------------------------- ### Define Custom Endpoints Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Configures custom API endpoints with specific headers and query parameters. ```julia using GitForge using GitForge: Endpoint, request using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) # Create custom endpoint ep = Endpoint( :GET, "/repos/owner/repo/stargazers"; headers=["Accept" => "application/vnd.github.v3.star+json"], query=Dict("per_page" => 100) ) # Make request with custom endpoint result, response = request(gh, get_user, ep) println("Request completed with status: $(response.status)") ``` -------------------------------- ### Rate Limiting Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Configuration and handling of API rate limits. ```APIDOC ## Rate Limiting ### RateLimiter Configuration Configure and handle API rate limits using `GitHubAPI` parameters. ### Parameters - **has_rate_limits** (Bool) - Set to `true` to enable rate limit checking. - **on_rate_limit** (Enum: `ORL_THROW`, `ORL_WAIT`) - Defines behavior when rate limit is hit. `ORL_THROW` raises an error, `ORL_WAIT` automatically waits. ### Usage ```julia using GitForge using GitForge.GitHub # Throw error when rate limited (default) gh = GitHubAPI( token=Token("your_token"), has_rate_limits=true, on_rate_limit=ORL_THROW ) # Automatic waiting when rate limited gh = GitHubAPI( token=Token("your_token"), has_rate_limits=true, on_rate_limit=ORL_WAIT ) # Handle rate limit errors try users, response = get_users(gh) catch e if e isa RateLimitedError println("Rate limited! Wait $(e.period) before retrying") else rethrow(e) end end # Disable rate limit checking (for internal/unlimited APIs) gh = GitHubAPI( token=Token("your_token"), url="https://internal-github.company.com/api/v3", has_rate_limits=false ) ``` ``` -------------------------------- ### Error Handling Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Handling various API exceptions and response statuses. ```APIDOC ## Error Handling ### Exception Types Handle different types of errors from API operations. ### Description GitForge provides specific exception types for common API errors, allowing for granular error handling. ### Usage ```julia using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) try repo, response = get_repo(gh, "nonexistent", "repo") catch e if e isa HTTPError println("HTTP Error: $(e.response.status)") println("Message: $(String(e.response.body))") elseif e isa PostProcessorError println("Failed to parse response") println("Raw body: $(String(e.response.body))") elseif e isa RateLimitedError println("Rate limited for $(e.period)") else rethrow(e) end end # Check response status directly user, response = get_user(gh) println("Status: $(response.status)") println("Headers: $(response.headers)") ``` ### Exception Types - **HTTPError**: For general HTTP request errors. - **PostProcessorError**: When response parsing fails. - **RateLimitedError**: When the API rate limit is exceeded. ``` -------------------------------- ### Subscribe to Pull Request Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Subscribe to notifications for a specific GitLab merge request. ```julia using GitForge using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) # Subscribe to MR notifications mr, response = subscribe_to_pull_request(gl, 12345, 1) println("Subscribed to MR !$(mr.iid)") println("Subscribed: $(mr.subscribed)") ``` -------------------------------- ### Pull Request / Merge Request Operations Source: https://context7.com/juliaweb/gitforge.jl/llms.txt APIs for managing pull requests (GitHub) and merge requests (GitLab), including listing open pull requests. ```APIDOC ## GET /repos/{owner}/{repo}/pulls ### Description Lists pull requests for a repository. ### Method GET ### Endpoint `/repos/{owner}/{repo}/pulls` ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. #### Query Parameters - **state** (string) - Optional - The state of the pull requests to retrieve ('open', 'closed', or 'all'). Defaults to 'open'. ### Request Example ```julia # GitHub example using GitForge using GitForge.GitHub gh = GitHubAPI(token=Token("your_token")) prs, response = get_pull_requests(gh, "JuliaLang", "julia"; state="open") for pr in prs println("#$(pr.number): $(pr.title)") println(" By: $(pr.user.login)") println(" State: $(pr.state)") end # GitLab example (merge requests) using GitForge.GitLab gl = GitLabAPI(token=PersonalAccessToken("your_token")) # Note: The function signature for GitLab merge requests might differ slightly. # Example assumes a similar function exists for GitLab. # merge_requests, response = get_merge_requests(gl, "group/project") ``` ### Response #### Success Response (200) - **number** (integer) - The number of the pull request. - **title** (string) - The title of the pull request. - **user.login** (string) - The login name of the user who created the pull request. - **state** (string) - The state of the pull request ('open' or 'closed'). ``` -------------------------------- ### POST /api/pull_requests Source: https://context7.com/juliaweb/gitforge.jl/llms.txt Creates a new pull request or merge request. ```APIDOC ## POST /api/pull_requests ### Description Create a new pull request. ### Method POST ### Endpoint `/api/pull_requests` ### Parameters #### Query Parameters - **owner** (string) - Required - The owner of the repository (for GitHub). - **repo** (string) - Required - The name of the repository (for GitHub). - **project_id** (integer) - Required - The ID of the project (for GitLab). #### Request Body - **title** (string) - Required - The title of the pull request. - **body** (string) - Optional - The description of the pull request. - **head** (string) - Required - The name of the branch where your changes are implemented (for GitHub). - **base** (string) - Required - The name of the branch you want the changes pulled into (for GitHub). - **source_branch** (string) - Required - The source branch name (for GitLab). - **target_branch** (string) - Required - The target branch name (for GitLab). - **draft** (boolean) - Optional - Indicates whether the pull request is a draft (for GitHub). - **remove_source_branch** (boolean) - Optional - Whether to delete the source branch after merging (for GitLab). ### Request Example ```json { "title": "Add new feature", "body": "This PR adds a new feature\n\n- Feature 1\n- Feature 2", "head": "feature-branch", "base": "main" } ``` ### Response #### Success Response (200) - **pr** (object) - The created pull request object. - **response** (object) - The HTTP response object. #### Response Example ```json { "number": 1, "html_url": "https://github.com/owner/repo/pull/1" } ``` ```