diff options
Diffstat (limited to 'app/graphql/types/clusters')
-rw-r--r-- | app/graphql/types/clusters/agent_token_type.rb | 52 | ||||
-rw-r--r-- | app/graphql/types/clusters/agent_type.rb | 67 |
2 files changed, 119 insertions, 0 deletions
diff --git a/app/graphql/types/clusters/agent_token_type.rb b/app/graphql/types/clusters/agent_token_type.rb new file mode 100644 index 00000000000..94c5fc46a5d --- /dev/null +++ b/app/graphql/types/clusters/agent_token_type.rb @@ -0,0 +1,52 @@ +# 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.' + + def cluster_agent + Gitlab::Graphql::Loaders::BatchModelLoader.new(::Clusters::Agent, object.agent_id).find + end + end + end +end diff --git a/app/graphql/types/clusters/agent_type.rb b/app/graphql/types/clusters/agent_type.rb new file mode 100644 index 00000000000..ce748f6e8ae --- /dev/null +++ b/app/graphql/types/clusters/agent_type.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true + +module Types + module Clusters + class AgentType < BaseObject + graphql_name 'ClusterAgent' + + authorize :admin_cluster + + connection_type_class(Types::CountableConnectionType) + + field :created_at, + Types::TimeType, + null: true, + description: 'Timestamp the cluster agent was created.' + + field :created_by_user, + Types::UserType, + null: true, + description: 'User object, containing information about the person who created the agent.' + + field :id, GraphQL::Types::ID, + null: false, + description: 'ID of the cluster agent.' + + field :name, + GraphQL::Types::String, + null: true, + description: 'Name of the cluster agent.' + + field :project, Types::ProjectType, + description: 'Project this cluster agent is associated with.', + null: true, + authorize: :read_project + + field :tokens, Types::Clusters::AgentTokenType.connection_type, + description: 'Tokens associated with the cluster agent.', + null: true, + resolver: ::Resolvers::Clusters::AgentTokensResolver + + field :updated_at, + Types::TimeType, + null: true, + description: 'Timestamp the cluster agent was updated.' + + field :web_path, + GraphQL::Types::String, + null: true, + description: 'Web path of the cluster agent.' + + field :connections, + Types::Kas::AgentConnectionType.connection_type, + null: true, + description: 'Active connections for the cluster agent', + complexity: 5, + resolver: ::Resolvers::Kas::AgentConnectionsResolver + + def project + Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find + end + + def web_path + ::Gitlab::Routing.url_helpers.project_cluster_agent_path(object.project, object.name) + end + end + end +end |