summaryrefslogtreecommitdiff
path: root/app/graphql/types/clusters/agent_token_type.rb
blob: 96fdb5f05c88934d2c2579abd87e7705a694e305 (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
47
48
49
50
51
52
53
54
55
56
57
# frozen_string_literal: true

module Types
  module Clusters
    class AgentTokenType < BaseObject
      graphql_name 'ClusterAgentToken'

      authorize :admin_cluster

      connection_type_class(Types::CountableConnectionType)

      field :cluster_agent,
            Types::Clusters::AgentType,
            description: 'Cluster agent this token is associated with.',
            null: true

      field :created_at,
            Types::TimeType,
            null: true,
            description: 'Timestamp the token was created.'

      field :created_by_user,
            Types::UserType,
            null: true,
            description: 'User who created the token.'

      field :description,
            GraphQL::Types::String,
            null: true,
            description: 'Description of the token.'

      field :last_used_at,
            Types::TimeType,
            null: true,
            description: 'Timestamp the token was last used.'

      field :id,
            ::Types::GlobalIDType[::Clusters::AgentToken],
            null: false,
            description: 'Global ID of the token.'

      field :name,
            GraphQL::Types::String,
            null: true,
            description: 'Name given to the token.'

      field :status,
            Types::Clusters::AgentTokenStatusEnum,
            null: true,
            description: 'Current status of the token.'

      def cluster_agent
        Gitlab::Graphql::Loaders::BatchModelLoader.new(::Clusters::Agent, object.agent_id).find
      end
    end
  end
end