blob: 68f8fe0f9c9aa55696ee4e3217cca51804dde421 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# frozen_string_literal: true
module Sentry
class Client
module Projects
def projects
projects = get_projects
handle_mapping_exceptions do
map_to_projects(projects)
end
end
private
def get_projects
http_get(projects_api_url)[:body]
end
def projects_api_url
projects_url = URI(url)
projects_url.path = '/api/0/projects/'
projects_url
end
def map_to_projects(projects)
projects.map(&method(:map_to_project))
end
def map_to_project(project)
organization = project.fetch('organization')
Gitlab::ErrorTracking::Project.new(
id: project.fetch('id', nil),
name: project.fetch('name'),
slug: project.fetch('slug'),
status: project.dig('status'),
organization_name: organization.fetch('name'),
organization_id: organization.fetch('id', nil),
organization_slug: organization.fetch('slug')
)
end
end
end
end
|