1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
# frozen_string_literal: true
class Gitlab::Client
# Defines methods related to remote mirrors.
# @see https://docs.gitlab.com/ee/api/remote_mirrors.html
module RemoteMirrors
# List a project's remote mirrors
#
# @example
# Gitlab.remote_mirrors(42)
# Gitlab.remote_mirrors('gitlab-org/gitlab')
#
# @param [Integer, String] project The ID or name of a project.
# @return [Array<Gitlab::ObjectifiedHash>]
def remote_mirrors(project)
get("/projects/#{url_encode project}/remote_mirrors")
end
# Get a specific remote mirror.
#
# @example
# Gitlab.remote_mirror(42, 1234)
#
# @param [Integer, String] project The ID or path of a project.
# @param [Integer] id The ID of the remote mirror.
#
# @return [Gitlab::ObjectifiedHash] Information about the specified remote mirror.
def remote_mirror(project, id)
get("/projects/#{url_encode project}/remote_mirrors/#{id}")
end
# Create a remote mirror
#
# @example
# Gitlab.create_remote_mirror(42, 'https://mirror-bot@gitlab.com/gitlab-org/gitlab.git', enabled: true)
#
# @param [Integer, String] project The ID or name of a project.
# @param [String] url The full URL of the remote repository.
# @param [Hash] options A customizable set of options.
# @option options [Boolean] :enabled Determines if the mirror is enabled.
# @option options [Boolean] :only_protected_branches Determines if only protected branches are mirrored.
# @option options [Boolean] :keep_divergent_refs Determines if divergent refs are skipped.
# @return [Gitlab::ObjectifiedHash]
def create_remote_mirror(project, url, options = {})
post("/projects/#{url_encode project}/remote_mirrors", body: options.merge(url: url))
end
# Update a remote mirror's attributes
#
# @example
# Gitlab.edit_remote_mirror(42, 66, only_protected_branches: true)
#
# @param [Integer, String] project The ID or name of a project.
# @param [Integer] id The ID of the remote mirror.
# @param [Hash] options A customizable set of options.
# @option options [Boolean] :enabled Determines if the mirror is enabled.
# @option options [Boolean] :only_protected_branches Determines if only protected branches are mirrored.
# @option options [Boolean] :keep_divergent_refs Determines if divergent refs are skipped.
# @return [Gitlab::ObjectifiedHash]
def edit_remote_mirror(project, id, options = {})
put("/projects/#{url_encode project}/remote_mirrors/#{id}", body: options)
end
# Delete a remote mirror.
#
# @example
# Gitlab.delete_remote_mirror(42, 1234)
#
# @param [Integer, String] project The ID or path of a project.
# @param [Integer] id The ID of the remote mirror.
#
# @return [Gitlab::ObjectifiedHash]
def delete_remote_mirror(project, id)
delete("/projects/#{url_encode project}/remote_mirrors/#{id}")
end
# Force push mirror update.
#
# @example
# Gitlab.sync_remote_mirror(42, 1234)
#
# @param [Integer, String] project The ID or path of a project.
# @param [Integer] id The ID of the remote mirror.
#
# @return [Gitlab::ObjectifiedHash]
def sync_remote_mirror(project, id)
post("/projects/#{url_encode project}/remote_mirrors/#{id}/sync")
end
end
end
|