Class: Gitlab::Client

Inherits:
API show all
Includes:
AccessRequests, ApplicationSettings, Avatar, AwardEmojis, Boards, Branches, BroadcastMessages, BuildVariables, Builds, Commits, ContainerRegistry, Deployments, Environments, EpicIssues, Epics, Events, Features, GroupBadges, GroupBoards, GroupLabels, GroupMilestones, Groups, IssueLinks, Issues, Jobs, Keys, Labels, Lint, Markdown, MergeRequestApprovals, MergeRequests, MergeTrains, Milestones, Namespaces, Notes, Packages, PipelineSchedules, PipelineTriggers, Pipelines, ProjectBadges, ProjectClusters, ProjectExports, ProjectReleaseLinks, ProjectReleases, Projects, ProtectedTags, RemoteMirrors, Repositories, RepositoryFiles, RepositorySubmodules, ResourceLabelEvents, ResourceStateEvents, Runners, Search, Services, Sidekiq, Snippets, SystemHooks, Tags, Templates, Todos, UserSnippets, Users, Versions, Wikis
Defined in:
lib/gitlab/client.rb,
lib/gitlab/client/jobs.rb,
lib/gitlab/client/keys.rb,
lib/gitlab/client/lint.rb,
lib/gitlab/client/tags.rb,
lib/gitlab/client/epics.rb,
lib/gitlab/client/notes.rb,
lib/gitlab/client/todos.rb,
lib/gitlab/client/users.rb,
lib/gitlab/client/wikis.rb,
lib/gitlab/client/avatar.rb,
lib/gitlab/client/boards.rb,
lib/gitlab/client/builds.rb,
lib/gitlab/client/events.rb,
lib/gitlab/client/groups.rb,
lib/gitlab/client/issues.rb,
lib/gitlab/client/labels.rb,
lib/gitlab/client/search.rb,
lib/gitlab/client/commits.rb,
lib/gitlab/client/runners.rb,
lib/gitlab/client/sidekiq.rb,
lib/gitlab/client/branches.rb,
lib/gitlab/client/features.rb,
lib/gitlab/client/markdown.rb,
lib/gitlab/client/packages.rb,
lib/gitlab/client/projects.rb,
lib/gitlab/client/services.rb,
lib/gitlab/client/snippets.rb,
lib/gitlab/client/versions.rb,
lib/gitlab/client/pipelines.rb,
lib/gitlab/client/templates.rb,
lib/gitlab/client/milestones.rb,
lib/gitlab/client/namespaces.rb,
lib/gitlab/client/deployments.rb,
lib/gitlab/client/epic_issues.rb,
lib/gitlab/client/issue_links.rb,
lib/gitlab/client/award_emojis.rb,
lib/gitlab/client/environments.rb,
lib/gitlab/client/group_badges.rb,
lib/gitlab/client/group_boards.rb,
lib/gitlab/client/group_labels.rb,
lib/gitlab/client/merge_trains.rb,
lib/gitlab/client/repositories.rb,
lib/gitlab/client/system_hooks.rb,
lib/gitlab/client/user_snippets.rb,
lib/gitlab/client/merge_requests.rb,
lib/gitlab/client/project_badges.rb,
lib/gitlab/client/protected_tags.rb,
lib/gitlab/client/remote_mirrors.rb,
lib/gitlab/client/access_requests.rb,
lib/gitlab/client/build_variables.rb,
lib/gitlab/client/project_exports.rb,
lib/gitlab/client/group_milestones.rb,
lib/gitlab/client/project_clusters.rb,
lib/gitlab/client/project_releases.rb,
lib/gitlab/client/repository_files.rb,
lib/gitlab/client/pipeline_triggers.rb,
lib/gitlab/client/broadcast_messages.rb,
lib/gitlab/client/container_registry.rb,
lib/gitlab/client/pipeline_schedules.rb,
lib/gitlab/client/application_settings.rb,
lib/gitlab/client/project_release_links.rb,
lib/gitlab/client/repository_submodules.rb,
lib/gitlab/client/resource_label_events.rb,
lib/gitlab/client/resource_state_events.rb,
lib/gitlab/client/merge_request_approvals.rb

Overview

Wrapper for the Gitlab REST API.

Defined Under Namespace

Modules: AccessRequests, ApplicationSettings, Avatar, AwardEmojis, Boards, Branches, BroadcastMessages, BuildVariables, Builds, Commits, ContainerRegistry, Deployments, Environments, EpicIssues, Epics, Events, Features, GroupBadges, GroupBoards, GroupLabels, GroupMilestones, Groups, IssueLinks, Issues, Jobs, Keys, Labels, Lint, Markdown, MergeRequestApprovals, MergeRequests, MergeTrains, Milestones, Namespaces, Notes, Packages, PipelineSchedules, PipelineTriggers, Pipelines, ProjectBadges, ProjectClusters, ProjectExports, ProjectReleaseLinks, ProjectReleases, Projects, ProtectedTags, RemoteMirrors, Repositories, RepositoryFiles, RepositorySubmodules, ResourceLabelEvents, ResourceStateEvents, Runners, Search, Services, Sidekiq, Snippets, SystemHooks, Tags, Templates, Todos, UserSnippets, Users, Versions, Wikis

Instance Attribute Summary

Attributes inherited from Request

#endpoint, #private_token

Instance Method Summary collapse

Methods included from Wikis

#create_wiki, #delete_wiki, #update_wiki, #wiki, #wikis

Methods included from Versions

#version

Methods included from UserSnippets

#create_user_snippet, #delete_user_snippet, #edit_user_snippet, #public_snippets, #snippet_user_agent_details, #user_snippet, #user_snippet_raw, #user_snippets

Methods included from Users

#activate_user, #activities, #add_email, #add_user_custom_attribute, #approve_user, #block_user, #create_personal_access_token, #create_service_account, #create_ssh_key, #create_user, #create_user_impersonation_token, #deactivate_user, #delete_email, #delete_ssh_key, #delete_user, #delete_user_custom_attribute, #disable_two_factor, #edit_user, #email, #emails, #memberships, #revoke_personal_access_token, #revoke_user_impersonation_token, #rotate_personal_access_token, #session, #ssh_key, #ssh_keys, #unblock_user, #user, #user_by_username, #user_custom_attribute, #user_custom_attributes, #user_impersonation_token, #user_impersonation_tokens, #user_personal_access_tokens, #user_search, #users

Methods included from Todos

#mark_all_todos_as_done, #mark_todo_as_done, #todos

Methods included from Templates

#dockerfile_template, #dockerfile_templates, #gitignore_template, #gitignore_templates, #gitlab_ci_yml_template, #gitlab_ci_yml_templates, #license_template, #license_templates

Methods included from Tags

#create_release, #create_tag, #delete_tag, #tag, #tags, #update_release

Methods included from SystemHooks

#add_hook, #delete_hook, #hook, #hooks

Methods included from Snippets

#create_snippet, #delete_snippet, #edit_snippet, #snippet, #snippet_content, #snippets

Methods included from Sidekiq

#sidekiq_compound_metrics, #sidekiq_job_stats, #sidekiq_process_metrics, #sidekiq_queue_metrics

Methods included from Services

#change_service, #delete_service, #service

Methods included from Search

#search_globally, #search_in_group, #search_in_project

Methods included from Runners

#all_runners, #create_group_runner, #create_instance_runner, #create_project_runner, #delete_registered_runner, #delete_runner, #group_runners, #project_disable_runner, #project_enable_runner, #project_runners, #register_runner, #runner, #runner_jobs, #runners, #update_runner, #verify_auth_registered_runner

Methods included from ResourceStateEvents

#issue_state_event, #issue_state_events, #merge_request_state_event, #merge_request_state_events

Methods included from ResourceLabelEvents

#epic_label_event, #epic_label_events, #issue_label_event, #issue_label_events, #merge_request_label_event, #merge_request_label_events

Methods included from RepositorySubmodules

#edit_submodule

Methods included from RepositoryFiles

#create_file, #edit_file, #file_contents, #get_file, #get_file_blame, #remove_file

Methods included from Repositories

#compare, #contributors, #generate_changelog, #get_changelog, #merge_base, #repo_archive, #tree

Methods included from RemoteMirrors

#create_remote_mirror, #edit_remote_mirror, #remote_mirrors

Methods included from ProtectedTags

#protect_repository_tag, #protected_tag, #protected_tags, #unprotect_repository_tag

Methods included from Projects

#add_project_custom_attribute, #add_project_hook, #add_push_rule, #add_team_member, #all_members, #archive_project, #create_deploy_key, #create_fork, #create_project, #delete_deploy_key, #delete_project, #delete_project_custom_attribute, #delete_project_hook, #delete_push_rule, #deploy_key, #deploy_keys, #disable_deploy_key, #edit_deploy_key, #edit_project, #edit_project_hook, #edit_push_rule, #edit_team_member, #enable_deploy_key, #make_forked_from, #project, #project_custom_attribute, #project_custom_attributes, #project_deploy_tokens, #project_forks, #project_hook, #project_hooks, #project_search, #project_template, #project_templates, #projects, #push_rule, #remove_forked, #remove_team_member, #share_project_with_group, #star_project, #team_member, #team_members, #transfer_project, #unarchive_project, #unshare_project_with_group, #unstar_project, #upload_file, #user_projects, #user_starred_projects

Methods included from ProjectReleases

#create_project_release, #delete_project_release, #project_latest_release, #project_release, #project_releases, #update_project_release

Methods included from ProjectReleaseLinks

#create_project_release_link, #delete_project_release_link, #project_release_link, #project_release_links, #update_project_release_link

Methods included from ProjectExports

#export_project, #export_project_status, #exported_project_download

Methods included from ProjectClusters

#add_project_cluster, #delete_project_cluster, #edit_project_cluster, #project_cluster, #project_clusters

Methods included from ProjectBadges

#add_project_badge, #edit_project_badge, #preview_project_badge, #project_badge, #project_badges, #remove_project_badge

Methods included from Pipelines

#cancel_pipeline, #create_pipeline, #delete_pipeline, #pipeline, #pipeline_test_report, #pipeline_variables, #pipelines, #retry_pipeline, #update_pipeline_metadata

Methods included from PipelineTriggers

#create_trigger, #remove_trigger, #run_trigger, #trigger, #trigger_take_ownership, #triggers, #update_trigger

Methods included from PipelineSchedules

#create_pipeline_schedule, #create_pipeline_schedule_variable, #delete_pipeline_schedule, #delete_pipeline_schedule_variable, #edit_pipeline_schedule, #edit_pipeline_schedule_variable, #pipeline_schedule, #pipeline_schedule_take_ownership, #pipeline_schedules, #run_pipeline_schedule

Methods included from Packages

#delete_project_package, #delete_project_package_file, #group_packages, #project_package, #project_package_files, #project_packages

Methods included from Notes

#create_epic_note, #create_issue_note, #create_merge_request_note, #create_note, #create_snippet_note, #delete_issue_note, #delete_merge_request_note, #delete_note, #delete_snippet_note, #edit_issue_note, #edit_merge_request_note, #edit_note, #edit_snippet_note, #epic_notes, #issue_note, #issue_notes, #merge_request_note, #merge_request_notes, #note, #notes, #snippet_note, #snippet_notes

Methods included from Namespaces

#namespaces

Methods included from Milestones

#create_milestone, #delete_milestone, #edit_milestone, #milestone, #milestone_issues, #milestone_merge_requests, #milestones

Methods included from MergeTrains

#add_merge_request_to_merge_train, #merge_train_merge_requests, #merge_train_status, #merge_trains

Methods included from MergeRequests

#accept_merge_request, #create_merge_request, #create_merge_request_discussion, #create_merge_request_discussion_note, #create_merge_request_pipeline, #delete_merge_request, #delete_merge_request_discussion_note, #merge_request, #merge_request_changes, #merge_request_closes_issues, #merge_request_commits, #merge_request_diff_version, #merge_request_diff_versions, #merge_request_diffs, #merge_request_discussion, #merge_request_discussions, #merge_request_participants, #merge_request_pipelines, #merge_requests, #rebase_merge_request, #resolve_merge_request_discussion, #subscribe_to_merge_request, #unsubscribe_from_merge_request, #update_merge_request, #update_merge_request_discussion_note, #user_merge_requests

Methods included from MergeRequestApprovals

#approve_merge_request, #create_merge_request_level_rule, #create_project_merge_request_approval_rule, #delete_merge_request_level_rule, #delete_project_merge_request_approval_rule, #edit_merge_request_approvals, #edit_merge_request_approvers, #edit_project_approvers, #edit_project_merge_request_approvals, #merge_request_approval_state, #merge_request_approvals, #merge_request_level_rule, #project_merge_request_approval_rules, #project_merge_request_approvals, #unapprove_merge_request, #update_merge_request_level_rule, #update_project_merge_request_approval_rule

Methods included from Markdown

#markdown

Methods included from Lint

#validate_gitlab_ci_yml

Methods included from Labels

#create_label, #delete_label, #edit_label, #labels, #subscribe_to_label, #unsubscribe_from_label

Methods included from Keys

#key, #key_by_fingerprint

Methods included from Jobs

#download_branch_artifact_file, #download_job_artifact_file, #job, #job_artifacts, #job_artifacts_delete, #job_artifacts_download, #job_artifacts_keep, #job_cancel, #job_erase, #job_play, #job_retry, #job_trace, #jobs, #pipeline_bridges, #pipeline_jobs

Methods included from Issues

#add_time_spent_on_issue, #close_issue, #create_issue, #delete_issue, #edit_issue, #estimate_time_of_issue, #issue, #issues, #merge_requests_closing_issue_on_merge, #move_issue, #participants_on_issue, #related_merge_requests, #reopen_issue, #reset_time_estimate_of_issue, #reset_time_spent_on_issue, #subscribe_to_issue, #time_stats_for_issue, #unsubscribe_from_issue

Methods included from IssueLinks

#create_issue_link, #delete_issue_link, #issue_links

Methods included from Groups

#add_group_custom_attribute, #add_group_hook, #add_group_member, #add_ldap_group_links, #all_group_members, #create_group, #delete_group, #delete_group_custom_attribute, #delete_group_hook, #delete_ldap_group_links, #edit_group, #edit_group_hook, #edit_group_member, #group, #group_billable_members, #group_custom_attribute, #group_custom_attributes, #group_descendants, #group_hook, #group_issues, #group_member, #group_members, #group_merge_requests, #group_projects, #group_search, #group_subgroups, #groups, #list_group_hooks, #remove_group_member, #sync_ldap_group, #transfer_project_to_group

Methods included from GroupMilestones

#create_group_milestone, #edit_group_milestone, #group_milestone, #group_milestone_issues, #group_milestone_merge_requests, #group_milestones

Methods included from GroupLabels

#create_group_label, #delete_group_label, #edit_group_label, #group_labels, #subscribe_to_group_label, #unsubscribe_from_group_label

Methods included from GroupBoards

#create_group_board, #create_group_board_list, #delete_group_board, #delete_group_board_list, #edit_group_board, #edit_group_board_list, #group_board, #group_board_list, #group_board_lists, #group_boards

Methods included from GroupBadges

#add_group_badge, #edit_group_badge, #group_badge, #group_badges, #preview_group_badge, #remove_group_badge

Methods included from Features

#delete_feature, #features, #set_feature

Methods included from Events

#events, #project_events, #user_events

Methods included from Epics

#create_epic, #delete_epic, #edit_epic, #epic, #epics

Methods included from EpicIssues

#epic_issues

Methods included from Environments

#create_environment, #delete_environment, #edit_environment, #environment, #environments, #stop_environment

Methods included from Deployments

#deployment, #deployments

Methods included from ContainerRegistry

#bulk_delete_registry_repository_tags, #delete_registry_repository, #delete_registry_repository_tag, #registry_repositories, #registry_repository_tag, #registry_repository_tags

Methods included from Commits

#cherry_pick_commit, #commit, #commit_comments, #commit_diff, #commit_merge_requests, #commit_refs, #commit_status, #commits, #create_commit, #create_commit_comment, #revert_commit, #update_commit_status

Methods included from Builds

#build, #build_artifacts, #build_cancel, #build_erase, #build_retry, #builds, #commit_builds

Methods included from BuildVariables

#create_group_variable, #create_variable, #group_variable, #group_variables, #remove_group_variable, #remove_variable, #update_group_variable, #update_variable, #variable, #variables

Methods included from BroadcastMessages

#broadcast_message, #broadcast_messages, #create_broadcast_message, #delete_broadcast_message, #edit_broadcast_message

Methods included from Branches

#branch, #branches, #create_branch, #delete_branch, #delete_merged_branches, #protect_branch, #protected_branch, #protected_branches, #unprotect_branch

Methods included from Boards

#board, #board_list, #board_lists, #boards, #create_board, #create_board_list, #delete_board, #delete_board_list, #edit_board, #edit_board_list

Methods included from AwardEmojis

#award_emoji, #award_emojis, #create_award_emoji, #create_note_award_emoji, #delete_award_emoji, #delete_note_award_emoji, #note_award_emoji, #note_award_emojis

Methods included from Avatar

#avatar

Methods included from ApplicationSettings

#application_settings, #edit_application_settings

Methods included from AccessRequests

#approve_group_access_request, #approve_project_access_request, #deny_group_access_request, #deny_project_access_request, #group_access_requests, #project_access_requests, #request_group_access, #request_project_access

Methods inherited from API

#initialize

Methods inherited from Request

decode, parse, #request_defaults, #validate

Constructor Details

This class inherits a constructor from Gitlab::API

Instance Method Details

#create_group_access_token(group_id, name, scopes, access_level = nil, expires_at = nil) ⇒ Gitlab::ObjectifiedHash

Create group access token

Examples:

Gitlab.create_group_access_token(2, "token", ["api", "read_user"])
Gitlab.create_group_access_token(2, "token", ["api", "read_user"], 20)
Gitlab.create_group_access_token(2, "token", ["api", "read_user"], 20, "1970-01-01")

Parameters:

  • group_id (Integer)

    The ID of the group.

  • name (String)

    Name for group access token.

  • scopes (Array<String>)

    Array of scopes for the group access token

  • access_level (Integer) (defaults to: nil)

    Project access level (10: Guest, 20: Reporter, 30: Developer, 40: Maintainer, 50: Owner).

  • expires_at (String) (defaults to: nil)

    Date for group access token expiration in ISO format.

Returns:



489
490
491
492
493
494
# File 'lib/gitlab/client/groups.rb', line 489

def create_group_access_token(group_id, name, scopes, access_level = nil, expires_at = nil)
  body = { name: name, scopes: scopes }
  body[:access_level] = access_level if access_level
  body[:expires_at] = expires_at if expires_at
  post("/groups/#{group_id}/access_tokens", body: body)
end

#group_access_token(group_id, group_access_token_id) ⇒ Gitlab::ObjectifiedHash

Get group access token information

Examples:

Gitlab.group_access_token(1, 1)

Parameters:

  • group_id (Integer)

    The ID of the group.

  • group_access_token_id (Integer)

    ID of the group access token.

Returns:



472
473
474
# File 'lib/gitlab/client/groups.rb', line 472

def group_access_token(group_id, group_access_token_id)
  get("/groups/#{group_id}/access_tokens/#{group_access_token_id}")
end

#group_access_tokens(group_id) ⇒ Array<Gitlab::ObjectifiedHash>

Get all access tokens for a group

Examples:

Gitlab.group_access_tokens(1)

Parameters:

  • group_id (Integer)

    The ID of the group.

Returns:



460
461
462
# File 'lib/gitlab/client/groups.rb', line 460

def group_access_tokens(group_id)
  get("/groups/#{group_id}/access_tokens")
end

#inspectString

Text representation of the client, masking private token.

Returns:

  • (String)


78
79
80
81
82
# File 'lib/gitlab/client.rb', line 78

def inspect
  inspected = super
  inspected.sub! @private_token, only_show_last_four_chars(@private_token) if @private_token
  inspected
end

#revoke_group_access_token(group_id, group_access_token_id) ⇒ Gitlab::ObjectifiedHash

Revoke a group access token

Examples:

Gitlab.revoke_group_access_token(1, 1)

Parameters:

  • user_id (Integer)

    The ID of the group.

  • group_access_token_id (Integer)

    ID of the group access token.

Returns:



504
505
506
# File 'lib/gitlab/client/groups.rb', line 504

def revoke_group_access_token(group_id, group_access_token_id)
  delete("/groups/#{group_id}/access_tokens/#{group_access_token_id}")
end

#url_encode(url) ⇒ String

Utility method for URL encoding of a string. Copied from ruby-doc.org/stdlib-2.7.0/libdoc/erb/rdoc/ERB/Util.html

Returns:

  • (String)


88
89
90
# File 'lib/gitlab/client.rb', line 88

def url_encode(url)
  url.to_s.b.gsub(/[^a-zA-Z0-9_\-.~]/n) { |m| sprintf('%%%02X', m.unpack1('C')) } # rubocop:disable Style/FormatString
end