33
44
55def create_deployment (name , project_id , spec , cluster_id = None ):
6- client = graphql_client ()
7- query = gql (
8- """
9- mutation createDeployment($input: CreateDeploymentInput!) {
10- createDeployment(input: $input) {
11- deployment {
12- id
13- }
14- }
15- }
16- """
17- )
18- params = {
19- "input" : {
20- "name" : name ,
21- "clusterId" : cluster_id ,
22- "projectId" : project_id ,
23- "spec" : spec ,
24- }
25- }
26- return client .execute (query , variable_values = params )['createDeployment' ]['deployment' ]
6+ client = graphql_client ()
7+ query = gql (
8+ """
9+ mutation createDeployment($input: CreateDeploymentInput!) {
10+ createDeployment(input: $input) {
11+ deployment {
12+ id
13+ }
14+ }
15+ }
16+ """
17+ )
18+ params = {
19+ "input" : {
20+ "name" : name ,
21+ "clusterId" : cluster_id ,
22+ "projectId" : project_id ,
23+ "spec" : spec ,
24+ }
25+ }
26+ return client .execute (query , variable_values = params )['createDeployment' ]['deployment' ]
2727
2828
2929def update_deployment (id , name = None , project_id = None , spec = None , cluster_id = None ):
30- client = graphql_client ()
31- query = gql (
32- """
33- mutation updateDeployment($input: UpdateDeploymentInput!) {
34- updateDeployment(input: $input) {
35- deployment {
36- id
37- }
38- }
39- }
40- """
41- )
30+ client = graphql_client ()
31+ query = gql (
32+ """
33+ mutation updateDeployment($input: UpdateDeploymentInput!) {
34+ updateDeployment(input: $input) {
35+ deployment {
36+ id
37+ }
38+ }
39+ }
40+ """
41+ )
4242
43- input = {
44- "id" : id ,
45- }
46- if name is not None :
47- input ["name" ] = name
48- if project_id is not None :
49- input ["projectId" ] = project_id
50- if cluster_id is not None :
51- input ["clusterId" ] = cluster_id
52- if spec is not None :
53- input ["spec" ] = spec
43+ input = {
44+ "id" : id ,
45+ }
46+ if name is not None :
47+ input ["name" ] = name
48+ if project_id is not None :
49+ input ["projectId" ] = project_id
50+ if cluster_id is not None :
51+ input ["clusterId" ] = cluster_id
52+ if spec is not None :
53+ input ["spec" ] = spec
5454
55- params = {
56- "input" : input
57- }
58- return client .execute (query , variable_values = params )['updateDeployment' ]['deployment' ]
55+ params = {
56+ "input" : input
57+ }
58+ return client .execute (query , variable_values = params )['updateDeployment' ]['deployment' ]
5959
6060
6161def get_deployment (id , first = 100 ):
62- client = graphql_client ()
63- query = gql (
64- """
65- query getDeployment($id: UUID!, $first: Int!) {
66- deployment(id: $id) {
67- id
68- name
69- deploymentSpecs(first: $first) {
70- nodes {
71- id
72- data {
73- image
74- port
75- resources {
76- instanceType
77- replicas
78- }
79- }
80- endpointUrl
81- actor {
82- avatarUrl
83- fullName
84- }
85- cluster {
86- id
87- }
88- data {
89- command
90- env {
91- name
92- value
93- }
94- image
95- models {
96- id
97- path
98- }
99- port
100- resources {
101- replicas
102- }
103- }
104- deploymentRuns(first: $first) {
105- nodes {
106- id
107- availableReplicas
108- readyReplicas
109- replicas
110- deploymentRunInstances(first: $first) {
111- nodes {
112- id
113- phase
114- dtStarted
115- dtFinished
116- }
117- }
118- }
119- }
120- }
121- }
122- }
123- }
124- """
125- )
126- params = {
127- "id" : id ,
128- "first" : first ,
129- }
130- return client .execute (query , variable_values = params )
62+ client = graphql_client ()
63+ query = gql (
64+ """
65+ query getDeployment($id: UUID!, $first: Int!) {
66+ deployment(id: $id) {
67+ id
68+ name
69+ deploymentSpecs(first: $first) {
70+ nodes {
71+ id
72+ data {
73+ image
74+ port
75+ resources {
76+ instanceType
77+ replicas
78+ }
79+ }
80+ endpointUrl
81+ actor {
82+ avatarUrl
83+ fullName
84+ }
85+ cluster {
86+ id
87+ }
88+ data {
89+ command
90+ env {
91+ name
92+ value
93+ }
94+ image
95+ models {
96+ id
97+ path
98+ }
99+ port
100+ resources {
101+ replicas
102+ }
103+ }
104+ deploymentRuns(first: $first) {
105+ nodes {
106+ id
107+ availableReplicas
108+ readyReplicas
109+ replicas
110+ deploymentRunInstances(first: $first) {
111+ nodes {
112+ id
113+ phase
114+ dtStarted
115+ dtFinished
116+ }
117+ }
118+ }
119+ }
120+ }
121+ }
122+ }
123+ }
124+ """
125+ )
126+ params = {
127+ "id" : id ,
128+ "first" : first ,
129+ }
130+ return client .execute (query , variable_values = params )
131131
132132
133133def list_deployments (first = 100 ):
134- client = graphql_client ()
135- query = gql (
136- """
137- query getDeployments($first: Int!) {
138- deployments(first: $first) {
139- nodes {
140- id
141- name
142- deploymentSpecs(first: $first) {
143- nodes {
144- id
145- data {
146- image
147- port
148- resources {
149- instanceType
150- replicas
151- }
152- }
153- endpointUrl
154- actor {
155- avatarUrl
156- fullName
157- }
158- deploymentRuns(first: $first) {
159- nodes {
160- id
161- availableReplicas
162- readyReplicas
163- replicas
164- deploymentRunInstances(first: $first) {
165- nodes {
166- id
167- phase
168- dtStarted
169- dtFinished
170- }
171- }
172- }
173- }
174- }
175- }
176- }
177- }
178- }
179- """
180- )
181- params = {
182- "first" : first ,
183- }
184- return client .execute (query , variable_values = params )['deployments' ]['nodes' ]
134+ client = graphql_client ()
135+ query = gql (
136+ """
137+ query getDeployments($first: Int!) {
138+ deployments(first: $first) {
139+ nodes {
140+ id
141+ name
142+ deploymentSpecs(first: $first) {
143+ nodes {
144+ id
145+ data {
146+ image
147+ port
148+ resources {
149+ instanceType
150+ replicas
151+ }
152+ }
153+ endpointUrl
154+ actor {
155+ avatarUrl
156+ fullName
157+ }
158+ deploymentRuns(first: $first) {
159+ nodes {
160+ id
161+ availableReplicas
162+ readyReplicas
163+ replicas
164+ deploymentRunInstances(first: $first) {
165+ nodes {
166+ id
167+ phase
168+ dtStarted
169+ dtFinished
170+ }
171+ }
172+ }
173+ }
174+ }
175+ }
176+ }
177+ }
178+ }
179+ """
180+ )
181+ params = {
182+ "first" : first ,
183+ }
184+ return client .execute (query , variable_values = params )['deployments' ]['nodes' ]
185185
186186
187187def delete_deployment (id ):
188- client = graphql_client ()
189- query = gql (
190- """
191- mutation deleteDeployment($input: DeleteDeploymentInput!) {
192- deleteDeployment(input: $input) {
193- deployment {
194- id
195- }
196- }
197- }
198- """
199- )
200- params = {
201- "input" : {
202- "id" : id ,
203- }
204- }
205- return client .execute (query , variable_values = params )['deleteDeployment' ]
188+ client = graphql_client ()
189+ query = gql (
190+ """
191+ mutation deleteDeployment($input: DeleteDeploymentInput!) {
192+ deleteDeployment(input: $input) {
193+ deployment {
194+ id
195+ }
196+ }
197+ }
198+ """
199+ )
200+ params = {
201+ "input" : {
202+ "id" : id ,
203+ }
204+ }
205+ return client .execute (query , variable_values = params )['deleteDeployment' ]
0 commit comments