<commit_before># Copyright 2012 New Dream Network, LLC (DreamHost)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DreamHost Qauntum Extensions
# @author: <NAME>, New Dream Network, LLC (DreamHost)
# @author: <NAME>, New Dream Network, LLC (DreamHost)

from quantum.api.v2 import attributes
from quantum.db import models_v2
from quantum.extensions import extensions

from quantum.extensions import _authzbase


class PortforwardResource(_authzbase.ResourceDelegate):
    """
    This class is responsible for receiving REST requests and operating on the
    defined data model to create, update, or delete portforward-related data.
    """
    model = models_v2.PortForward
    resource_name = 'portforward'
    collection_name = 'portforwards'

    ATTRIBUTE_MAP = {
        'id': {'allow_post': False, 'allow_put': False,
               'validate': {'type:regex': attributes.UUID_PATTERN},
               'is_visible': True},
        'name': {'allow_post': True, 'allow_put': True,
                 'default': '', 'is_visible': True},
        'tenant_id': {'allow_post': True, 'allow_put': False,
                      'required_by_policy': True,
                      'is_visible': True},
        'instance_id': {'allow_post': True, 'allow_put': False,
                        'required_by_policy': True,
                        'is_visible': True},
        'private_port': {'allow_post': True, 'allow_put': False,
                         'required_by_policy': True,
                         'is_visible': True},
        'fixed_id': {'allow_post': True, 'allow_put': False,
                     'required_by_policy': True,
                     'is_visible': True},
        'op_status': {'allow_post': True, 'allow_put': False,
                      'required_by_policy': True,
                      'is_visible': True}
    }

    def make_dict(self, portforward):
        """
        Convert a portforward model object to a dictionary.
        """
        res = {'id': portforward['id'],
               'name': portforward['name'],
               'instance_id': portforward['instance_id'],
               'private_port': portforward['private_port'],
               'fixed_id': portforward['fixed_id'],
               'op_status': portforward['op_status']}
        return res<commit_msg>Added missing public_port to ATTRIBUTE_MAP in portforward.py<commit_after># Copyright 2012 New Dream Network, LLC (DreamHost)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# DreamHost Qauntum Extensions
# @author: <NAME>, New Dream Network, LLC (DreamHost)
# @author: <NAME>, New Dream Network, LLC (DreamHost)

from quantum.api.v2 import attributes
from quantum.db import models_v2
from quantum.extensions import extensions

from quantum.extensions import _authzbase


class PortforwardResource(_authzbase.ResourceDelegate):
    """
    This class is responsible for receiving REST requests and operating on the
    defined data model to create, update, or delete portforward-related data.
    """
    model = models_v2.PortForward
    resource_name = 'portforward'
    collection_name = 'portforwards'

    ATTRIBUTE_MAP = {
        'id': {'allow_post': False, 'allow_put': False,
               'validate': {'type:regex': attributes.UUID_PATTERN},
               'is_visible': True},
        'name': {'allow_post': True, 'allow_put': True,
                 'default': '', 'is_visible': True},
        'tenant_id': {'allow_post': True, 'allow_put': False,
                      'required_by_policy': True,
                      'is_visible': True},
        'instance_id': {'allow_post': True, 'allow_put': False,
                        'required_by_policy': True,
                        'is_visible': True},
        'public_port': {'allow_post': True, 'allow_put': False,
                        'required_by_policy': True,
                        'is_visible': True},
        'private_port': {'allow_post': True, 'allow_put': False,
                         'required_by_policy': True,
                         'is_visible': True},
        'fixed_id': {'allow_post': True, 'allow_put': False,
                     'required_by_policy': True,
                     'is_visible': True},
        'op_status': {'allow_post': True, 'allow_put': False,
                      'required_by_policy': True,
                      'is_visible': True}
    }

    def make_dict(self, portforward):
        """
        Convert a portforward model object to a dictionary.
        """
        res = {'id': portforward['id'],
               'name': portforward['name'],
               'instance_id': portforward['instance_id'],
               'private_port': portforward['private_port'],
               'fixed_id': portforward['fixed_id'],
               'op_status': portforward['op_status']}
        return res
{'fraction_non_alphanumeric': 0.11080428028995512, 'fraction_numerical': 0.0037970314118053157, 'mean_word_length': 2.527084601339014, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4305908', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1525, 'n_words': 492}