Class: Gitlab::GitalyClient::NamespaceService
- Inherits:
-
Object
- Object
- Gitlab::GitalyClient::NamespaceService
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
TemporarilyAllow::TEMPORARILY_ALLOW_MUTEX
Class Method Summary
collapse
Instance Method Summary
collapse
temporarily_allow, temporarily_allowed?
Constructor Details
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
.allow ⇒ Object
11
12
13
|
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 11
def self.allow
temporarily_allow(ALLOW_KEY) { yield }
end
|
.denied? ⇒ 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
|
#exists?(name) ⇒ Boolean
43
44
45
46
47
48
|
# File 'lib/gitlab/gitaly_client/namespace_service.rb', line 43
def exists?(name)
request = Gitaly::NamespaceExistsRequest.new(storage_name: @storage, name: name)
response = gitaly_client_call(:namespace_exists, request, timeout: GitalyClient.fast_timeout)
response.exists
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
|