def _get_missing_permissions()

in dataflux_pytorch/_helper.py [0:0]


def _get_missing_permissions(storage_client: any, bucket_name: str,
                             project_name: str, required_perm: any):
    """Returns a list of missing permissions of the client from the required permissions list."""
    if not storage_client:
        storage_client = storage.Client(project=project_name)
    dataflux_core.user_agent.add_dataflux_user_agent(storage_client)
    bucket = storage_client.bucket(bucket_name)

    try:
        perm = bucket.test_iam_permissions(required_perm)
    except RefreshError as e:
        e.add_note(
            "Application Default credentials may be missing. Follow https://cloud.google.com/docs/authentication/provide-credentials-adc to set up Application Default Credentials.")
        raise

    return [p for p in required_perm if p not in perm]