Skip to content

Commit e4dfcce

Browse files
author
Clark Perkins
committed
Added utilities for labels
1 parent 3b3e288 commit e4dfcce

File tree

3 files changed

+71
-3
lines changed

3 files changed

+71
-3
lines changed

stackdio/cli/mixins/blueprints.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,19 @@ def delete_all_blueprints(client):
217217
for blueprint in client.list_blueprints():
218218
client.delete_blueprint(blueprint['id'])
219219
click.secho('Deleted blueprint {0}'.format(blueprint['title']), fg='magenta')
220+
221+
222+
@blueprints.command(name='create-label')
223+
@pass_client
224+
@click.argument('title')
225+
@click.argument('key')
226+
@click.argument('value')
227+
def create_label(client, title, key, value):
228+
"""
229+
Create a key:value label on a blueprint
230+
"""
231+
blueprint_id = get_blueprint_id(client, title)
232+
233+
client.add_blueprint_label(blueprint_id, key, value)
234+
235+
click.echo('Created label on {0}'.format(title))

stackdio/client/blueprint.py

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717

1818
from .exceptions import BlueprintException
19-
from .http import HttpMixin, get, post, delete
19+
from .http import HttpMixin, get, post, put, patch, delete
2020

2121

2222
class BlueprintMixin(HttpMixin):
@@ -67,6 +67,32 @@ def get_blueprint(self, blueprint_id):
6767
def search_blueprints(self, **kwargs):
6868
pass
6969

70-
@delete('blueprints/{blueprint_id}')
70+
@delete('blueprints/{blueprint_id}/')
7171
def delete_blueprint(self, blueprint_id):
7272
pass
73+
74+
@put('blueprints/{blueprint_id}/properties/')
75+
def update_blueprint_properties(self, blueprint_id, properties):
76+
return properties
77+
78+
@patch('blueprints/{blueprint_id}/properties/')
79+
def partial_update_blueprint_properties(self, blueprint_id, properties):
80+
return properties
81+
82+
@post('blueprints/{blueprint_id}/labels/')
83+
def add_blueprint_label(self, blueprint_id, key, value):
84+
return {
85+
'key': key,
86+
'value': value,
87+
}
88+
89+
@put('blueprints/{blueprint_id}/labels/{key}/')
90+
def update_blueprint_label(self, blueprint_id, key, value):
91+
return {
92+
'key': key,
93+
'value': value,
94+
}
95+
96+
@delete('blueprints/{blueprint_id}/labels/{key}/')
97+
def delete_blueprint_label(self, blueprint_id, key):
98+
pass

stackdio/client/stack.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717

1818
from .exceptions import StackException
19-
from .http import HttpMixin, get, post, put, delete
19+
from .http import HttpMixin, get, post, put, patch, delete
2020

2121

2222
class StackMixin(HttpMixin):
@@ -105,6 +105,32 @@ def get_stack_hosts(self, stack_id):
105105
"""Get a list of all stack hosts"""
106106
pass
107107

108+
@put('stacks/{stack_id}/properties/')
109+
def update_stack_properties(self, stack_id, properties):
110+
return properties
111+
112+
@patch('stacks/{stack_id}/properties/')
113+
def partial_update_stack_properties(self, stack_id, properties):
114+
return properties
115+
116+
@post('stacks/{stack_id}/labels/')
117+
def add_stack_label(self, stack_id, key, value):
118+
return {
119+
'key': key,
120+
'value': value,
121+
}
122+
123+
@put('stacks/{stack_id}/labels/{key}/')
124+
def update_stack_label(self, stack_id, key, value):
125+
return {
126+
'key': key,
127+
'value': value,
128+
}
129+
130+
@delete('stacks/{stack_id}/labels/{key}/')
131+
def delete_stack_label(self, stack_id, key):
132+
pass
133+
108134
@get('stacks/{stack_id}/logs/')
109135
def list_stack_logs(self, stack_id):
110136
"""Get a list of stack logs"""

0 commit comments

Comments
 (0)