<commit_before># vim: tabstop=4 shiftwidth=4 softtabstop=4

#
#    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.

"""
Client classes for callers of a heat system
"""

import errno
import httplib
import json
import logging
import os
import socket
import sys

import heat.api.v1
from heat.common import client as base_client
from heat.common import exception
from heat.common import utils

logger = logging.getLogger(__name__)
SUPPORTED_PARAMS = heat.api.v1.SUPPORTED_PARAMS


class V1Client(base_client.BaseClient):

    """Main client class for accessing heat resources"""

    DEFAULT_DOC_ROOT = "/v1"

    def _insert_common_parameters(self, params):
        params['Version'] = '2010-05-15'
        params['SignatureVersion'] = '2'
        params['SignatureMethod'] = 'HmacSHA256'

    def list_stacks(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)

        res = self.do_request("GET", "/ListStacks", params=params)
        data = json.loads(res.read())
        return data

    def describe_stacks(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)

        res = self.do_request("GET", "/DescribeStacks", params=params)
        data = json.loads(res.read())
        return data

    def create_stack(self, **kwargs):

        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)
        res = self.do_request("POST", "/CreateStack", params=params)

        data = json.loads(res.read())
        return data

    def update_stack(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)
        res = self.do_request("PUT", "/UpdateStack", params=params)

        data = json.loads(res.read())
        return data

    def delete_stack(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)
        self.do_request("DELETE", "/DeleteStack", params)
        return True

Client = V1Client


def get_client(host, port=None, username=None,
               password=<PASSWORD>, tenant=None,
               auth_url=None, auth_strategy=None,
               auth_token=None, region=None,
               is_silent_upload=False, insecure=False):
    """
    Returns a new client heat client object based on common kwargs.
    If an option isn't specified falls back to common environment variable<commit_msg>fix delete params (was treated as body)<commit_after># vim: tabstop=4 shiftwidth=4 softtabstop=4

#
#    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.

"""
Client classes for callers of a heat system
"""

import errno
import httplib
import json
import logging
import os
import socket
import sys

import heat.api.v1
from heat.common import client as base_client
from heat.common import exception
from heat.common import utils

logger = logging.getLogger(__name__)
SUPPORTED_PARAMS = heat.api.v1.SUPPORTED_PARAMS


class V1Client(base_client.BaseClient):

    """Main client class for accessing heat resources"""

    DEFAULT_DOC_ROOT = "/v1"

    def _insert_common_parameters(self, params):
        params['Version'] = '2010-05-15'
        params['SignatureVersion'] = '2'
        params['SignatureMethod'] = 'HmacSHA256'

    def list_stacks(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)

        res = self.do_request("GET", "/ListStacks", params=params)
        data = json.loads(res.read())
        return data

    def describe_stacks(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)

        res = self.do_request("GET", "/DescribeStacks", params=params)
        data = json.loads(res.read())
        return data

    def create_stack(self, **kwargs):

        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)
        res = self.do_request("POST", "/CreateStack", params=params)

        data = json.loads(res.read())
        return data

    def update_stack(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)
        res = self.do_request("PUT", "/UpdateStack", params=params)

        data = json.loads(res.read())
        return data

    def delete_stack(self, **kwargs):
        params = self._extract_params(kwargs, SUPPORTED_PARAMS)
        self._insert_common_parameters(params)
        self.do_request("DELETE", "/DeleteStack", params=params)
        return True

Client = V1Client


def get_client(host, port=None, username=None,
               password=<PASSWORD>, tenant=None,
               auth_url=None, auth_strategy=None,
               auth_token=None, region=None,
               is_silent_upload=False, insecure=False):
    """
    Returns a new client heat client object based on common kwargs.
    If an option isn't specified falls back to common environment variable
{'fraction_non_alphanumeric': 0.0945530951996121, 'fraction_numerical': 0.007758202683045095, 'mean_word_length': 3.3002084781097984, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4773350', 'n_tokens_mistral': 1777, 'n_tokens_neox': 1729, 'n_words': 511}