Skip to content

Commit c6726f8

Browse files
Merge pull request #409 from linode/dev
v5.16.0
2 parents 69d9e55 + 90b43ab commit c6726f8

34 files changed

+763
-62
lines changed

.github/workflows/e2e-test.yml

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,35 +36,21 @@ jobs:
3636
run: |
3737
timestamp=$(date +'%Y%m%d%H%M')
3838
report_filename="${timestamp}_sdk_test_report.xml"
39-
status=0
40-
if ! python3 -m pytest test/integration/${INTEGRATION_TEST_PATH} --disable-warnings --junitxml="${report_filename}"; then
41-
echo "EXIT_STATUS=1" >> $GITHUB_ENV
42-
fi
39+
make testint TEST_ARGS="--junitxml=${report_filename}"
4340
env:
4441
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}
4542

46-
- name: Add additional information to XML report
43+
- name: Upload test results
44+
if: always()
4745
run: |
4846
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
4947
python tod_scripts/add_to_xml_test_report.py \
5048
--branch_name "${GITHUB_REF#refs/*/}" \
5149
--gha_run_id "$GITHUB_RUN_ID" \
5250
--gha_run_number "$GITHUB_RUN_NUMBER" \
5351
--xmlfile "${filename}"
54-
55-
- name: Upload test results
56-
run: |
57-
report_filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
58-
python3 tod_scripts/test_report_upload_script.py "${report_filename}"
52+
sync
53+
python3 tod_scripts/test_report_upload_script.py "${filename}"
5954
env:
6055
LINODE_CLI_OBJ_ACCESS_KEY: ${{ secrets.LINODE_CLI_OBJ_ACCESS_KEY }}
6156
LINODE_CLI_OBJ_SECRET_KEY: ${{ secrets.LINODE_CLI_OBJ_SECRET_KEY }}
62-
63-
- name: Test Execution Status Handler
64-
run: |
65-
if [[ "$EXIT_STATUS" != 0 ]]; then
66-
echo "Test execution contains failure(s)"
67-
exit $EXIT_STATUS
68-
else
69-
echo "Tests passed!"
70-
fi

.python-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.8.10
1+
linode_api4-python

Makefile

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
11
PYTHON ?= python3
22

3-
INTEGRATION_TEST_PATH :=
43
TEST_CASE_COMMAND :=
5-
MODEL_COMMAND :=
4+
TEST_SUITE :=
5+
TEST_ARGS :=
66

77
LINODE_SDK_VERSION ?= "0.0.0.dev"
88
VERSION_MODULE_DOCSTRING ?= \"\"\"\nThe version of this linode_api4 package.\n\"\"\"\n\n
99
VERSION_FILE := ./linode_api4/version.py
1010

1111
ifdef TEST_CASE
12-
TEST_CASE_COMMAND = -k $(TEST_CASE)
12+
TEST_CASE_COMMAND = -k $(TEST_CASE)
1313
endif
1414

15-
ifdef TEST_MODEL
16-
MODEL_COMMAND = models/$(TEST_MODEL)
15+
ifdef TEST_SUITE
16+
ifneq ($(TEST_SUITE),linode_client)
17+
ifneq ($(TEST_SUITE),login_client)
18+
TEST_COMMAND = models/$(TEST_SUITE)
19+
else
20+
TEST_COMMAND = login_client
21+
endif
22+
else
23+
TEST_COMMAND = linode_client
24+
endif
1725
endif
1826

1927
.PHONY: clean
@@ -67,7 +75,7 @@ lint: build
6775

6876
.PHONY: testint
6977
testint:
70-
$(PYTHON) -m pytest test/integration/${INTEGRATION_TEST_PATH}${MODEL_COMMAND} ${TEST_CASE_COMMAND}
78+
$(PYTHON) -m pytest test/integration/${TEST_COMMAND} ${TEST_CASE_COMMAND} ${TEST_ARGS}
7179

7280
.PHONY: testunit
7381
testunit:

README.rst

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,10 @@ Run the tests locally using the make command. Run the entire test suite using co
150150

151151
make testint
152152

153-
To run a specific package, use environment variable `INTEGRATION_TEST_PATH` with `testint` command::
153+
To run a specific package/suite, use the environment variable `TEST_SUITE` using directory names in `integration/...` folder ::
154154

155-
make INTEGRATION_TEST_PATH="linode_client" testint
156-
157-
To run a specific model test suite, set the environment variable `TEST_MODEL` using file name in `integration/models`::
158-
159-
make TEST_MODEL="test_account.py" testint
155+
make TEST_SUITE="account" testint // Runs tests in `integration/models/account` directory
156+
make TEST_SUITE="linode_client" testint // Runs tests in `integration/linode_client` directory
160157

161158
Lastly to run a specific test case use environment variable `TEST_CASE` with `testint` command::
162159

linode_api4/groups/account.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
AccountBetaProgram,
99
AccountSettings,
1010
BetaProgram,
11+
ChildAccount,
1112
Event,
1213
Invoice,
1314
Login,
@@ -18,6 +19,7 @@
1819
ServiceTransfer,
1920
User,
2021
)
22+
from linode_api4.objects.profile import PersonalAccessToken
2123

2224

2325
class AccountGroup(Group):
@@ -496,3 +498,14 @@ def availabilities(self, *filters):
496498
:rtype: PaginatedList of AccountAvailability
497499
"""
498500
return self.client._get_and_filter(AccountAvailability, *filters)
501+
502+
def child_accounts(self, *filters):
503+
"""
504+
Returns a list of all child accounts under the this parent account.
505+
506+
API doc: TBD
507+
508+
:returns: a list of all child accounts.
509+
:rtype: PaginatedList of ChildAccount
510+
"""
511+
return self.client._get_and_filter(ChildAccount, *filters)

linode_api4/groups/lke.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
from typing import Any, Dict, Union
2+
13
from linode_api4.errors import UnexpectedResponseError
24
from linode_api4.groups import Group
3-
from linode_api4.objects import Base, KubeVersion, LKECluster
5+
from linode_api4.objects import (
6+
Base,
7+
JSONObject,
8+
KubeVersion,
9+
LKECluster,
10+
LKEClusterControlPlaneOptions,
11+
drop_null_keys,
12+
)
413

514

615
class LKEGroup(Group):
@@ -47,7 +56,17 @@ def clusters(self, *filters):
4756
"""
4857
return self.client._get_and_filter(LKECluster, *filters)
4958

50-
def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
59+
def cluster_create(
60+
self,
61+
region,
62+
label,
63+
node_pools,
64+
kube_version,
65+
control_plane: Union[
66+
LKEClusterControlPlaneOptions, Dict[str, Any]
67+
] = None,
68+
**kwargs,
69+
):
5170
"""
5271
Creates an :any:`LKECluster` on this account in the given region, with
5372
the given label, and with node pools as described. For example::
@@ -80,6 +99,8 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
8099
formatted dicts.
81100
:param kube_version: The version of Kubernetes to use
82101
:type kube_version: KubeVersion or str
102+
:param control_plane: Dict[str, Any] or LKEClusterControlPlaneRequest
103+
:type control_plane: The control plane configuration of this LKE cluster.
83104
:param kwargs: Any other arguments to pass along to the API. See the API
84105
docs for possible values.
85106
@@ -112,10 +133,15 @@ def cluster_create(self, region, label, node_pools, kube_version, **kwargs):
112133
if issubclass(type(kube_version), Base)
113134
else kube_version
114135
),
136+
"control_plane": (
137+
control_plane.dict
138+
if issubclass(type(control_plane), JSONObject)
139+
else control_plane
140+
),
115141
}
116142
params.update(kwargs)
117143

118-
result = self.client.post("/lke/clusters", data=params)
144+
result = self.client.post("/lke/clusters", data=drop_null_keys(params))
119145

120146
if "id" not in result:
121147
raise UnexpectedResponseError(

linode_api4/objects/account.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from datetime import datetime
24

35
import requests
@@ -16,6 +18,7 @@
1618
)
1719
from linode_api4.objects.longview import LongviewClient, LongviewSubscription
1820
from linode_api4.objects.nodebalancer import NodeBalancer
21+
from linode_api4.objects.profile import PersonalAccessToken
1922
from linode_api4.objects.support import SupportTicket
2023

2124

@@ -53,6 +56,37 @@ class Account(Base):
5356
}
5457

5558

59+
class ChildAccount(Account):
60+
"""
61+
A child account under a parent account.
62+
63+
API Documentation: TBD
64+
"""
65+
66+
api_endpoint = "/account/child-accounts/{euuid}"
67+
id_attribute = "euuid"
68+
69+
def create_token(self, **kwargs):
70+
"""
71+
Create a ephemeral token for accessing the child account.
72+
73+
API Documentation: TBD
74+
"""
75+
resp = self._client.post(
76+
"{}/token".format(self.api_endpoint),
77+
model=self,
78+
data=kwargs,
79+
)
80+
81+
if "errors" in resp:
82+
raise UnexpectedResponseError(
83+
"Unexpected response when creating a token for the child account!",
84+
json=resp,
85+
)
86+
87+
return PersonalAccessToken(self._client, resp["id"], resp)
88+
89+
5690
class ServiceTransfer(Base):
5791
"""
5892
A transfer request for transferring a service between Linode accounts.
@@ -476,6 +510,7 @@ class User(Base):
476510
properties = {
477511
"email": Property(),
478512
"username": Property(identifier=True, mutable=True),
513+
"user_type": Property(),
479514
"restricted": Property(mutable=True),
480515
"ssh_keys": Property(),
481516
"tfa_enabled": Property(),

0 commit comments

Comments
 (0)