1# Licensed under the Apache License, Version 2.0 (the "License"); you may 2# not use this file except in compliance with the License. You may obtain 3# 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, WITHOUT 9# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 10# License for the specific language governing permissions and limitations 11# under the License. 12 13from openstack import resource 14 15 16class Policy(resource.Resource): 17 resource_key = 'policy' 18 resources_key = 'policies' 19 base_path = '/policies' 20 21 # Capabilities 22 allow_list = True 23 allow_fetch = True 24 allow_create = True 25 allow_delete = True 26 allow_commit = True 27 28 commit_method = 'PATCH' 29 30 _query_mapping = resource.QueryParameters( 31 'name', 'type', 'sort', 'global_project') 32 33 # Properties 34 #: The name of the policy. 35 name = resource.Body('name') 36 #: The type name of the policy. 37 type = resource.Body('type') 38 #: The ID of the project this policy belongs to. 39 project_id = resource.Body('project') 40 # The domain ID of the policy. 41 domain_id = resource.Body('domain') 42 #: The ID of the user who created this policy. 43 user_id = resource.Body('user') 44 #: The timestamp when the policy is created. 45 created_at = resource.Body('created_at') 46 #: The timestamp when the policy was last updated. 47 updated_at = resource.Body('updated_at') 48 #: The specification of the policy. 49 spec = resource.Body('spec', type=dict) 50 #: A dictionary containing runtime data of the policy. 51 data = resource.Body('data', type=dict) 52 53 54class PolicyValidate(Policy): 55 base_path = '/policies/validate' 56 57 # Capabilities 58 allow_list = False 59 allow_fetch = False 60 allow_create = True 61 allow_delete = False 62 allow_commit = False 63 64 commit_method = 'PUT' 65