Class: Gitlab::GitalyClient::NamespaceService

Inherits:
Object
  • Object
show all
Extended by:
TemporarilyAllow
Defined in:
lib/gitlab/gitaly_client/namespace_service.rb

Constant Summary collapse

NamespaceServiceAccessError =
Class.new(StandardError)
ALLOW_KEY =
:allow_namespace

Constants included from TemporarilyAllow

TemporarilyAllow::TEMPORARILY_ALLOW_MUTEX

Class Method Summary collapse

Instance Method Summary collapse

Methods included from TemporarilyAllow

temporarily_allow, temporarily_allowed?

Constructor Details

#initialize(storage) ⇒ NamespaceService

Returns a new instance of NamespaceService.


19
20
21
22
23
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 19

def initialize(storage)
  raise NamespaceServiceAccessError if self.class.denied?

  @storage = storage
end

Class Method Details

.allowObject


11
12
13
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 11

def self.allow
  temporarily_allow(ALLOW_KEY) { yield }
end

.denied?Boolean

Returns:

  • (Boolean)

15
16
17
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 15

def self.denied?
  !temporarily_allowed?(ALLOW_KEY)
end

Instance Method Details

#add(name) ⇒ Object


25
26
27
28
29
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 25

def add(name)
  request = Gitaly::AddNamespaceRequest.new(storage_name: @storage, name: name)

  gitaly_client_call(:add_namespace, request, timeout: GitalyClient.fast_timeout)
end

#remove(name) ⇒ Object


31
32
33
34
35
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 31

def remove(name)
  request = Gitaly::RemoveNamespaceRequest.new(storage_name: @storage, name: name)

  gitaly_client_call(:remove_namespace, request, timeout: GitalyClient.long_timeout)
end

#rename(from, to) ⇒ Object


37
38
39
40
41
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 37

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