Skip to content

TAM API implementation #1225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add TAM image build status endpoint
  • Loading branch information
AndriiMysko committed Dec 22, 2021
commit 639d796848b9765a64bc7bdc4eb9478f66caaf14
8 changes: 8 additions & 0 deletions lib/travis/api/v3/artifacts_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ def delete_image(image_name)
handle_errors_and_respond(response)
end

def image_build_status(image_name)
response = connection.get("/api/#{image_name}/build_status")

handle_errors_and_respond(response) do |body|
body
end
end

private

def handle_errors_and_respond(response)
Expand Down
4 changes: 4 additions & 0 deletions lib/travis/api/v3/queries/artifacts_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def info(user_id)
def delete(user_id)
artifacts_client(user_id).delete_image(params['image_name'])
end

def build_status(user_id)
artifacts_client(user_id).image_build_status(params['image_name'])
end

def artifacts_client(user_id)
@_artifacts_client ||= ArtifactsClient.new(user_id)
Expand Down
19 changes: 19 additions & 0 deletions lib/travis/api/v3/renderer/artifacts_image_build_status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Travis::API::V3
module Renderer::ArtifactsImageBuildStatus
extend self

AVAILABLE_ATTRIBUTES = [:name, :status]

def available_attributes
AVAILABLE_ATTRIBUTES
end

def render(object, **)
{
'@type': 'artifacts_image_build_status'.freeze,
name: object['name'],
status: object['status']
}
end
end
end
19 changes: 19 additions & 0 deletions lib/travis/api/v3/renderer/artifacts_image_logs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module Travis::API::V3
module Renderer::ArtifactsImageLogs
extend self

AVAILABLE_ATTRIBUTES = [:name, :log]

def available_attributes
AVAILABLE_ATTRIBUTES
end

def render(object, **)
{
'@type': 'artifacts_image_logs'.freeze,
name: object['name'],
log: object['log']
}
end
end
end
1 change: 1 addition & 0 deletions lib/travis/api/v3/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ module Routes

get :logs, '/logs'
get :info, '/info'
get :build_status, '/build_status'
delete :delete
end
end
Expand Down
12 changes: 12 additions & 0 deletions lib/travis/api/v3/services/artifacts_image/build_status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module Travis::API::V3
class Services::ArtifactsImage::BuildStatus < Service
params :image_name
result_type :artifacts_image_build_status

def run!
raise LoginRequired unless access_control.full_access_or_logged_in?
result query(:artifacts_image).build_status(access_control.user.id)
end
end
end

1 change: 1 addition & 0 deletions lib/travis/api/v3/services/artifacts_image/logs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module Travis::API::V3
class Services::ArtifactsImage::Logs < Service
params :image_name
result_type :artifacts_image_logs

def run!
raise LoginRequired unless access_control.full_access_or_logged_in?
Expand Down