debian-mirror-gitlab/lib/gitlab/gitaly_client/namespace_service.rb

42 lines
1.2 KiB
Ruby
Raw Normal View History

2019-02-15 15:39:39 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module Gitlab
module GitalyClient
class NamespaceService
def initialize(storage)
@storage = storage
end
def exists?(name)
request = Gitaly::NamespaceExistsRequest.new(storage_name: @storage, name: name)
2018-11-08 19:23:39 +05:30
gitaly_client_call(:namespace_exists, request, timeout: GitalyClient.fast_timeout).exists
2018-03-17 18:26:18 +05:30
end
def add(name)
request = Gitaly::AddNamespaceRequest.new(storage_name: @storage, name: name)
2018-11-08 19:23:39 +05:30
gitaly_client_call(:add_namespace, request, timeout: GitalyClient.fast_timeout)
2018-03-17 18:26:18 +05:30
end
def remove(name)
request = Gitaly::RemoveNamespaceRequest.new(storage_name: @storage, name: name)
2018-11-08 19:23:39 +05:30
gitaly_client_call(:remove_namespace, request, timeout: nil)
2018-03-17 18:26:18 +05:30
end
def rename(from, to)
request = Gitaly::RenameNamespaceRequest.new(storage_name: @storage, from: from, to: to)
2018-11-08 19:23:39 +05:30
gitaly_client_call(:rename_namespace, request, timeout: GitalyClient.fast_timeout)
2018-03-17 18:26:18 +05:30
end
private
2018-11-08 19:23:39 +05:30
def gitaly_client_call(type, request, timeout: nil)
GitalyClient.call(@storage, :namespace_service, type, request, timeout: timeout)
2018-03-17 18:26:18 +05:30
end
end
end
end