Test Failed
Push — master ( e380d0...f5671d )
by W
02:58
created

st2api/controllers/v1/pack_config_schemas.py (1 issue)

1
# Licensed to the StackStorm, Inc ('StackStorm') under one or more
2
# contributor license agreements.  See the NOTICE file distributed with
3
# this work for additional information regarding copyright ownership.
4
# The ASF licenses this file to You under the Apache License, Version 2.0
5
# (the "License"); you may not use this file except in compliance with
6
# the License.  You may obtain 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,
12
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
# See the License for the specific language governing permissions and
14
# limitations under the License.
15
16
import six
17
18
from st2api.controllers.resource import ResourceController
19
from st2api.controllers.v1.packs import packs_controller
20
from st2common.services import packs as packs_service
21
from st2common.models.api.pack import ConfigSchemaAPI
22
from st2common.persistence.pack import ConfigSchema
23
24
http_client = six.moves.http_client
25
26
__all__ = [
27
    'PackConfigSchemasController'
28
]
29
30
31
class PackConfigSchemasController(ResourceController):
32
    model = ConfigSchemaAPI
33
    access = ConfigSchema
34
    supported_filters = {}
35
36
    def __init__(self):
37
        super(PackConfigSchemasController, self).__init__()
38
39
        # Note: This method is used to retrieve object for RBAC purposes and in
40
        # this case, RBAC is checked on the parent PackDB object
41
        self.get_one_db_method = packs_service.get_pack_by_ref
42
43
    def get_all(self, sort=None, offset=0, limit=None, requester_user=None, **raw_filters):
44
        """
45
        Retrieve config schema for all the packs.
46
47
        Handles requests:
48
            GET /config_schema/
49
        """
50
51
        return super(PackConfigSchemasController, self)._get_all(sort=sort,
52
                                                                 offset=offset,
53
                                                                 limit=limit,
54
                                                                 raw_filters=raw_filters,
55
                                                                 requester_user=requester_user)
56
57
    def get_one(self, pack_ref, requester_user):
58
        """
59
        Retrieve config schema for a particular pack.
60
61
        Handles requests:
62
            GET /config_schema/<pack_ref>
63
        """
64
        packs_controller._get_one_by_ref_or_id(ref_or_id=pack_ref, requester_user=requester_user)
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like _get_one_by_ref_or_id was declared protected and should not be accessed from this context.

Prefixing a member variable _ is usually regarded as the equivalent of declaring it with protected visibility that exists in other languages. Consequentially, such a member should only be accessed from the same class or a child class:

class MyParent:
    def __init__(self):
        self._x = 1;
        self.y = 2;

class MyChild(MyParent):
    def some_method(self):
        return self._x    # Ok, since accessed from a child class

class AnotherClass:
    def some_method(self, instance_of_my_child):
        return instance_of_my_child._x   # Would be flagged as AnotherClass is not
                                         # a child class of MyParent
Loading history...
65
66
        return self._get_one_by_pack_ref(pack_ref=pack_ref)
67
68
69
pack_config_schema_controller = PackConfigSchemasController()
70