# Path: python/boto/glacier/exceptions.py
# class UnexpectedHTTPResponseError(Exception):
#     def __init__(self, expected_responses, response):
#         self.status = response.status
#         self.body = response.read()
#         self.code = None
#         try:
#             body = json.loads(self.body)
#             self.code = body["code"]
#             msg = 'Expected %s, got ' % expected_responses
#             msg += '(%d, code=%s, message=%s)' % (response.status,
#                                                   self.code,
#                                                   body["message"])
#         except Exception:
#             msg = 'Expected %s, got (%d, %s)' % (expected_responses,
#                                                  response.status,
#                                                  self.body)
#         super(UnexpectedHTTPResponseError, self).__init__(msg)
# 
# Path: python/boto/glacier/response.py
# class GlacierResponse(dict):
#     """
#     Represents a response from Glacier layer1. It acts as a dictionary
#     containing the combined keys received via JSON in the body (if
#     supplied) and headers.
#     """
#     def __init__(self, http_response, response_headers):
#         self.http_response = http_response
#         self.status = http_response.status
#         self[u'RequestId'] = http_response.getheader('x-amzn-requestid')
#         if response_headers:
#             for header_name, item_name in response_headers:
#                 self[item_name] = http_response.getheader(header_name)
#         if http_response.getheader('Content-Type') == 'application/json':
#             body = json.loads(http_response.read())
#             self.update(body)
#         size = http_response.getheader('Content-Length', None)
#         if size is not None:
#             self.size = size
#         
#     def read(self, amt=None):
#         "Reads and returns the response body, or up to the next amt bytes."
#         return self.http_response.read(amt)


import os
import json
import urllib
import boto.glacier
from boto.connection import AWSAuthConnection
from .exceptions import UnexpectedHTTPResponseError
from .response import GlacierResponse
            for reg in boto.glacier.regions():
                if reg.name == region_name:
                    region = reg
                    break

        self.region = region
        self.account_id = account_id
        AWSAuthConnection.__init__(self, region.endpoint,
                                   aws_access_key_id, aws_secret_access_key,
                                   True, port, proxy, proxy_port,
                                   proxy_user, proxy_pass, debug,
                                   https_connection_factory,
                                   path, provider, security_token,
                                   suppress_consec_slashes)

    def _required_auth_capability(self):
        return ['hmac-v4']

    def make_request(self, verb, resource, headers=None,
                     data='', ok_responses=(200,), params=None,
                     response_headers=None):
        if headers is None:
            headers = {}
        headers['x-amz-glacier-version'] = self.Version
        uri = '/%s/%s' % (self.account_id, resource)
        response = AWSAuthConnection.make_request(self, verb, uri,
                                                  params=params,
                                                  headers=headers,
                                                  data=data)
        if response.status in ok_responses:

# Path: python/boto/glacier/exceptions.py
# class UnexpectedHTTPResponseError(Exception):
#     def __init__(self, expected_responses, response):
#         self.status = response.status
#         self.body = response.read()
#         self.code = None
#         try:
#             body = json.loads(self.body)
#             self.code = body["code"]
#             msg = 'Expected %s, got ' % expected_responses
#             msg += '(%d, code=%s, message=%s)' % (response.status,
#                                                   self.code,
#                                                   body["message"])
#         except Exception:
#             msg = 'Expected %s, got (%d, %s)' % (expected_responses,
#                                                  response.status,
#                                                  self.body)
#         super(UnexpectedHTTPResponseError, self).__init__(msg)
# 
# Path: python/boto/glacier/response.py
# class GlacierResponse(dict):
#     """
#     Represents a response from Glacier layer1. It acts as a dictionary
#     containing the combined keys received via JSON in the body (if
#     supplied) and headers.
#     """
#     def __init__(self, http_response, response_headers):
#         self.http_response = http_response
#         self.status = http_response.status
#         self[u'RequestId'] = http_response.getheader('x-amzn-requestid')
#         if response_headers:
#             for header_name, item_name in response_headers:
#                 self[item_name] = http_response.getheader(header_name)
#         if http_response.getheader('Content-Type') == 'application/json':
#             body = json.loads(http_response.read())
#             self.update(body)
#         size = http_response.getheader('Content-Length', None)
#         if size is not None:
#             self.size = size
#         
#     def read(self, amt=None):
#         "Reads and returns the response body, or up to the next amt bytes."
#         return self.http_response.read(amt)


# Path: python/boto/glacier/layer1.py
import os
import json
import urllib
import boto.glacier
from boto.connection import AWSAuthConnection
from .exceptions import UnexpectedHTTPResponseError
from .response import GlacierResponse

            for reg in boto.glacier.regions():
                if reg.name == region_name:
                    region = reg
                    break

        self.region = region
        self.account_id = account_id
        AWSAuthConnection.__init__(self, region.endpoint,
                                   aws_access_key_id, aws_secret_access_key,
                                   True, port, proxy, proxy_port,
                                   proxy_user, proxy_pass, debug,
                                   https_connection_factory,
                                   path, provider, security_token,
                                   suppress_consec_slashes)

    def _required_auth_capability(self):
        return ['hmac-v4']

    def make_request(self, verb, resource, headers=None,
                     data='', ok_responses=(200,), params=None,
                     response_headers=None):
        if headers is None:
            headers = {}
        headers['x-amz-glacier-version'] = self.Version
        uri = '/%s/%s' % (self.account_id, resource)
        response = AWSAuthConnection.make_request(self, verb, uri,
                                                  params=params,
                                                  headers=headers,
                                                  data=data)
        if response.status in ok_responses:

            return GlacierResponse(response, response_headers)