Skip to content

docs: add project and group cluster examples #947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions docs/gl_objects/clusters.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
############
Clusters
############

Reference
---------

* v4 API:

+ :class:`gitlab.v4.objects.ProjectCluster`
+ :class:`gitlab.v4.objects.ProjectClusterManager`
+ :attr:`gitlab.v4.objects.Project.clusters`
+ :class:`gitlab.v4.objects.GroupCluster`
+ :class:`gitlab.v4.objects.GroupClusterManager`
+ :attr:`gitlab.v4.objects.Group.clusters`

* GitLab API: https://docs.gitlab.com/ee/api/project_clusters.html
* GitLab API: https://docs.gitlab.com/ee/api/group_clusters.html

Examples
--------

List clusters for a project::

clusters = project.clusters.list()

Create an cluster for a project::

cluster = project.clusters.create(
{
"name": "cluster1",
"platform_kubernetes_attributes": {
"api_url": "http://url",
"token": "tokenval",
},
})

Retrieve a specific cluster for a project::

cluster = project.clusters.get(cluster_id)

Update an cluster for a project::

cluster.platform_kubernetes_attributes = {"api_url": "http://newurl"}
cluster.save()

Delete an cluster for a project::

cluster = project.clusters.delete(cluster_id)
# or
cluster.delete()


List clusters for a group::

clusters = group.clusters.list()

Create an cluster for a group::

cluster = group.clusters.create(
{
"name": "cluster1",
"platform_kubernetes_attributes": {
"api_url": "http://url",
"token": "tokenval",
},
})

Retrieve a specific cluster for a group::

cluster = group.clusters.get(cluster_id)

Update an cluster for a group::

cluster.platform_kubernetes_attributes = {"api_url": "http://newurl"}
cluster.save()

Delete an cluster for a group::

cluster = group.clusters.delete(cluster_id)
# or
cluster.delete()