-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat(configurationversion): add ConfigurationVersion * feat(workspaces): get workspace by name / id * chore(dependencies): downgrade axios due to "ProgressEvent" type errors * feat(apiclient): camelcase all keys, not only root level * chore(types): ignore linter for `any` * feat(plans): get json plan output * fix(runs): actions don't return any entities * fix(run): typo * feat(applies): add apply resource * fix(tests): adapt to fixed typo * fix(workspaces): typed executionMode * feat(state-versions): add state versions
- Loading branch information
Showing
19 changed files
with
237 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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,19 @@ | ||
import { AxiosInstance } from 'axios' | ||
import { Apply, ApplyLogs } from '../..' | ||
import Request from './Request' | ||
|
||
export default class Applies extends Request { | ||
constructor(client: AxiosInstance) { | ||
super(client) | ||
} | ||
|
||
async show(applyId: string): Promise<Apply> { | ||
const path = `/applies/${applyId}` | ||
return await this.get<Apply>(path) | ||
} | ||
|
||
async logs(applyId: string): Promise<ApplyLogs> { | ||
const apply = await this.show(applyId) | ||
return await this.client.get(apply.attributes.logReadUrl) | ||
} | ||
} |
This file contains 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,22 @@ | ||
import Request from './Request' | ||
import { ConfigurationVersion, ConfigurationVersionRequest } from '../../types' | ||
import axios, { AxiosInstance } from 'axios' | ||
|
||
export default class ConfigurationVersions extends Request { | ||
constructor(client: AxiosInstance) { | ||
super(client) | ||
} | ||
|
||
create(workspaceId: string, request?: ConfigurationVersionRequest): Promise<ConfigurationVersion> { | ||
const path = `/workspaces/${workspaceId}/configuration-versions` | ||
return this.post<ConfigurationVersion, ConfigurationVersionRequest>( | ||
path, | ||
request || { data: { attributes: {}, type: 'configuration-version' } } | ||
) | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types | ||
async upload(url: string, data: any): Promise<any> { | ||
return await axios.put(url, data) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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,27 @@ | ||
import Request from './Request' | ||
import { StateVersion, StateVersionRequest } from '../../types' | ||
import { AxiosInstance } from 'axios' | ||
|
||
export default class StateVersions extends Request { | ||
constructor(client: AxiosInstance) { | ||
super(client) | ||
} | ||
|
||
create(workspaceId: string, request: StateVersionRequest): Promise<StateVersion> { | ||
const path = `/workspaces/${workspaceId}/state-versions` | ||
return this.post<StateVersion, StateVersionRequest>(path, request) | ||
} | ||
|
||
show(stateVersionId: string, includeOutputs = false): Promise<StateVersion> { | ||
const path = `/state-versions/${stateVersionId}${includeOutputs ? '?include=outputs' : ''}` | ||
return this.get<StateVersion>(path) | ||
} | ||
|
||
current(workspaceId: string, includeOutputs = false): Promise<StateVersion> { | ||
const path = `/workspaces/${workspaceId}/current-state-version` | ||
const params: { [key: string]: string } = {} | ||
if (includeOutputs) params.include = 'outputs' | ||
|
||
return this.client.get(path, { params }) | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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,5 +1,6 @@ | ||
export * from './api/TerraformCloud' | ||
export * from './types/Plan' | ||
export * from './types/Apply' | ||
export * from './types/Run' | ||
export * from './types/TerraformCloudData' | ||
export * from './types/User' |
This file contains 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,38 @@ | ||
import { TerraformCloudData, Data } from './TerraformCloudData' | ||
|
||
export type Apply = TerraformCloudData<ApplyAttributes> & { | ||
relationships: ApplyRelationship | ||
} | ||
|
||
export type ApplyLogs = { | ||
firstIndex: number | ||
lastIndex: number | ||
size: number | ||
data: string | ||
} | ||
|
||
export type StateVersionsRelationship = { | ||
data: Data[] | ||
} | ||
|
||
export interface ApplyRelationship { | ||
stateVersions: StateVersionsRelationship | ||
} | ||
|
||
export interface ApplyTimestamps { | ||
queuedAt: Date | ||
startedAt: Date | ||
finishedAt: Date | ||
} | ||
|
||
export interface ApplyAttributes { | ||
executionDetails: { | ||
mode: 'remote' | ||
} | ||
status: 'pending' | 'managed_queued' | 'queued' | 'running' | 'errored' | 'canceled' | 'finished' | 'unreachable' | ||
statusTimestamps: ApplyTimestamps | ||
logReadUrl: string | ||
resourceAdditions: number | ||
resourceChanges: number | ||
resourceDestructions: number | ||
} |
This file contains 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,19 @@ | ||
import { Params, TerraformCloudData } from './TerraformCloudData' | ||
|
||
export type ConfigurationVersionRequest = Params<'configuration-version', ConfigurationVersionRequestAttributes> | ||
|
||
export interface ConfigurationVersionRequestAttributes { | ||
autoQueueRuns?: boolean | ||
speculative?: boolean | ||
} | ||
export type ConfigurationVersion = TerraformCloudData<ConfigurationVersionAttributes> | ||
|
||
export interface ConfigurationVersionAttributes { | ||
autoQueueRuns: boolean | ||
error?: string | ||
errorMessage?: string | ||
source: string | ||
status: string | ||
statusTimestamps: { [key: string]: unknown } | ||
uploadUrl: string | ||
} |
This file contains 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
This file contains 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,57 @@ | ||
import { Params, TerraformCloudData } from './TerraformCloudData' | ||
|
||
export type StateVersionRequest = Params<'state-version', StateVersionRequestAttributes> & { | ||
relationships: StateVersionRelationship | ||
} | ||
|
||
export interface StateVersionRelationData { | ||
id: string | ||
type: string | ||
} | ||
|
||
export interface StateVersionRelationship { | ||
run: { | ||
data: { | ||
type: string | ||
} | ||
} | ||
outputs: { | ||
data: StateVersionRelationData[] | ||
} | ||
createdby: { | ||
data: StateVersionRelationData[] | ||
links: { | ||
related: string | ||
} | ||
} | ||
} | ||
|
||
export interface StateVersionRequestAttributes { | ||
serial: number | ||
md5: string | ||
lineage: string | ||
state: string | ||
} | ||
|
||
export interface StateVersionIncludedOutput { | ||
id: string | ||
type: string | ||
attributes: { | ||
name: string | ||
sensitive: boolean | ||
type: string | ||
value: string | ||
} | ||
} | ||
|
||
export type StateVersion = TerraformCloudData<StateVersionAttributes> & { | ||
included?: StateVersionIncludedOutput[] | ||
} | ||
|
||
export interface StateVersionAttributes { | ||
vcsCommitSha?: string | ||
vcsCommitUrl?: string | ||
createdAt: Date | ||
hostedStateDownloadUrl: string | ||
serial: number | ||
} |
This file contains 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
This file contains 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,5 +1,8 @@ | ||
export * from './User' | ||
export * from './Plan' | ||
export * from './Apply' | ||
export * from './Run' | ||
export * from './TerraformCloudData' | ||
export * from './Workspace' | ||
export * from './ConfigurationVersion' | ||
export * from './StateVersion' |
This file contains 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
This file contains 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
This file contains 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