Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Veeva Vault Objects example #56

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

fivetran-kirkvanarkel
Copy link
Collaborator

No description provided.

Copy link

height bot commented Nov 25, 2024

Link Height tasks by mentioning a task ID in the pull request title or commit messages, or description and comments with the keyword link (e.g. "Link T-123").

💡Tip: You can also use "Close T-X" to automatically close a task when the pull request is merged.

README.md Outdated
@@ -114,6 +114,10 @@ Refer to the Multithreading Guidelines in api_threading_utils.py
This is an example of how we can sync Smartsheets sheets via Connector SDK.
You would need to provide your Smartsheets api_key for this example to work.

### veeva vault objects
This is an example of how we can sync Veeva Vault Object data using VQL via Connector SDK.
You would need to provide your Veeva Vault vaultDNS, username, and password for this example to work.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You would need to provide your Veeva Vault vaultDNS, username, and password for this example to work.
You would need to provide your Veeva Vault credentials for this example to work.

@@ -0,0 +1,171 @@
# This is a simple example for how to work with the fivetran_connector_sdk module.
# This code is currently configured to Retrieve Details from All Object Types in Veeva Vault and then utilize VQL to retrieve all Object records, creating 1 table per object
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# This code is currently configured to Retrieve Details from All Object Types in Veeva Vault and then utilize VQL to retrieve all Object records, creating 1 table per object
# This code is currently configured to Retrieve Details from All Object Types in Veeva Vault and then utilize VQL to retrieve all Object records, creating one table per object

@@ -0,0 +1,171 @@
# This is a simple example for how to work with the fivetran_connector_sdk module.
# This code is currently configured to Retrieve Details from All Object Types in Veeva Vault and then utilize VQL to retrieve all Object records, creating 1 table per object
# You will need to provide your own Veeva Vault credentials for this to work --> vaultDNS, username, and password variables in configuration.json
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# You will need to provide your own Veeva Vault credentials for this to work --> vaultDNS, username, and password variables in configuration.json
# You will need to provide your own Veeva Vault credentials for this to work --> subdomain, username, and password variables in configuration.json

# You will need to provide your own Veeva Vault credentials for this to work --> vaultDNS, username, and password variables in configuration.json
# Retrieve Details from All Object Types endpoint: https://developer.veevavault.com/api/24.2/#retrieve-details-from-all-object-types
# VQL endpoint: https://developer.veevavault.com/api/24.2/#vault-query-language-vql
# Can also add code to extract from other endpoints as needed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Can also add code to extract from other endpoints as needed
# You can also add code to extract from other endpoints as needed.

log.severe(f"Failed to create session for user with username: {username}")
session_id = None
else:
log.severe(f"Failed to get 200 response from Auth URL: {auth_url}, received response status code of {response.status_code}")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

polish this log statement, and also throw the response.message, so that error is visible

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work? "Authentication failed: {auth_url} returned {response.status_code}. Expected 200."

# The state dictionary is empty for the first sync or for any full re-sync
# This function is designed to loop through and retrieve vault Object data using VQL endpoint: https://developer.veevavault.com/api/24.2/#submitting-a-query
def update(configuration: dict, state: dict):
base_url = f"https://{configuration.get('vaultDNS')}/api/v24.2/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define this as a constant and then use that for all occurrences
you can keep some regex and then replace that while using in your code with config value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defined as a constant at the start of the code under #Constant

@varundhall
Copy link
Collaborator

@orizwanft please re-request the review in future, so we can get notified to review the PR again 😅

@varundhall varundhall self-requested a review December 11, 2024 17:45
Copy link
Collaborator

@varundhall varundhall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there 🙌🏻

def startVeevaSession(configuration: dict):
username = configuration.get('username')
password = configuration.get('password')
auth_url = f"https://{configuration.get('subdomain')}/api/v24.2/auth"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are calling the field as sub-domain but then taking the entire value in credentials as the URL

it should be
auth_url = f"https://{configuration.get('subdomain')}.veevavault.com/api/v24.2/auth"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

# - session_id: a Veeva Vault session ID generated from the startVeevaSession function

def endVeevaSession(configuration: dict, session_id):
deactivate_session_url = f"https://{configuration.get('subdomain')}/api/v24.2/session"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

# - session_id: a Veeva Vault session ID generated from the startVeevaSession function

def getVaultObjects(configuration: dict, session_id):
base_url = f"https://{configuration.get('subdomain')}/api/v24.2/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

def initialize_sync(configuration: dict, state: dict):

sub_domain = configuration.get('subdomain')
base_url = f"https://{sub_domain}/api/v24.2/"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@orizwanft orizwanft requested a review from varundhall January 7, 2025 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants