Skip to content

Commit

Permalink
Prefer access_credentials_name in File API. (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
thetorpedodog authored May 22, 2023
1 parent f80fb75 commit a7bd322
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/tiledb/cloud/file.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import warnings
from typing import Optional, Tuple, Union

import tiledb
Expand All @@ -14,6 +15,7 @@ def create_file(
input_uri: str,
output_uri: str,
name: Optional[str] = None,
access_credentials_name: Optional[str] = None,
access_credential_name: Optional[str] = None,
async_req: bool = False,
) -> models.FileCreated:
Expand All @@ -23,10 +25,26 @@ def create_file(
:param name: name to use for registration in TileDB Cloud
:param input_uri: input file uri
:param output_uri: output array uri
:param access_credential_name: optional access credentials to use
:param access_credential_name:
DEPRECATED. Use ``access_credential_name`` instead.
:param access_credentials_name: optional access credentials to use
:param async_req: return future instead of results for async support
:return: FileCreated details, including file_uuid and output_uri
"""
if access_credential_name is not None:
if access_credentials_name is not None:
raise ValueError(
"pass only access_credentials_name (plural);"
" do not set access_credential_name (singular)"
)
warnings.warn(
DeprecationWarning(
"access_credential_name (singular) is deprecated;"
" use access_credentials_name (plural)"
)
)
access_credentials_name = access_credential_name
del access_credential_name # Make certain we don't use this later.
try:
api_instance = client.build(rest_api.FilesApi)

Expand All @@ -37,8 +55,8 @@ def create_file(
)

kwargs = {}
if access_credential_name is not None:
kwargs["x_tiledb_cloud_access_credentials_name"] = access_credential_name
if access_credentials_name is not None:
kwargs["x_tiledb_cloud_access_credentials_name"] = access_credentials_name

return api_instance.handle_create_file(
namespace, file_create, async_req=async_req, **kwargs
Expand Down

0 comments on commit a7bd322

Please sign in to comment.