summaryrefslogtreecommitdiff
path: root/app/serializers/projects/serverless/service_entity.rb
blob: 4f1f62d145b5abbe23fbe4d8b999a907ded44dd2 (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
# frozen_string_literal: true

module Projects
  module Serverless
    class ServiceEntity < Grape::Entity
      include RequestAwareEntity

      expose :name do |service|
        service.dig('metadata', 'name')
      end

      expose :namespace do |service|
        service.dig('metadata', 'namespace')
      end

      expose :created_at do |service|
        service.dig('metadata', 'creationTimestamp')
      end

      expose :url do |service|
        "http://#{service.dig('status', 'domain')}"
      end

      expose :description do |service|
        service.dig('spec', 'runLatest', 'configuration', 'revisionTemplate', 'metadata', 'annotations', 'Description')
      end

      expose :image do |service|
        service.dig('spec', 'runLatest', 'configuration', 'build', 'template', 'name')
      end
    end
  end
end