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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 13:00:54 +0300
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /lib/api/clusters
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'lib/api/clusters')
-rw-r--r--lib/api/clusters/agents.rb81
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/api/clusters/agents.rb b/lib/api/clusters/agents.rb
new file mode 100644
index 00000000000..6c1bf21b952
--- /dev/null
+++ b/lib/api/clusters/agents.rb
@@ -0,0 +1,81 @@
+# frozen_string_literal: true
+
+module API
+ module Clusters
+ class Agents < ::API::Base
+ include PaginationParams
+
+ before { authenticate! }
+
+ feature_category :kubernetes_management
+
+ params do
+ requires :id, type: String, desc: 'The ID of a project'
+ end
+ resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
+ desc 'List agents' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ success Entities::Clusters::Agent
+ end
+ params do
+ use :pagination
+ end
+ get ':id/cluster_agents' do
+ authorize! :read_cluster, user_project
+
+ agents = ::Clusters::AgentsFinder.new(user_project, current_user).execute
+
+ present paginate(agents), with: Entities::Clusters::Agent
+ end
+
+ desc 'Get single agent' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ success Entities::Clusters::Agent
+ end
+ params do
+ requires :agent_id, type: Integer, desc: 'The ID of an agent'
+ end
+ get ':id/cluster_agents/:agent_id' do
+ authorize! :read_cluster, user_project
+
+ agent = user_project.cluster_agents.find(params[:agent_id])
+
+ present agent, with: Entities::Clusters::Agent
+ end
+
+ desc 'Add an agent to a project' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ success Entities::Clusters::Agent
+ end
+ params do
+ requires :name, type: String, desc: 'The name of the agent'
+ end
+ post ':id/cluster_agents' do
+ authorize! :create_cluster, user_project
+
+ params = declared_params(include_missing: false)
+
+ result = ::Clusters::Agents::CreateService.new(user_project, current_user).execute(name: params[:name])
+
+ bad_request!(result[:message]) if result[:status] == :error
+
+ present result[:cluster_agent], with: Entities::Clusters::Agent
+ end
+
+ desc 'Delete an agent' do
+ detail 'This feature was introduced in GitLab 14.10.'
+ end
+ params do
+ requires :agent_id, type: Integer, desc: 'The ID of an agent'
+ end
+ delete ':id/cluster_agents/:agent_id' do
+ authorize! :admin_cluster, user_project
+
+ agent = user_project.cluster_agents.find(params.delete(:agent_id))
+
+ destroy_conditionally!(agent)
+ end
+ end
+ end
+ end
+end