Class: BackupRepos::BackupGitlabEndpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/backup_repos/backup_gitlab_endpoint.rb

Constant Summary collapse

DEFAULT_ENDPOINT =
'https://gitlab.com/api/v4'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings) ⇒ BackupGitlabEndpoint



14
15
16
17
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 14

def initialize(settings)
  @endpoint = settings.endpoint || DEFAULT_ENDPOINT
  @private_token = settings.private_token
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



12
13
14
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 12

def endpoint
  @endpoint
end

#private_tokenObject (readonly)

Returns the value of attribute private_token.



12
13
14
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 12

def private_token
  @private_token
end

Instance Method Details

#callObject



19
20
21
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 19

def call
  backup_repositories
end

#clientObject



27
28
29
30
31
32
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 27

def client
  @client ||= ::Gitlab.client(
    private_token: private_token,
    endpoint: endpoint
  )
end

#endpoint_hostObject



34
35
36
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 34

def endpoint_host
  @endpoint_host ||= URI.parse(endpoint).host
end

#reposObject



23
24
25
# File 'lib/backup_repos/backup_gitlab_endpoint.rb', line 23

def repos
  @repos ||= client.projects(membership: true).auto_paginate
end