create_batch
imerit_ango.sdk.SDK.
create_batch(project_id, batch_name)
Create a new batch within the specified project.
Parameters
project_id: str
The unique identifier for the project. You can find the project ID in the user interface or retrieve it using the
list_projects
function.
batch_name: str
Name of the batch to be created.
Example:
'My Batch 1'
Returns:
output: dict
A dictionary containing the result of the operation.
Example
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')
ango_sdk = SDK(api_key)
ango_sdk.create_batch(project_id, "My Batch Name")
Prevent creating duplicate batches:
import os
from dotenv import load_dotenv
from imerit_ango.sdk import SDK
load_dotenv('variables.env')
api_key = os.getenv('API_KEY')
project_id = os.getenv('PROJECT_ID')
ango_sdk = SDK(api_key)
batch_name = "My Batch"
# Get available batch names from project
batch_response = ango_sdk.get_batches(project_id)
project_batch_name_list = []
for index in range(len(batch_response)):
project_batch_name = batch_response[index]['name']
project_batch_name_list.append(project_batch_name)
# Create batch if it is not available on the project
if batch_name not in project_batch_name_list:
ango_sdk.create_batch(project_id=project_id, batch_name=batch_name)
Last updated