debian-mirror-gitlab/app/graphql/types/terraform/state_version_type.rb

59 lines
1.6 KiB
Ruby
Raw Normal View History

2021-01-29 00:20:46 +05:30
# frozen_string_literal: true
module Types
module Terraform
class StateVersionType < BaseObject
2021-02-22 17:27:13 +05:30
include ::API::Helpers::RelatedResourcesHelpers
2021-01-29 00:20:46 +05:30
graphql_name 'TerraformStateVersion'
authorize :read_terraform_state
field :id, GraphQL::ID_TYPE,
null: false,
2021-03-11 19:13:27 +05:30
description: 'ID of the Terraform state version.'
2021-01-29 00:20:46 +05:30
field :created_by_user, Types::UserType,
null: true,
2021-03-11 19:13:27 +05:30
description: 'The user that created this version.'
2021-02-22 17:27:13 +05:30
field :download_path, GraphQL::STRING_TYPE,
null: true,
2021-03-11 19:13:27 +05:30
description: "URL for downloading the version's JSON file."
2021-01-29 00:20:46 +05:30
field :job, Types::Ci::JobType,
null: true,
2021-03-11 19:13:27 +05:30
description: 'The job that created this version.'
2021-02-22 17:27:13 +05:30
field :serial, GraphQL::INT_TYPE,
null: true,
2021-03-11 19:13:27 +05:30
description: 'Serial number of the version.',
2021-02-22 17:27:13 +05:30
method: :version
2021-01-29 00:20:46 +05:30
field :created_at, Types::TimeType,
null: false,
2021-03-11 19:13:27 +05:30
description: 'Timestamp the version was created.'
2021-01-29 00:20:46 +05:30
field :updated_at, Types::TimeType,
null: false,
2021-03-11 19:13:27 +05:30
description: 'Timestamp the version was updated.'
2021-02-22 17:27:13 +05:30
def created_by_user
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.created_by_user_id).find
end
def download_path
expose_path api_v4_projects_terraform_state_versions_path(
id: object.project_id,
name: object.terraform_state.name,
serial: object.version
)
end
def job
Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Build, object.ci_build_id).find
end
2021-01-29 00:20:46 +05:30
end
end
end