Welcome to mirror list, hosted at ThFree Co, Russian Federation.

state_version_type.rb « terraform « types « graphql « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a3af5c876caf49f8095e2d1c03b9840c108eb35b (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
58
# frozen_string_literal: true

module Types
  module Terraform
    class StateVersionType < BaseObject
      include ::API::Helpers::RelatedResourcesHelpers

      graphql_name 'TerraformStateVersion'

      authorize :read_terraform_state

      field :id, GraphQL::ID_TYPE,
            null: false,
            description: 'ID of the Terraform state version'

      field :created_by_user, Types::UserType,
            null: true,
            description: 'The user that created this version'

      field :download_path, GraphQL::STRING_TYPE,
            null: true,
            description: "URL for downloading the version's JSON file"

      field :job, Types::Ci::JobType,
            null: true,
            description: 'The job that created this version'

      field :serial, GraphQL::INT_TYPE,
            null: true,
            description: 'Serial number of the version',
            method: :version

      field :created_at, Types::TimeType,
            null: false,
            description: 'Timestamp the version was created'

      field :updated_at, Types::TimeType,
            null: false,
            description: 'Timestamp the version was updated'

      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
    end
  end
end