2020-01-01 13:55:28 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2021-04-17 20:07:23 +05:30
|
|
|
module ErrorTracking
|
|
|
|
class SentryClient
|
2020-01-01 13:55:28 +05:30
|
|
|
module Projects
|
|
|
|
def projects
|
|
|
|
projects = get_projects
|
|
|
|
|
|
|
|
handle_mapping_exceptions do
|
|
|
|
map_to_projects(projects)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def get_projects
|
2020-03-13 15:44:24 +05:30
|
|
|
http_get(api_urls.projects_url)[:body]
|
2020-01-01 13:55:28 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def map_to_projects(projects)
|
2022-06-21 17:19:12 +05:30
|
|
|
projects.map { map_to_project(_1) }
|
2020-01-01 13:55:28 +05:30
|
|
|
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'),
|
2022-06-21 17:19:12 +05:30
|
|
|
status: project['status'],
|
2020-01-01 13:55:28 +05:30
|
|
|
organization_name: organization.fetch('name'),
|
|
|
|
organization_id: organization.fetch('id', nil),
|
|
|
|
organization_slug: organization.fetch('slug')
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|