Module: Gitlab::Client::ProjectClusters

Included in:
Gitlab::Client
Defined in:
lib/gitlab/client/project_clusters.rb

Overview

Defines methods related to project clusters.

Instance Method Summary collapse

Instance Method Details

#add_project_cluster(project, name, options = {}) ⇒ Gitlab::ObjectifiedHash

Adds an existing Kubernetes cluster to the project.

Examples:

Gitlab.add_project_cluster(5, 'cluster-5', { enabled: false, platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345', ca_cert: "-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----", namespace: 'cluster-5-namespace', authorization_type: 'rbac' } })
Gitlab.add_project_cluster(5, 'cluster-5', { platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345' } })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • name (String)

    The name of the existing cluster.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :enabled(optional) (Boolean)

    Determines if cluster is active or not, defaults to true

  • :platform_kubernetes_attributes (Hash)

    A customizable set of Kubernetes platform attributes

Returns:



47
48
49
50
# File 'lib/gitlab/client/project_clusters.rb', line 47

def add_project_cluster(project, name, options = {})
  body = { name: name }.merge(options)
  post("/projects/#{url_encode project}/clusters/user", body: body)
end

#delete_project_cluster(project, cluster_id) ⇒ nil

Deletes an existing project cluster.

Examples:

Gitlab.delete_project_cluster(5, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • cluster_id (Integer)

    The ID of the cluster.

Returns:

  • (nil)

    This API call returns an empty response body.



79
80
81
# File 'lib/gitlab/client/project_clusters.rb', line 79

def delete_project_cluster(project, cluster_id)
  delete("/projects/#{url_encode project}/clusters/#{cluster_id}")
end

#edit_project_cluster(project, cluster_id, options = {}) ⇒ Gitlab::ObjectifiedHash

Updates an existing project cluster.

Examples:

Gitlab.edit_project_cluster(5, 1, { name: 'cluster-6', platform_kubernetes_attributes: { api_url: 'https://35.111.51.20', token: '12345', ca_cert: "-----BEGIN CERTIFICATE-----\r\nhFiK1L61owwDQYJKoZIhvcNAQELBQAw\r\nLzEtMCsGA1UEAxMkZDA1YzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM4ZDBj\r\nMB4XDTE4MTIyNzIwMDM1MVoXDTIzMTIyNjIxMDM1MVowLzEtMCsGA1UEAxMkZDA1\r\nYzQ1YjctNzdiMS00NDY0LThjNmEtMTQ0ZDJkZjM.......-----END CERTIFICATE-----", namespace: 'cluster-6-namespace' } })

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • cluster_id (Integer)

    The ID of the cluster.

  • options (Hash) (defaults to: {})

    A customizable set of options.

Options Hash (options):

  • :name(optional) (String)

    The name of the cluster

  • :platform_kubernetes_attributes (Hash)

    A customizable set of Kubernetes platform attributes

Returns:



67
68
69
# File 'lib/gitlab/client/project_clusters.rb', line 67

def edit_project_cluster(project, cluster_id, options = {})
  put("/projects/#{url_encode project}/clusters/#{cluster_id}", body: options)
end

#project_cluster(project, cluster_id) ⇒ Gitlab::ObjectifiedHash

Gets a single project cluster.

Examples:

Gitlab.project_cluster(5, 42)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

  • cluster_id (Integer)

    The ID of the cluster.

Returns:



26
27
28
# File 'lib/gitlab/client/project_clusters.rb', line 26

def project_cluster(project, cluster_id)
  get("/projects/#{url_encode project}/clusters/#{cluster_id}")
end

#project_clusters(project) ⇒ Array<Gitlab::ObjectifiedHash>

Returns a list of project clusters.

Examples:

Gitlab.project_clusters(5)

Parameters:

  • project (Integer, String)

    The ID or name of a project.

Returns:



14
15
16
# File 'lib/gitlab/client/project_clusters.rb', line 14

def project_clusters(project)
  get("/projects/#{url_encode project}/clusters")
end