File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed
examples/src/environments
src/features/deploymentEnvironments Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ import { ClientConfiguration , EnvironmentRepository } from "../../../src/index" ;
2+ import { CreateClient , GetProject } from "../utility" ;
3+
4+ const main = async ( ) => {
5+ const projectNameOrId : string = "project-name-or-ID" ;
6+ const environmentName : string = "an-ephemeral-environment-name" ;
7+
8+ const configuration : ClientConfiguration = {
9+ userAgentApp : "examples" ,
10+ instanceURL : "instance-url" , // required
11+ apiKey : "api-key" , // required
12+ } ;
13+
14+ const client = await CreateClient ( configuration ) ;
15+
16+ console . log ( `Getting project: ${ projectNameOrId } ` ) ;
17+ const project = await GetProject ( client , projectNameOrId ) ;
18+
19+ const environmentsRepo = new EnvironmentRepository ( client , "Default" ) ;
20+
21+ console . log ( `Creating ephemeral environment: ${ environmentName } ` ) ;
22+ const environment = await environmentsRepo . createEphemeralEnvironment ( environmentName , project . Id ) ;
23+
24+ console . log ( `Getting ephemeral environment status: ${ environment . Id } ` ) ;
25+ const response = await environmentsRepo . getEphemeralEnvironmentProjectStatus ( environment . Id , project . Id ) ;
26+
27+ console . log ( `Ephemeral Environment Status: ${ response . Status } ` ) ;
28+ } ;
29+
30+ main ( ) ;
Original file line number Diff line number Diff line change @@ -56,6 +56,18 @@ export class EnvironmentRepository extends SpaceScopedBasicRepository<Deployment
5656 return response ;
5757 }
5858
59+ async getEphemeralEnvironmentProjectStatus ( environmentId : string , projectId : string ) : Promise < GetEphemeralEnvironmentProjectStatusResponse > {
60+ const response = await this . client . request < GetEphemeralEnvironmentProjectStatusResponse > (
61+ `${ spaceScopedRoutePrefix } /projects/{projectId}/environments/ephemeral/{id}/status` ,
62+ {
63+ spaceName : this . spaceName ,
64+ projectId : projectId ,
65+ id : environmentId ,
66+ }
67+ ) ;
68+ return response ;
69+ }
70+
5971 async deprovisionEphemeralEnvironmentForProject ( environmentId : string , projectId : string ) : Promise < DeprovisionEphemeralEnvironmentProjectResponse > {
6072 const response = await this . client . doCreate < DeprovisionEphemeralEnvironmentProjectResponse > (
6173 `${ spaceScopedRoutePrefix } /projects/{projectId}/environments/ephemeral/{environmentId}/deprovision` ,
@@ -151,3 +163,7 @@ export interface DeprovisionEphemeralEnvironmentProjectResponse {
151163export interface DeprovisionEphemeralEnvironmentResponse {
152164 DeprovisioningRuns ?: DeprovisioningRunbookRun [ ] ;
153165}
166+
167+ export interface GetEphemeralEnvironmentProjectStatusResponse {
168+ Status : string ;
169+ }
You can’t perform that action at this time.
0 commit comments