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

Commitb86df12

Browse files
authored
feature: add ske service + examples (#3)
1 parent4531057 commitb86df12

File tree

52 files changed

+9170
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+9170
-0
lines changed

‎examples/ske/create_cluster.py‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
importos
2+
3+
fromstackit.ske.api.default_apiimportDefaultApi
4+
fromstackit.ske.models.create_or_update_cluster_payloadimport (
5+
CreateOrUpdateClusterPayload,
6+
)
7+
fromstackit.ske.models.kubernetesimportKubernetes
8+
fromstackit.ske.models.nodepoolimportNodepool
9+
fromstackit.ske.models.machineimportMachine
10+
fromstackit.ske.models.volumeimportVolume
11+
fromstackit.ske.models.imageimportImage
12+
13+
fromstackit.core.configurationimportConfiguration
14+
15+
16+
project_id=os.getenv("PROJECT_ID")
17+
volume_type="storage_premium_perf0"
18+
19+
# Create a new API client, that uses default authentication and configuration
20+
config=Configuration()
21+
client=DefaultApi(config)
22+
23+
# Get available options
24+
options_resonse=client.list_provider_options()
25+
26+
# Create a new instance using the first option for everything
27+
cluser_name="cl-name"
28+
create_instance_payload=CreateOrUpdateClusterPayload(
29+
kubernetes=Kubernetes(version=options_resonse.kubernetes_versions[0].version),
30+
nodepools=[
31+
Nodepool(
32+
availability_zones=[options_resonse.availability_zones[0].name],
33+
machine=Machine(
34+
image=Image(
35+
name=options_resonse.machine_images[0].name,
36+
version=options_resonse.machine_images[0].versions[0].version,
37+
),
38+
type=options_resonse.machine_types[0].name,
39+
),
40+
maximum=3,
41+
minimum=2,
42+
name="my-nodepool",
43+
volume=Volume(
44+
size=20,
45+
type=volume_type,
46+
),
47+
)
48+
],
49+
)
50+
client.create_or_update_cluster(project_id,cluser_name,create_instance_payload)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
importos
2+
3+
fromstackit.ske.api.default_apiimportDefaultApi
4+
fromstackit.core.configurationimportConfiguration
5+
6+
project_id=os.getenv("PROJECT_ID")
7+
8+
# Create a new API client, that uses default authentication and configuration
9+
config=Configuration()
10+
client=DefaultApi(config)
11+
12+
# Get all ske instances
13+
response=client.list_clusters(project_id)
14+
15+
# Rotate credentials on all instances
16+
forclusterinresponse.items:
17+
client.start_credentials_rotation(project_id,cluster.name)

‎examples/ske/delete_clusters.py‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
importos
2+
3+
fromstackit.ske.api.default_apiimportDefaultApi
4+
fromstackit.core.configurationimportConfiguration
5+
6+
project_id=os.getenv("PROJECT_ID")
7+
8+
# Create a new API client, that uses default authentication and configuration
9+
config=Configuration()
10+
client=DefaultApi(config)
11+
12+
# List all ske clusters
13+
response=client.list_clusters(project_id)
14+
15+
# Delete all cluster
16+
forclusterinresponse.items:
17+
client.delete_cluster(project_id,cluster.name)

‎examples/ske/list_clusters.py‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
importos
2+
3+
fromstackit.ske.api.default_apiimportDefaultApi
4+
fromstackit.core.configurationimportConfiguration
5+
6+
project_id=os.getenv("PROJECT_ID")
7+
8+
# Create a new API client, that uses default authentication and configuration
9+
config=Configuration()
10+
client=DefaultApi(config)
11+
12+
# List all ske instances
13+
print(client.list_clusters(project_id))

‎services/ske/pyproject.toml‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
[project]
2+
name ="stackit-ske"
3+
version ="1.0.0"
4+
authors = [
5+
{name="STACKIT Kubernetes Engine (SKE) Team",email="team@openapitools.org" },
6+
]
7+
description ="SKE-API"
8+
#readme = "README.md"
9+
#license = "NoLicense"
10+
requires-python =">=3.8"
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"License :: OSI Approved :: Apache Software License",
14+
"Operating System :: OS Independent",
15+
]
16+
dependencies = [
17+
"requests ~= 2.32.3",
18+
"python_dateutil ~= 2.5.3",
19+
"pydantic ~= 2.9.2",
20+
"stackit-core ~= 0.0.1",
21+
]
22+
23+
[project.optional-dependencies]
24+
dev = [
25+
"black >= 24.8.0",
26+
"pytest ~= 8.3.2",
27+
"flake8 ~= 7.1.0",
28+
"flake8-black ~= 0.3.6",
29+
"flake8-pyproject ~= 1.2.3",
30+
"flake8-quotes ~= 3.4.0",
31+
"flake8-bandit ~= 4.1.1",
32+
"flake8-bugbear ~= 24.8.19",
33+
"flake8-eradicate ~= 1.5.0",
34+
"flake8-eol ~= 0.0.8",
35+
"autoimport ~= 1.6.1",
36+
"isort ~= 5.13.2",
37+
]
38+
39+
[project.urls]
40+
Homepage ="https://github.com/stackitcloud/stackit-sdk-python-beta"
41+
Issues ="https://github.com/stackitcloud/stackit-sdk-python-beta/issues"
42+
43+
[build-system]
44+
requires = ["setuptools"]
45+
build-backend ="setuptools.build_meta"
46+
47+
[tool.black]
48+
line-length =120
49+
exclude ="""
50+
/(
51+
.eggs
52+
| .git
53+
| .hg
54+
| .mypy_cache
55+
| .nox
56+
| .pants.d
57+
| .tox
58+
| .venv
59+
| _build
60+
| buck-out
61+
| build
62+
| dist
63+
| node_modules
64+
| venv
65+
)/
66+
"""
67+
68+
[tool.isort]
69+
profile ='black'
70+
71+
[tool.flake8]
72+
exclude= [".eggs",".git",".hg",".mypy_cache",".tox",".venv",".devcontainer","venv","_build","buck-out","build","dist"]
73+
statistics =true
74+
show-source =false
75+
max-line-length =120
76+
# E203,W503 and E704 are incompatible with the formatter black
77+
# W291 needs to be disabled because some doc-strings get generated with trailing whitespace but black won't re-format comments
78+
ignore = ["E203","W503","E704","W291"]
79+
inline-quotes ='"'
80+
docstring-quotes ='"""'
81+
multiline-quotes ='"""'
82+
ban-relative-imports =true
83+
per-file-ignores ="""
84+
# asserts are fine in tests, tests shouldn't be build optimized
85+
./tests/*: S101,
86+
# F841: some variables get generated but may not be used, depending on the api-spec
87+
# E501: long descriptions/string values might lead to lines that are too long
88+
./stackit/*/models/*: F841,E501
89+
# F841: some variables get generated but may not be used, depending on the api-spec
90+
# E501: long descriptions/string values might lead to lines that are too long
91+
# B028: stacklevel for deprecation warning is irrelevant
92+
./stackit/*/api/default_api.py: F841,B028,E501
93+
"""
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# coding: utf-8
2+
3+
# flake8: noqa
4+
5+
"""
6+
SKE-API
7+
8+
The SKE API provides endpoints to create, update, delete clusters within STACKIT portal projects and to trigger further cluster management tasks.
9+
10+
The version of the OpenAPI document: 1.1
11+
Generated by OpenAPI Generator (https://openapi-generator.tech)
12+
13+
Do not edit the class manually.
14+
"""# noqa: E501 docstring might be too long
15+
16+
17+
__version__="1.0.0"
18+
19+
# import apis into sdk package
20+
fromstackit.ske.api.default_apiimportDefaultApi
21+
fromstackit.ske.api_clientimportApiClient
22+
23+
# import ApiClient
24+
fromstackit.ske.api_responseimportApiResponse
25+
fromstackit.ske.configurationimportHostConfiguration
26+
fromstackit.ske.exceptionsimport (
27+
ApiAttributeError,
28+
ApiException,
29+
ApiKeyError,
30+
ApiTypeError,
31+
ApiValueError,
32+
OpenApiException,
33+
)
34+
35+
# import models into sdk package
36+
fromstackit.ske.models.aclimportACL
37+
fromstackit.ske.models.argusimportArgus
38+
fromstackit.ske.models.availability_zoneimportAvailabilityZone
39+
fromstackit.ske.models.clusterimportCluster
40+
fromstackit.ske.models.cluster_statusimportClusterStatus
41+
fromstackit.ske.models.cluster_status_stateimportClusterStatusState
42+
fromstackit.ske.models.create_kubeconfig_payloadimportCreateKubeconfigPayload
43+
fromstackit.ske.models.create_or_update_cluster_payloadimport (
44+
CreateOrUpdateClusterPayload,
45+
)
46+
fromstackit.ske.models.credentialsimportCredentials
47+
fromstackit.ske.models.credentials_rotation_stateimportCredentialsRotationState
48+
fromstackit.ske.models.criimportCRI
49+
fromstackit.ske.models.dnsimportDNS
50+
fromstackit.ske.models.extensionimportExtension
51+
fromstackit.ske.models.hibernationimportHibernation
52+
fromstackit.ske.models.hibernation_scheduleimportHibernationSchedule
53+
fromstackit.ske.models.imageimportImage
54+
fromstackit.ske.models.kubeconfigimportKubeconfig
55+
fromstackit.ske.models.kubernetesimportKubernetes
56+
fromstackit.ske.models.kubernetes_versionimportKubernetesVersion
57+
fromstackit.ske.models.list_clusters_responseimportListClustersResponse
58+
fromstackit.ske.models.login_kubeconfigimportLoginKubeconfig
59+
fromstackit.ske.models.machineimportMachine
60+
fromstackit.ske.models.machine_imageimportMachineImage
61+
fromstackit.ske.models.machine_image_versionimportMachineImageVersion
62+
fromstackit.ske.models.machine_typeimportMachineType
63+
fromstackit.ske.models.maintenanceimportMaintenance
64+
fromstackit.ske.models.maintenance_auto_updateimportMaintenanceAutoUpdate
65+
fromstackit.ske.models.networkimportNetwork
66+
fromstackit.ske.models.nodepoolimportNodepool
67+
fromstackit.ske.models.project_responseimportProjectResponse
68+
fromstackit.ske.models.project_stateimportProjectState
69+
fromstackit.ske.models.provider_optionsimportProviderOptions
70+
fromstackit.ske.models.runtime_errorimportRuntimeError
71+
fromstackit.ske.models.taintimportTaint
72+
fromstackit.ske.models.time_windowimportTimeWindow
73+
fromstackit.ske.models.volumeimportVolume
74+
fromstackit.ske.models.volume_typeimportVolumeType
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# flake8: noqa
2+
3+
# import apis into api package
4+
fromstackit.ske.api.default_apiimportDefaultApi

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp