Example #1
0
 def __init__(self, connection=None, resource=None, **kwargs):
     super().__init__(connection=connection, **kwargs)
     if not self.RESOURCE_TYPE:
         raise PolyaxonConnectionError(
             "Aws connection requires a RESOURCE_TYPE")
     self._resource = resource
     self._encoding = kwargs.get("encoding", "utf-8")
     self._endpoint_url = (kwargs.get("endpoint_url")
                           or kwargs.get("aws_endpoint_url")
                           or kwargs.get("AWS_ENDPOINT_URL"))
     self._aws_access_key_id = (kwargs.get("access_key_id")
                                or kwargs.get("aws_access_key_id")
                                or kwargs.get("AWS_ACCESS_KEY_ID"))
     self._aws_secret_access_key = (kwargs.get("secret_access_key")
                                    or kwargs.get("aws_secret_access_key")
                                    or kwargs.get("AWS_SECRET_ACCESS_KEY"))
     self._aws_session_token = (kwargs.get("session_token")
                                or kwargs.get("aws_session_token")
                                or kwargs.get("AWS_SECURITY_TOKEN"))
     self._region_name = (kwargs.get("region") or kwargs.get("aws_region")
                          or kwargs.get("AWS_REGION"))
     self._aws_verify_ssl = kwargs.get(
         "verify_ssl",
         kwargs.get("aws_verify_ssl", kwargs.get("AWS_VERIFY_SSL", None)),
     )
     self._aws_use_ssl = (kwargs.get("use_ssl") or kwargs.get("aws_use_ssl")
                          or kwargs.get("AWS_USE_SSL"))
     self._aws_legacy_api = (kwargs.get("legacy_api")
                             or kwargs.get("aws_legacy_api")
                             or kwargs.get("AWS_LEGACY_API"))
Example #2
0
def get_blob_service_connection(
    account_name=None,
    account_key=None,
    connection_string=None,
    context_path: Optional[str] = None,
):
    account_name = account_name or get_account_name(context_path=context_path)
    account_key = account_key or get_account_key(context_path=context_path)
    connection_string = connection_string or get_connection_string(
        context_path=context_path
    )
    if connection_string:
        return BlobServiceClient.from_connection_string(
            conn_str=connection_string,
            credential=account_key,
        )
    if account_name:
        return BlobServiceClient(
            account_url="https://{account}.blob.core.windows.net".format(
                account=account_name
            ),
            credential=account_key,
        )
    raise PolyaxonConnectionError(
        "Azure blob service connection requires an account name or a connection string"
    )