create_batch

imerit_ango.sdk.SDK.

create_batch(project_id, batch_name)

Create batches in a specific project.

Parameters

  • project_id: str

  • batch_name: str

    • Name of the batch to be created.

    • Example: 'My Batch 1'

Returns:

  • output: dict

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