2020-10-29 18:09:11 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Types
|
|
|
|
module Terraform
|
|
|
|
class StateVersionType < BaseObject
|
|
|
|
graphql_name 'TerraformStateVersion'
|
|
|
|
|
2022-02-15 12:14:49 +00:00
|
|
|
include ::API::Helpers::RelatedResourcesHelpers
|
|
|
|
|
2020-10-29 18:09:11 +00:00
|
|
|
authorize :read_terraform_state
|
|
|
|
|
2021-07-23 12:09:05 +00:00
|
|
|
field :id, GraphQL::Types::ID,
|
2020-10-29 18:09:11 +00:00
|
|
|
null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'ID of the Terraform state version.'
|
2020-10-29 18:09:11 +00:00
|
|
|
|
|
|
|
field :created_by_user, Types::UserType,
|
|
|
|
null: true,
|
2021-08-31 15:10:29 +00:00
|
|
|
description: 'User that created this version.'
|
2020-10-29 18:09:11 +00:00
|
|
|
|
2021-07-23 12:09:05 +00:00
|
|
|
field :download_path, GraphQL::Types::String,
|
2020-12-03 15:09:46 +00:00
|
|
|
null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: "URL for downloading the version's JSON file."
|
2020-12-03 15:09:46 +00:00
|
|
|
|
2020-11-12 09:08:57 +00:00
|
|
|
field :job, Types::Ci::JobType,
|
|
|
|
null: true,
|
2021-09-14 21:11:58 +00:00
|
|
|
description: 'Job that created this version.',
|
|
|
|
authorize: :read_commit_status
|
2020-11-12 09:08:57 +00:00
|
|
|
|
2021-07-23 12:09:05 +00:00
|
|
|
field :serial, GraphQL::Types::Int,
|
2020-12-03 15:09:46 +00:00
|
|
|
null: true,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Serial number of the version.',
|
2020-12-03 15:09:46 +00:00
|
|
|
method: :version
|
|
|
|
|
2020-10-29 18:09:11 +00:00
|
|
|
field :created_at, Types::TimeType,
|
|
|
|
null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Timestamp the version was created.'
|
2020-10-29 18:09:11 +00:00
|
|
|
|
|
|
|
field :updated_at, Types::TimeType,
|
|
|
|
null: false,
|
2021-02-05 15:09:28 +00:00
|
|
|
description: 'Timestamp the version was updated.'
|
2020-12-01 12:09:17 +00:00
|
|
|
|
|
|
|
def created_by_user
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(User, object.created_by_user_id).find
|
|
|
|
end
|
|
|
|
|
2020-12-03 15:09:46 +00:00
|
|
|
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
|
|
|
|
|
2020-12-01 12:09:17 +00:00
|
|
|
def job
|
|
|
|
Gitlab::Graphql::Loaders::BatchModelLoader.new(::Ci::Build, object.ci_build_id).find
|
|
|
|
end
|
2020-10-29 18:09:11 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|