Debian Codegraph @

glanceclient/v2/image_tags.py

raw symbols SCIP
1 # Copyright 2013 OpenStack Foundation
2 # All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
14 # under the License.
15
16 import warlock
17
18 from glanceclient.common import utils
19 from glanceclient.v2 import schemas
20
21
22 class Controller(object):
23 def __init__(self, http_client, schema_client):
24 self.http_client = http_client
25 self.schema_client = schema_client
26
27 @utils.memoized_property
28 def model(self):
29 schema = self.schema_client.get('image')
30 return warlock.model_factory(schema.raw(),
31 base_class=schemas.SchemaBasedModel)
32
33 @utils.add_req_id_to_object()
34 def update(self, image_id, tag_value):
35 """Update an image with the given tag.
36
37 :param image_id: image to be updated with the given tag.
38 :param tag_value: value of the tag.
39 """
40 url = '/v2/images/%s/tags/%s' % (image_id, tag_value)
41 resp, body = self.http_client.put(url)
42 return (resp, body), resp
43
44 @utils.add_req_id_to_object()
45 def delete(self, image_id, tag_value):
46 """Delete the tag associated with the given image.
47
48 :param image_id: Image whose tag to be deleted.
49 :param tag_value: tag value to be deleted.
50 """
51 url = '/v2/images/%s/tags/%s' % (image_id, tag_value)
52 resp, body = self.http_client.delete(url)
53 return (resp, body), resp