Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feature: add ske service + examples#3

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
MelvinKl merged 3 commits intomainfromadd_ske
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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
50 changes: 50 additions & 0 deletionsexamples/ske/create_cluster.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
import os

from stackit.ske.api.default_api import DefaultApi
from stackit.ske.models.create_or_update_cluster_payload import (
CreateOrUpdateClusterPayload,
)
from stackit.ske.models.kubernetes import Kubernetes
from stackit.ske.models.nodepool import Nodepool
from stackit.ske.models.machine import Machine
from stackit.ske.models.volume import Volume
from stackit.ske.models.image import Image

from stackit.core.configuration import Configuration


project_id = os.getenv("PROJECT_ID")
volume_type = "storage_premium_perf0"

# Create a new API client, that uses default authentication and configuration
config = Configuration()
client = DefaultApi(config)

# Get available options
options_resonse = client.list_provider_options()

# Create a new instance using the first option for everything
cluser_name = "cl-name"
create_instance_payload = CreateOrUpdateClusterPayload(
kubernetes=Kubernetes(version=options_resonse.kubernetes_versions[0].version),
nodepools=[
Nodepool(
availability_zones=[options_resonse.availability_zones[0].name],
machine=Machine(
image=Image(
name=options_resonse.machine_images[0].name,
version=options_resonse.machine_images[0].versions[0].version,
),
type=options_resonse.machine_types[0].name,
),
maximum=3,
minimum=2,
name="my-nodepool",
volume=Volume(
size=20,
type=volume_type,
),
)
],
)
client.create_or_update_cluster(project_id, cluser_name, create_instance_payload)
17 changes: 17 additions & 0 deletionsexamples/ske/credential_rotation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import os

from stackit.ske.api.default_api import DefaultApi
from stackit.core.configuration import Configuration

project_id = os.getenv("PROJECT_ID")

# Create a new API client, that uses default authentication and configuration
config = Configuration()
client = DefaultApi(config)

# Get all ske instances
response = client.list_clusters(project_id)

# Rotate credentials on all instances
for cluster in response.items:
client.start_credentials_rotation(project_id, cluster.name)
17 changes: 17 additions & 0 deletionsexamples/ske/delete_clusters.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
import os

from stackit.ske.api.default_api import DefaultApi
from stackit.core.configuration import Configuration

project_id = os.getenv("PROJECT_ID")

# Create a new API client, that uses default authentication and configuration
config = Configuration()
client = DefaultApi(config)

# List all ske clusters
response = client.list_clusters(project_id)

# Delete all cluster
for cluster in response.items:
client.delete_cluster(project_id, cluster.name)
13 changes: 13 additions & 0 deletionsexamples/ske/list_clusters.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
import os

from stackit.ske.api.default_api import DefaultApi
from stackit.core.configuration import Configuration

project_id = os.getenv("PROJECT_ID")

# Create a new API client, that uses default authentication and configuration
config = Configuration()
client = DefaultApi(config)

# List all ske instances
print(client.list_clusters(project_id))
93 changes: 93 additions & 0 deletionsservices/ske/pyproject.toml
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
[project]
name = "stackit-ske"
version = "1.0.0"
authors = [
{ name="STACKIT Kubernetes Engine (SKE) Team", email="team@openapitools.org" },
]
description = "SKE-API"
#readme = "README.md"
#license = "NoLicense"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python :: 3",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
]
dependencies = [
"requests ~= 2.32.3",
"python_dateutil ~= 2.5.3",
"pydantic ~= 2.9.2",
"stackit-core ~= 0.0.1",
]

[project.optional-dependencies]
dev = [
"black >= 24.8.0",
"pytest ~= 8.3.2",
"flake8 ~= 7.1.0",
"flake8-black ~= 0.3.6",
"flake8-pyproject ~= 1.2.3",
"flake8-quotes ~= 3.4.0",
"flake8-bandit ~= 4.1.1",
"flake8-bugbear ~= 24.8.19",
"flake8-eradicate ~= 1.5.0",
"flake8-eol ~= 0.0.8",
"autoimport ~= 1.6.1",
"isort ~= 5.13.2",
]

[project.urls]
Homepage = "https://github.com/stackitcloud/stackit-sdk-python-beta"
Issues = "https://github.com/stackitcloud/stackit-sdk-python-beta/issues"

[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 120
exclude = """
/(
.eggs
| .git
| .hg
| .mypy_cache
| .nox
| .pants.d
| .tox
| .venv
| _build
| buck-out
| build
| dist
| node_modules
| venv
)/
"""

[tool.isort]
profile = 'black'

[tool.flake8]
exclude= [".eggs", ".git", ".hg", ".mypy_cache", ".tox", ".venv", ".devcontainer", "venv", "_build", "buck-out", "build", "dist"]
statistics = true
show-source = false
max-line-length = 120
# E203,W503 and E704 are incompatible with the formatter black
# W291 needs to be disabled because some doc-strings get generated with trailing whitespace but black won't re-format comments
ignore = ["E203", "W503", "E704", "W291"]
inline-quotes = '"'
docstring-quotes = '"""'
multiline-quotes = '"""'
ban-relative-imports = true
per-file-ignores = """
# asserts are fine in tests, tests shouldn't be build optimized
./tests/*: S101,
# F841: some variables get generated but may not be used, depending on the api-spec
# E501: long descriptions/string values might lead to lines that are too long
./stackit/*/models/*: F841,E501
# F841: some variables get generated but may not be used, depending on the api-spec
# E501: long descriptions/string values might lead to lines that are too long
# B028: stacklevel for deprecation warning is irrelevant
./stackit/*/api/default_api.py: F841,B028,E501
"""
74 changes: 74 additions & 0 deletionsservices/ske/stackit/ske/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
# coding: utf-8

# flake8: noqa

"""
SKE-API

The SKE API provides endpoints to create, update, delete clusters within STACKIT portal projects and to trigger further cluster management tasks.

The version of the OpenAPI document: 1.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501 docstring might be too long


__version__ = "1.0.0"

# import apis into sdk package
from stackit.ske.api.default_api import DefaultApi
from stackit.ske.api_client import ApiClient

# import ApiClient
from stackit.ske.api_response import ApiResponse
from stackit.ske.configuration import HostConfiguration
from stackit.ske.exceptions import (
ApiAttributeError,
ApiException,
ApiKeyError,
ApiTypeError,
ApiValueError,
OpenApiException,
)

# import models into sdk package
from stackit.ske.models.acl import ACL
from stackit.ske.models.argus import Argus
from stackit.ske.models.availability_zone import AvailabilityZone
from stackit.ske.models.cluster import Cluster
from stackit.ske.models.cluster_status import ClusterStatus
from stackit.ske.models.cluster_status_state import ClusterStatusState
from stackit.ske.models.create_kubeconfig_payload import CreateKubeconfigPayload
from stackit.ske.models.create_or_update_cluster_payload import (
CreateOrUpdateClusterPayload,
)
from stackit.ske.models.credentials import Credentials
from stackit.ske.models.credentials_rotation_state import CredentialsRotationState
from stackit.ske.models.cri import CRI
from stackit.ske.models.dns import DNS
from stackit.ske.models.extension import Extension
from stackit.ske.models.hibernation import Hibernation
from stackit.ske.models.hibernation_schedule import HibernationSchedule
from stackit.ske.models.image import Image
from stackit.ske.models.kubeconfig import Kubeconfig
from stackit.ske.models.kubernetes import Kubernetes
from stackit.ske.models.kubernetes_version import KubernetesVersion
from stackit.ske.models.list_clusters_response import ListClustersResponse
from stackit.ske.models.login_kubeconfig import LoginKubeconfig
from stackit.ske.models.machine import Machine
from stackit.ske.models.machine_image import MachineImage
from stackit.ske.models.machine_image_version import MachineImageVersion
from stackit.ske.models.machine_type import MachineType
from stackit.ske.models.maintenance import Maintenance
from stackit.ske.models.maintenance_auto_update import MaintenanceAutoUpdate
from stackit.ske.models.network import Network
from stackit.ske.models.nodepool import Nodepool
from stackit.ske.models.project_response import ProjectResponse
from stackit.ske.models.project_state import ProjectState
from stackit.ske.models.provider_options import ProviderOptions
from stackit.ske.models.runtime_error import RuntimeError
from stackit.ske.models.taint import Taint
from stackit.ske.models.time_window import TimeWindow
from stackit.ske.models.volume import Volume
from stackit.ske.models.volume_type import VolumeType
4 changes: 4 additions & 0 deletionsservices/ske/stackit/ske/api/__init__.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
# flake8: noqa

# import apis into api package
from stackit.ske.api.default_api import DefaultApi
Loading

[8]ページ先頭

©2009-2025 Movatter.jp