示例#1
0
def _set_encryption_headers(key, headers):
    """Builds customer encyrption key headers

    :type key: str or bytes
    :param key: 32 byte key to build request key and hash.

    :type headers: dict
    :param headers: dict of HTTP headers being sent in request.
    """
    key = _to_bytes(key)
    sha256_key = hashlib.sha256(key).digest()
    key_hash = base64.b64encode(sha256_key).rstrip()
    encoded_key = base64.b64encode(key).rstrip()
    headers['X-Goog-Encryption-Algorithm'] = 'AES256'
    headers['X-Goog-Encryption-Key'] = _bytes_to_unicode(encoded_key)
    headers['X-Goog-Encryption-Key-Sha256'] = _bytes_to_unicode(key_hash)
示例#2
0
def _set_encryption_headers(key, headers):
    """Builds customer encyrption key headers

    :type key: str or bytes
    :param key: 32 byte key to build request key and hash.

    :type headers: dict
    :param headers: dict of HTTP headers being sent in request.
    """
    key = _to_bytes(key)
    sha256_key = hashlib.sha256(key).digest()
    key_hash = base64.b64encode(sha256_key).rstrip()
    encoded_key = base64.b64encode(key).rstrip()
    headers['X-Goog-Encryption-Algorithm'] = 'AES256'
    headers['X-Goog-Encryption-Key'] = _bytes_to_unicode(encoded_key)
    headers['X-Goog-Encryption-Key-Sha256'] = _bytes_to_unicode(key_hash)
def _flatten_cells(prd):
    # Match results format from JSON testcases.
    # Doesn't handle error cases.
    from gcloud._helpers import _bytes_to_unicode
    from gcloud._helpers import _microseconds_from_datetime
    for row_key, row in prd.rows.items():
        for family_name, family in row.cells.items():
            for qualifier, column in family.items():
                for cell in column:
                    yield {
                        u'rk': _bytes_to_unicode(row_key),
                        u'fm': family_name,
                        u'qual': _bytes_to_unicode(qualifier),
                        u'ts': _microseconds_from_datetime(cell.timestamp),
                        u'value': _bytes_to_unicode(cell.value),
                        u'label': u' '.join(cell.labels),
                        u'error': False,
                    }
示例#4
0
    def __init__(self, image_source, client):
        self.client = client
        self._content = None
        self._source = None

        if _bytes_to_unicode(image_source).startswith('gs://'):
            self._source = image_source
        else:
            self._content = b64encode(_to_bytes(image_source))
示例#5
0
def _flatten_cells(prd):
    # Match results format from JSON testcases.
    # Doesn't handle error cases.
    from gcloud._helpers import _bytes_to_unicode
    from gcloud._helpers import _microseconds_from_datetime
    for row_key, row in prd.rows.items():
        for family_name, family in row.cells.items():
            for qualifier, column in family.items():
                for cell in column:
                    yield {
                        u'rk': _bytes_to_unicode(row_key),
                        u'fm': family_name,
                        u'qual': _bytes_to_unicode(qualifier),
                        u'ts': _microseconds_from_datetime(cell.timestamp),
                        u'value': _bytes_to_unicode(cell.value),
                        u'label': u' '.join(cell.labels),
                        u'error': False,
                    }
示例#6
0
 def _callFUT(self, *args, **kwargs):
     from gcloud._helpers import _bytes_to_unicode
     return _bytes_to_unicode(*args, **kwargs)
示例#7
0
 def _callFUT(self, *args, **kwargs):
     from gcloud._helpers import _bytes_to_unicode
     return _bytes_to_unicode(*args, **kwargs)