ebf98f27c4
Enables frozen string for the following: * lib/gitlab/fogbugz_import/**/*.rb * lib/gitlab/gfm/**/*.rb * lib/gitlab/git/**/*.rb * lib/gitlab/gitaly_client/**/*.rb * lib/gitlab/gitlab_import/**/*.rb * lib/gitlab/google_code_import/**/*.rb * lib/gitlab/gpg/**/*.rb * lib/gitlab/grape_logging/**/*.rb * lib/gitlab/graphql/**/*.rb * lib/gitlab/graphs/**/*.rb * lib/gitlab/hashed_storage/**/*.rb * lib/gitlab/health_checks/**/*.rb Partially address gitlab-org/gitlab-ce#47424.
41 lines
1.2 KiB
Ruby
41 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Gitlab
|
|
module GitalyClient
|
|
class NamespaceService
|
|
def initialize(storage)
|
|
@storage = storage
|
|
end
|
|
|
|
def exists?(name)
|
|
request = Gitaly::NamespaceExistsRequest.new(storage_name: @storage, name: name)
|
|
|
|
gitaly_client_call(:namespace_exists, request, timeout: GitalyClient.fast_timeout).exists
|
|
end
|
|
|
|
def add(name)
|
|
request = Gitaly::AddNamespaceRequest.new(storage_name: @storage, name: name)
|
|
|
|
gitaly_client_call(:add_namespace, request, timeout: GitalyClient.fast_timeout)
|
|
end
|
|
|
|
def remove(name)
|
|
request = Gitaly::RemoveNamespaceRequest.new(storage_name: @storage, name: name)
|
|
|
|
gitaly_client_call(:remove_namespace, request, timeout: nil)
|
|
end
|
|
|
|
def rename(from, to)
|
|
request = Gitaly::RenameNamespaceRequest.new(storage_name: @storage, from: from, to: to)
|
|
|
|
gitaly_client_call(:rename_namespace, request, timeout: GitalyClient.fast_timeout)
|
|
end
|
|
|
|
private
|
|
|
|
def gitaly_client_call(type, request, timeout: nil)
|
|
GitalyClient.call(@storage, :namespace_service, type, request, timeout: timeout)
|
|
end
|
|
end
|
|
end
|
|
end
|