-
Notifications
You must be signed in to change notification settings - Fork 976
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
Frameworks #6012
Merged
+121
−0
Merged
Frameworks #6012
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
14342b2
Initial commit to stacks api
svnsairam 7eac41d
Added more properties to the Stack and Build object
svnsairam d0d493e
Added api calls for framework stacks
svnsairam ca48bca
Changed naming
svnsairam feb6025
Changed naming
svnsairam cc90978
Merge remote-tracking branch 'origin/master' into fsk-m1-prop
svnsairam 81c2730
Review changes
svnsairam 7760c2d
Removed and used minimal fields
svnsairam 63fa9e3
Moved frameworks api file
svnsairam b7d05e6
Merge remote-tracking branch 'origin/master' into fsk-m1-prop
svnsairam 0f8eb17
Merge branch 'master' into fsk-m1-prop
svnsairam 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 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,117 @@ | ||
import { Client } from "../apiv2"; | ||
import { frameworksOrigin } from "../api"; | ||
|
||
export const API_VERSION = "v1"; | ||
|
||
const client = new Client({ | ||
urlPrefix: frameworksOrigin, | ||
auth: true, | ||
apiVersion: API_VERSION, | ||
}); | ||
|
||
export type State = "BUILDING" | "BUILD" | "DEPLOYING" | "READY" | "FAILED"; | ||
|
||
interface Codebase { | ||
repository?: string; | ||
rootDirectory: string; | ||
} | ||
|
||
/** A Stack, the primary resource of Frameworks. */ | ||
interface Stack { | ||
name: string; | ||
mode?: string; | ||
codebase: Codebase; | ||
labels: Record<string, string>; | ||
createTime: string; | ||
updateTime: string; | ||
uri: string; | ||
} | ||
|
||
export type StackOutputOnlyFields = "createTime" | "updateTime" | "uri"; | ||
|
||
interface Build { | ||
name: string; | ||
state: State; | ||
error: Status; | ||
image: string; | ||
source: BuildSource; | ||
buildLogsUri: string; | ||
createTime: Date; | ||
updateTime: Date; | ||
sourceRef: string; | ||
} | ||
|
||
export type BuildOutputOnlyFields = "createTime" | "updateTime" | "sourceRef"; | ||
|
||
interface BuildSource { | ||
codeBaseSource?: CodebaseSource; | ||
} | ||
|
||
interface Status { | ||
code: number; | ||
message: string; | ||
details: any[]; | ||
} | ||
|
||
interface CodebaseSource { | ||
// oneof reference | ||
branch: string; | ||
commit: string; | ||
tag: string; | ||
// end oneof reference | ||
} | ||
|
||
export interface OperationMetadata { | ||
createTime: string; | ||
endTime: string; | ||
target: string; | ||
verb: string; | ||
statusDetail: string; | ||
cancelRequested: boolean; | ||
apiVersion: string; | ||
} | ||
|
||
export interface Operation { | ||
name: string; | ||
metadata?: OperationMetadata; | ||
done: boolean; | ||
// oneof result | ||
error?: Status; | ||
response?: any; | ||
// end oneof result | ||
} | ||
|
||
/** | ||
* Creates a new Stack in a given project and location. | ||
*/ | ||
export async function createStack( | ||
projectId: string, | ||
location: string, | ||
stackId: string, | ||
stack: Stack | ||
): Promise<Operation> { | ||
const res = await client.post<Omit<Stack, StackOutputOnlyFields>, Operation>( | ||
`projects/${projectId}/locations/${location}/stacks`, | ||
stack, | ||
{ queryParams: { stackId } } | ||
); | ||
return res.body; | ||
} | ||
|
||
/** | ||
* Creates a new Build in a given project and location. | ||
*/ | ||
export async function createBuild( | ||
projectId: string, | ||
location: string, | ||
stackId: string, | ||
buildId: string, | ||
build: Build | ||
): Promise<Operation> { | ||
const res = await client.post<Omit<Build, BuildOutputOnlyFields>, Operation>( | ||
`projects/${projectId}/locations/${location}/stacks/${stackId}/builds`, | ||
build, | ||
{ queryParams: { buildId } } | ||
); | ||
return res.body; | ||
} |
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.
q: what do these mean 🤔 ?
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.
These are part of Long Running Operation object and they are returned as response from the rpc method,
name: Service assigned name which is unique. For HttpMapping, the
name
is a resource name ending withoperations/{unique_id}
.OperationMetadata: Service specific metadata associated with the operation. The is the metadata_type of the Operation.
done: If
false
then Operation is still running, iftrue
operation is completed.