Skip to content

Commit 55f76ba

Browse files
fix: Add environmentV2 repository to list new environment types (#244)
* Add v2 environments repo * Add example code to list v2 environments
1 parent 60e129e commit 55f76ba

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ClientConfiguration, EnvironmentV2Repository } from "../../../src/index";
2+
import { CreateClient } from "../utility";
3+
4+
const main = async () => {
5+
6+
const configuration: ClientConfiguration = {
7+
userAgentApp: "examples",
8+
instanceURL: "instance-url", // required
9+
apiKey: "api-key", // required
10+
};
11+
12+
const client = await CreateClient(configuration);
13+
14+
const environmentsRepo = new EnvironmentV2Repository(client, "Default");
15+
16+
const environments = await environmentsRepo.list({ skip: 0, take: 1000 });
17+
18+
if (environments.Items.length === 0) {
19+
console.log("No environments found.");
20+
return;
21+
}
22+
environments.Items.map(env => console.log(` - ${env.Name} (ID: ${env.Id})`));
23+
};
24+
25+
main();
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { Client, DeploymentEnvironmentV2, ResourceCollection, spaceScopedRoutePrefix } from "../..";
2+
3+
type EnvironmentV2RepositoryListArgs = {
4+
ids?: string[];
5+
partialName?: string;
6+
type?: EnvironmentType;
7+
skip: number;
8+
take: number;
9+
};
10+
11+
type EnvironmentType = "Static" | "Parent" | "Ephemeral";
12+
13+
export class EnvironmentV2Repository {
14+
private client: Client;
15+
private spaceName: string;
16+
17+
constructor(client: Client, spaceName: string) {
18+
this.client = client;
19+
this.spaceName = spaceName;
20+
}
21+
22+
async list(args?: EnvironmentV2RepositoryListArgs): Promise<ResourceCollection<DeploymentEnvironmentV2>> {
23+
return this.client.request(`${spaceScopedRoutePrefix}/environments/v2{?ids,partialName,type,skip,take}`, {
24+
spaceName: this.spaceName,
25+
...args,
26+
});
27+
}
28+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from "./deploymentEnvironment";
22
export * from "./environmentRepository";
3+
export * from "./environmentV2Repository";

0 commit comments

Comments
 (0)