Skip to content

Commit b292d8f

Browse files
feat(cli): add --name flag to environment create command
1 parent 5febe77 commit b292d8f

5 files changed

Lines changed: 52 additions & 4 deletions

File tree

.stats.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 170
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-2423c089f280cdf34a987d40531692097a69f4aa971c6adf9aeec4fd7984cec2.yml
3-
openapi_spec_hash: 24037c3ab9ceca689150d07ecec7aa80
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/gitpod%2Fgitpod-b43acdb0d7e591ca6dc119778dfc405afa6c4d5aeb43d06fc6aff9f941c552b6.yml
3+
openapi_spec_hash: f52b33b13c9efa8f5941d40dc6315e80
44
config_hash: d726afb2a92132197e4eae04303e8041

src/gitpod/resources/environments/environments.py

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ def with_streaming_response(self) -> EnvironmentsResourceWithStreamingResponse:
9191
def create(
9292
self,
9393
*,
94+
name: Optional[str] | Omit = omit,
9495
spec: EnvironmentSpecParam | Omit = omit,
9596
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
9697
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -164,6 +165,9 @@ def create(
164165
```
165166
166167
Args:
168+
name: name is a user-defined identifier for the environment. If not specified, the
169+
system will generate a name.
170+
167171
spec: spec is the configuration of the environment that's required for the to start
168172
the environment
169173
@@ -177,7 +181,13 @@ def create(
177181
"""
178182
return self._post(
179183
"/gitpod.v1.EnvironmentService/CreateEnvironment",
180-
body=maybe_transform({"spec": spec}, environment_create_params.EnvironmentCreateParams),
184+
body=maybe_transform(
185+
{
186+
"name": name,
187+
"spec": spec,
188+
},
189+
environment_create_params.EnvironmentCreateParams,
190+
),
181191
options=make_request_options(
182192
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
183193
),
@@ -549,6 +559,7 @@ def create_environment_token(
549559
def create_from_project(
550560
self,
551561
*,
562+
name: Optional[str] | Omit = omit,
552563
project_id: str | Omit = omit,
553564
spec: EnvironmentSpecParam | Omit = omit,
554565
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -591,6 +602,9 @@ def create_from_project(
591602
```
592603
593604
Args:
605+
name: name is a user-defined identifier for the environment. If not specified, the
606+
system will generate a name.
607+
594608
spec: Spec is the configuration of the environment that's required for the runner to
595609
start the environment Configuration already defined in the Project will override
596610
parts of the spec, if set
@@ -607,6 +621,7 @@ def create_from_project(
607621
"/gitpod.v1.EnvironmentService/CreateEnvironmentFromProject",
608622
body=maybe_transform(
609623
{
624+
"name": name,
610625
"project_id": project_id,
611626
"spec": spec,
612627
},
@@ -905,6 +920,7 @@ def with_streaming_response(self) -> AsyncEnvironmentsResourceWithStreamingRespo
905920
async def create(
906921
self,
907922
*,
923+
name: Optional[str] | Omit = omit,
908924
spec: EnvironmentSpecParam | Omit = omit,
909925
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
910926
# The extra values given here take precedence over values defined on the client or passed to this method.
@@ -978,6 +994,9 @@ async def create(
978994
```
979995
980996
Args:
997+
name: name is a user-defined identifier for the environment. If not specified, the
998+
system will generate a name.
999+
9811000
spec: spec is the configuration of the environment that's required for the to start
9821001
the environment
9831002
@@ -991,7 +1010,13 @@ async def create(
9911010
"""
9921011
return await self._post(
9931012
"/gitpod.v1.EnvironmentService/CreateEnvironment",
994-
body=await async_maybe_transform({"spec": spec}, environment_create_params.EnvironmentCreateParams),
1013+
body=await async_maybe_transform(
1014+
{
1015+
"name": name,
1016+
"spec": spec,
1017+
},
1018+
environment_create_params.EnvironmentCreateParams,
1019+
),
9951020
options=make_request_options(
9961021
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
9971022
),
@@ -1363,6 +1388,7 @@ async def create_environment_token(
13631388
async def create_from_project(
13641389
self,
13651390
*,
1391+
name: Optional[str] | Omit = omit,
13661392
project_id: str | Omit = omit,
13671393
spec: EnvironmentSpecParam | Omit = omit,
13681394
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
@@ -1405,6 +1431,9 @@ async def create_from_project(
14051431
```
14061432
14071433
Args:
1434+
name: name is a user-defined identifier for the environment. If not specified, the
1435+
system will generate a name.
1436+
14081437
spec: Spec is the configuration of the environment that's required for the runner to
14091438
start the environment Configuration already defined in the Project will override
14101439
parts of the spec, if set
@@ -1421,6 +1450,7 @@ async def create_from_project(
14211450
"/gitpod.v1.EnvironmentService/CreateEnvironmentFromProject",
14221451
body=await async_maybe_transform(
14231452
{
1453+
"name": name,
14241454
"project_id": project_id,
14251455
"spec": spec,
14261456
},

src/gitpod/types/environment_create_from_project_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
56
from typing_extensions import Annotated, TypedDict
67

78
from .._utils import PropertyInfo
@@ -11,6 +12,12 @@
1112

1213

1314
class EnvironmentCreateFromProjectParams(TypedDict, total=False):
15+
name: Optional[str]
16+
"""
17+
name is a user-defined identifier for the environment. If not specified, the
18+
system will generate a name.
19+
"""
20+
1421
project_id: Annotated[str, PropertyInfo(alias="projectId")]
1522

1623
spec: EnvironmentSpecParam

src/gitpod/types/environment_create_params.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from __future__ import annotations
44

5+
from typing import Optional
56
from typing_extensions import TypedDict
67

78
from .environment_spec_param import EnvironmentSpecParam
@@ -10,6 +11,12 @@
1011

1112

1213
class EnvironmentCreateParams(TypedDict, total=False):
14+
name: Optional[str]
15+
"""
16+
name is a user-defined identifier for the environment. If not specified, the
17+
system will generate a name.
18+
"""
19+
1320
spec: EnvironmentSpecParam
1421
"""
1522
spec is the configuration of the environment that's required for the to start

tests/api_resources/test_environments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def test_method_create(self, client: Gitpod) -> None:
3636
@parametrize
3737
def test_method_create_with_all_params(self, client: Gitpod) -> None:
3838
environment = client.environments.create(
39+
name="name",
3940
spec={
4041
"admission": "ADMISSION_LEVEL_UNSPECIFIED",
4142
"automations_file": {
@@ -387,6 +388,7 @@ def test_method_create_from_project(self, client: Gitpod) -> None:
387388
@parametrize
388389
def test_method_create_from_project_with_all_params(self, client: Gitpod) -> None:
389390
environment = client.environments.create_from_project(
391+
name="name",
390392
project_id="b0e12f6c-4c67-429d-a4a6-d9838b5da047",
391393
spec={
392394
"admission": "ADMISSION_LEVEL_UNSPECIFIED",
@@ -692,6 +694,7 @@ async def test_method_create(self, async_client: AsyncGitpod) -> None:
692694
@parametrize
693695
async def test_method_create_with_all_params(self, async_client: AsyncGitpod) -> None:
694696
environment = await async_client.environments.create(
697+
name="name",
695698
spec={
696699
"admission": "ADMISSION_LEVEL_UNSPECIFIED",
697700
"automations_file": {
@@ -1043,6 +1046,7 @@ async def test_method_create_from_project(self, async_client: AsyncGitpod) -> No
10431046
@parametrize
10441047
async def test_method_create_from_project_with_all_params(self, async_client: AsyncGitpod) -> None:
10451048
environment = await async_client.environments.create_from_project(
1049+
name="name",
10461050
project_id="b0e12f6c-4c67-429d-a4a6-d9838b5da047",
10471051
spec={
10481052
"admission": "ADMISSION_LEVEL_UNSPECIFIED",

0 commit comments

Comments
 (0)