Ejemplo n.º 1
0
class Client:
    compute_host: str = "compute.googleapis.com"
    cloud_resource_manager_host: str = "cloudresourcemanager.googleapis.com"
    port: int = 443
    scheme: str = "https"
    api_base: str = ""

    def __post_init__(self):
        self.cloud_resource_manager_client = AsyncHTTPClient(
            host=self.cloud_resource_manager_host,
            port=self.port,
            scheme=self.scheme,
            api_base=self.api_base)
        self.compute_client = AsyncHTTPClient(host=self.compute_host,
                                              port=self.port,
                                              scheme=self.scheme,
                                              api_base=self.api_base)
        self.projects = Projects(
            resource_manager_client=self.cloud_resource_manager_client,
            compute_client=self.compute_client,
        )
        self.instances = Instances(self.compute_client)

    def set_auth_token(self, token: object):
        token = str(token)
        self.cloud_resource_manager_client.set_auth_token(token)
        self.compute_client.set_auth_token(token)
Ejemplo n.º 2
0
class Client:
    host: str = "management.azure.com"
    port: int = 443
    scheme: str = "https"
    api_base: str = ""

    def __post_init__(self):
        self.client = AsyncHTTPClient(host=self.host,
                                      port=self.port,
                                      scheme=self.scheme,
                                      api_base=self.api_base)
        self.subscriptions = Subscriptions(self.client)
        self.vms = Vms(self.client)

    def set_auth_token(self, token: object):
        self.client.set_auth_token(str(token))