-
Notifications
You must be signed in to change notification settings - Fork 2
fix: Add environmentV2 repository to list new environment types #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a589603
Testing updated env repo with deploy action
caitlynstocker ae23089
Swap out for v2 endpoint
caitlynstocker 20fae2b
Add example
caitlynstocker e682e8f
Add v2 environments repo
caitlynstocker c7b3cdc
Pass through all args
caitlynstocker 365cd05
Add type to list args
caitlynstocker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { ClientConfiguration, EnvironmentV2Repository } from "../../../src/index"; | ||
| import { CreateClient } from "../utility"; | ||
|
|
||
| const main = async () => { | ||
|
|
||
| const configuration: ClientConfiguration = { | ||
| userAgentApp: "examples", | ||
| instanceURL: "instance-url", // required | ||
| apiKey: "api-key", // required | ||
| }; | ||
|
|
||
| const client = await CreateClient(configuration); | ||
|
|
||
| const environmentsRepo = new EnvironmentV2Repository(client, "Default"); | ||
|
|
||
| const environments = await environmentsRepo.list({ skip: 0, take: 1000 }); | ||
|
|
||
| if (environments.Items.length === 0) { | ||
| console.log("No environments found."); | ||
| return; | ||
| } | ||
| environments.Items.map(env => console.log(` - ${env.Name} (ID: ${env.Id})`)); | ||
| }; | ||
|
|
||
| main(); |
28 changes: 28 additions & 0 deletions
28
src/features/deploymentEnvironments/environmentV2Repository.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { Client, DeploymentEnvironmentV2, ResourceCollection, spaceScopedRoutePrefix } from "../.."; | ||
|
|
||
| type EnvironmentV2RepositoryListArgs = { | ||
| ids?: string[]; | ||
| partialName?: string; | ||
| type?: EnvironmentType; | ||
| skip: number; | ||
| take: number; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've made the skip and take values required as they're required on the v2 endpoint. |
||
| }; | ||
|
|
||
| type EnvironmentType = "Static" | "Parent" | "Ephemeral"; | ||
|
|
||
| export class EnvironmentV2Repository { | ||
| private client: Client; | ||
| private spaceName: string; | ||
|
|
||
| constructor(client: Client, spaceName: string) { | ||
| this.client = client; | ||
| this.spaceName = spaceName; | ||
| } | ||
|
|
||
| async list(args?: EnvironmentV2RepositoryListArgs): Promise<ResourceCollection<DeploymentEnvironmentV2>> { | ||
| return this.client.request(`${spaceScopedRoutePrefix}/environments/v2{?ids,partialName,type,skip,take}`, { | ||
| spaceName: this.spaceName, | ||
| ...args, | ||
| }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,3 @@ | ||
| export * from "./deploymentEnvironment"; | ||
| export * from "./environmentRepository"; | ||
| export * from "./environmentV2Repository"; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The v2 endpoint supports optional filtering by an array of environment types using the
typeproperty, for completeness it's prob worth adding that as well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea :)