Data Share Functions
The Python Data Studio Application Programming Interface (API) for Data Share functions provides the syntax and descriptions of the classes, methods, attributes, and parameters of the application programming interface to the Data Share tool of Data Studio suite of tools.
Data Studio Data Share API functions
The Adp.Share
class is used for working with data shares. This class contains a set of data sharing functions that allows manage data shares, recipients etc.
Prerequisites
You must first create an ADP instance.
The functions have string return value and string parameters.
Create Share Procedure
This function creates Data Share based on object storage date and associate them with recipients.
Syntax
Share.create_share(name, objects, storage_link_name, publish_job_details, owner, type,
storage_link_owner, description)
- name: The name of the Data Share. This field is mandatory.
- objects: The Data Share objects dictionary consists of the following fields:
- [{"schemaName" : "schemaNameValue", "objects": [{"objectName": "objectNameValue", "objectOwner": "objectOwnerValue", "shareObjectName" : "shareObjectNameValue"}, ...]}, ...]
This field is mandatory.
- storage_link_name: This field displays the Data Share cloud storage link name.
- publish_job_details: This field displays the Data Share publish job details dictionary. If this field is missing {
"enabled": False
} is used. - owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
- type: The type of the Data Share. If this field is missing, the tool uses the
VERSIONED
field. - storage_link_owner: The Data Share Cloud Storage link owner. If this field is missing, the tool uses the current schema owner.
- description: This field displays the data share description. If this field is missing, the tool uses an empty string.
name = 'share_py_api_7'
desc = 'desc_share_py_api_7'
link = '"food_cred"'
share_objects = json.dumps([{"schemaName" : "ADMIN",
"objects" : [{"objectName" : "IRIS",
"objectOwner" : "ADMIN",
"shareObjectName" : "IRIS_SHARE"},
{"objectName" : "DEMO_FOOD_SAMPLE",
"objectOwner" : "ADMIN",
"shareObjectName" : "DEMO_FOOD_SAMPLE_SHARE"}
]}])
job = json.dumps({"enabled" : False})
adp.Share.create_share(
name = name,
description = desc,
storage_link_name = link,
objects = share_objects,
publish_job_details = job)
//Output:
{"createdShare":true,"notifyRecipients":false,"shareId":40295,"sharetablename_":"DEMO_FOOD_SAMPLE_SHARE"}
Update Data Share Objects Procedure
This function updates the Data Share objects.
Syntax
Share.update_share_objects(name, objects, publish_job_details, owner,
description)
- name: The name of the Data Share. This field is mandatory.
- objects: The Data Share objects dictionary consists of the following fields:
- [{"schemaName" : "schemaNameValue", "objects": [{"objectName": "objectNameValue", "objectOwner": "objectOwnerValue", "shareObjectName" : "shareObjectNameValue"}, ...]}, ...]
This field is mandatory.
- publish_job_details: This field displays the Data Share publish job details dictionary. If this field is missing {
"enabled": False
} is used. - owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
- description: This field displays the data share description. If this field is missing, the tool uses an empty string.
name = 'share_py_api_7'
objects = json.dumps([{"schemaName" : "ADMIN",
"objects" : [{"objectName" : "WINE",
"objectOwner" : "ADMIN",
"shareObjectName" : "WINE_SHARE"}
]}])
adp.Share.update_share_objects(name = name, objects = objects)
//Output:
'{"sharetablename_":"WINE_SHARE"}'
Delete Data Share Procedure
This function deletes the Data Share.
Syntax
Share.delete_share(name, owner)
- name: The name of the Data Share. This field is mandatory.
- owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
adp.Share.delete_share('share_py_api_7_1')
//Output:
'{"deletedShare":true}'
Rename Data Share Procedure
This function renames the Data Share.
Syntax
Share.rename_share(name, new_name, owner)
- name: The name of the Data Share. This field is mandatory.
- new_name: The new name you want for the Data Share. This field is mandatory.
- owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
adp.Share.rename_share (name = 'share_py_api_7', new_name = 'share_py_api_7_1')
'{ "status": true }'
Publish Data Share Procedure
This function publishes Data Share.
Syntax
Share.publish_share(name, owner)
- name: The name of the Data Share. This field is mandatory.
- owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
adp.Share.publish_share(name='share_py_api_7_1')
//Output:
'{"publishShare":true}'
Unpublish Data Share
This function publishes Data Share.
Syntax
Share.unpublish_share(name, owner)
- name: The name of the Data Share. This field is mandatory.
- owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
adp.Share.unpublish_share(name ='share_py_api_7_1')
//Output:
'{"unpublishShare":true}'
Get Share Procedure
This function receives Data Share details.
Syntax
Share.get_share(name, owner)
- name: The name of the Data Share. This field is mandatory.
- owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
s = adp.Share.get_share(name = 'share_py_api_7_1')
json.loads(s)
//Output:
{'id': 40415,
'name': 'SHARE_PY_API_7_1',
'owner': 'ADMIN',
'description': 'desc_share_py_api_7',
'publicDescription': 'desc_share_py_api_7',
'type': 'VERSIONED',
'version': None,
'tablesCount': 3,
'recipientsCount': 0,
'lastExportTime': None,
'objects': [{'id': 40416,
'schemaName': 'ADMIN',
'objects': [{'id': 40435,
'shareObjectName': 'WINE_SHARE',
'objectName': 'WINE',
'objectOwner': 'ADMIN',
'objectType': 'TABLE'},
{'id': 40417,
'shareObjectName': 'IRIS_SHARE',
'objectName': 'IRIS',
'objectOwner': 'ADMIN',
'objectType': 'TABLE'},
{'id': 40418,
'shareObjectName': 'DEMO_FOOD_SAMPLE_SHARE',
'objectName': 'DEMO_FOOD_SAMPLE',
'objectOwner': 'ADMIN',
'objectType': 'TABLE'}]}],
'recipients': None,
'storageLinkName': 'food_cred',
'schedule': {'enabled': 'FALSE',
'startDate': None,
'endDate': None,
'repeatInterval': None}}
Get Shares Procedure
This function receives Data Share list based on the owner of the Data Share.
Syntax
Share.get_shares(owner)
- owner: This field displays the data share owner. If this field is missing, the tool uses the current schema owner.
s = adp.Share.get_shares()
json.loads(s)
//Output:
[{'id': 40415,
'name': 'SHARE_PY_API_7_1',
'owner': 'ADMIN',
'description': 'desc_share_py_api_7',
'type': 'VERSIONED',
'tablesCount': 3,
'version': None}]