00000046
  6   ˆl–ßi~”Ji?u8 �q§®*bÑ¿�þB g#‘ É#¬·üÿÂƒh¹ÁÀ¿      1
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Ã638_‘I|¥‰ÓMdœv ©ƒ†ü+=ÃÂ ~    ‹      Õ–QOÛ0ÇßùžöÖ^Òv Jê‰5H«¥‚NÓ4MÈ�ÝÄ"‰#Ûmè>ýœ:Ð2Ñ-Ó€ÁÓ��¿}÷s|¶ƒ7áùpúur‚>NÏNÑäó‡ÓÑáÀ—î œ†îC¯íù 'cŒpbLÑ(Ë²]vÛRÅ0½€Ädi´Q"2mf&{AÕGöP�pÊ¬E�&åd”3~ƒä�\-·ãV_ŠˆëÊ7<ƒŒgR­jsØ�\2îAT,ºÀ”XrUù^ nNê0ÁL²UÝäHvÂ5�­V®"�IÐ’¦"ÎØÈ“@d1Ò*`‘Ì5ÌRš_·c1Çˆ¦f€¿�†çß­LR�&E‰âó~?Œ�Î!&cšñ èÃš3«9Æä”jƒ2ÉÄ\p¶S|éÄ—âÇî	C§	¹Ž”(Œ�ùF
q5’©.¨e}g	µ­rö§Õ Ñ½Å˜_œŒ§áèÂ-	«¦Ød÷�ÿ“	U<7(ŠGÆÊj2æm>ÓÅÑmÕy+'„ZèAå_ÀÎeÊ¸ÚÆÝÑ(á6_g·³ü%­Ž×Ùoù~Ë?DþAß;@è	ó_ä×¹,óm »PT'W¹4\[ŠM£J§ƒ<¯ßñv¢Ø³çÓÿA¹Ò¶pîñ¬{^
TóýuWµÓ„ ‡|¯ßÝÒÖœ`.TVÚj¾ªÊÜ‚Üo7ä9è÷vÿ‘çåI¤)ÒElIn½ÇØUÏËàN\Lœm~j½”=UÈr]Î6Y¯Zïð…ä¯³ú.Ädã¿¾Ú¶ãe*ã•Å¸s_á¸àKûØÀÄÙÇ(‡ß_ßeP¿XX¿ŒpïòŸÅõŒÖú    7   ˆl–ßi~”Ji?u8 �q§®2ò˜´o‘äÇò 8àA�ÆàÆàÿŸÆƒh¹ÅÄÃ      1
  5   	ˆl–ß=¿Jõ4Ÿº‚ œP.\·˜´o�þB g Ùm–D7óÇƒh¹ÆÅÄ      	1
     ˆÂÁÆ634ÀÅÄ z    ‹      ÕVÑnÚ0}ïWx~ØÜ„²²Òà©#HCk)j™¦iš&â5‰#ÛiÆ¾~7„ª´‚�J´j_âçØ÷_ÇÁ›ð¢?ù6�O“ó32þòñlØ'´ðõ°NÂúC»éù ƒ%4v.ï”eÙ,›ÚÌar	±K“6XgTäšÂ	Ê‚ª�� –\`K§\"Ù0ò7Ñ3ºpV	‰ã¦……(/@u#�…ÜèHZ«MÕÛ‚LéU¡·BTqfÊ¤%7ògõ=€:æ„UÒ`ªÅ¢ââ?i^œ~)�O—é«Ð°ÀÅä†'jžõ¨Ó9e�JçÄš¨GAE:ÃÜ	Ï®›s5£„'®G¿û?.®F³€“ØÈY�~è÷F'½�²O1ßŒ9GÌ)egÜ:’j¡fJŠ­à«|¥þlŸ0¬1¡´‘Q¹S:»ƒJ\—éÄæµ¾C±YGÕñ¿ÕàÑ½ÅŸ^F“pxY/‰¨¦¸c·�*R6ÆfŽ„ÊÈÈi³XÉ«s½Í¦6?¹}%+òFÍcG!²ùÅEv�é2[�ºQ®ü…)[6ë$°jy­£†ï7ZmÒò»í÷„l¢¡??#ýXá‘€�WH�„SqKÙm´³ˆÃã—""ç.¦¬zîHÞë¶�ž”üL'BšuîÛœžÇ«"ž,ÏZôìý÷ôøÇÄït½ízöáåGèÑ%@¨cÙîîˆÎ“òÄf²Ž»ýP·/ÅÒ»ÀSüg8™bîâ×·‘\,MŠ>ˆ´NT6G5{öaögÞ\…¼Á?2eu»�¢ü{síxƒ�ÕÝ.€å�2€úvû×¸>+@    C   ˆl–Ðz¾”Šj"Tâ‚À½q¶”Å£�þ[}Á,ãe#qº•à?È„žx_Ç_ŠI|¥�+Wé3ž¯ÇÆ ?÷     # Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You 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.
"""
Scaleway Driver
"""

import copy

from libcloud.utils.py3 import httplib
from libcloud.common.base import JsonResponse, ConnectionUserAndKey
from libcloud.common.types import ProviderError
from libcloud.compute.base import (
    Node,
    KeyPair,
    NodeSize,
    NodeImage,
    NodeDriver,
    NodeLocation,
    StorageVolume,
    VolumeSnapshot,
)
from libcloud.compute.types import NodeState, VolumeSnapshotState
from libcloud.utils.iso8601 import parse_date
from libcloud.compute.providers import Provider

try:
    import simplejson as json
except ImportError:
    import json


__all__ = ["ScalewayResponse", "ScalewayConnection", "ScalewayNodeDriver"]

SCALEWAY_API_HOSTS = {
    "default": "cp-par1.scaleway.com",
    "account": "account.scaleway.com",
    "par1": "cp-par1.scaleway.com",
    "ams1": "cp-ams1.scaleway.com",
}

# The API doesn't give location info, so we provide it ourselves, instead.
SCALEWAY_LOCATION_DATA = [
    {"id": "par1", "name": "Paris 1", "country": "FR"},
    {"id": "ams1", "name": "Amsterdam 1", "country": "NL"},
]


class ScalewayResponse(JsonResponse):
    valid_response_codes = [
        httplib.OK,
        httplib.ACCEPTED,
        httplib.CREATED,
        httplib.NO_CONTENT,
    ]

    def parse_error(self):
        return super().parse_error()["message"]

    def success(self):
        return self.status in self.valid_response_codes


class ScalewayConnection(ConnectionUserAndKey):
    """
    Connection class for the Scaleway driver.
    """

    host = SCALEWAY_API_HOSTS["default"]
    allow_insecure = False
    responseCls = ScalewayResponse

    def request(
     