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

agent.rb « clusters « resource « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: cad5a4c6b1dcabbe57838b0696fb0e8783fd11b0 (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
# frozen_string_literal: true

module QA
  module Resource
    module Clusters
      class Agent < QA::Resource::Base
        attribute :id
        attribute :name
        attribute :project do
          QA::Resource::Project.fabricate_via_api! do |project|
            project.name = 'project-with-cluster-agent'
          end
        end

        def initialize
          @name = "my-agent"
        end

        def fabricate!
          puts 'TODO: FABRICATE VIA UI'
        end
        # TODO
        #
        # The UI for this model is not yet implemented. So far it can only be
        # created through the GraphQL API
        # def fabricate
        #
        # end

        def api_get_path
          "gid://gitlab/Clusters::Agent/#{id}"
        end

        def api_post_path
          "/graphql"
        end

        def api_post_body
          <<~GQL
          mutation createAgent {
            createClusterAgent(input: { projectPath: "#{project.full_path}", name: "#{@name}" }) {
              clusterAgent {
                id
                name
              }
              errors
            }
          }
          GQL
        end
      end
    end
  end
end