1# Licensed under the Apache License, Version 2.0 (the "License");
2# you may not use this file except in compliance with the License.
3# You may obtain a copy of the License at
4#
5#    http://www.apache.org/licenses/LICENSE-2.0
6#
7# Unless required by applicable law or agreed to in writing, software
8# distributed under the License is distributed on an "AS IS" BASIS,
9# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
10# implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14from keystoneclient import base
15from keystoneclient.v3.contrib.oauth1 import utils
16
17
18class Consumer(base.Resource):
19    """Represents an OAuth consumer.
20
21    Attributes:
22        * id: a uuid that identifies the consumer
23        * description: a short description of the consumer
24    """
25
26    pass
27
28
29class ConsumerManager(base.CrudManager):
30    """Manager class for manipulating identity consumers."""
31
32    resource_class = Consumer
33    collection_key = 'consumers'
34    key = 'consumer'
35    base_url = utils.OAUTH_PATH
36
37    def create(self, description=None, **kwargs):
38        return super(ConsumerManager, self).create(
39            description=description,
40            **kwargs)
41
42    def get(self, consumer):
43        return super(ConsumerManager, self).get(
44            consumer_id=base.getid(consumer))
45
46    def update(self, consumer, description=None, **kwargs):
47        return super(ConsumerManager, self).update(
48            consumer_id=base.getid(consumer),
49            description=description,
50            **kwargs)
51
52    def delete(self, consumer):
53        return super(ConsumerManager, self).delete(
54            consumer_id=base.getid(consumer))
55