Target

The target domain provides access to target queries, mutations, and subscriptions.

Use target to create, retrieve, update, delete, restore, clone, and subscribe to targets.

Quick Example

async with GPPClient() as client:
   target = await client.target.get_by_id(
      target_id="t-123",
      include_deleted=False,
   )

Creating Targets

Create a target by program ID:

result = await client.target.create_by_program_id(
   program_id="p-123",
   properties=properties,
   include_deleted=False,
)

Create a target by program reference:

result = await client.target.create_by_program_reference(
   program_reference="GN-2026A-Q-1",
   properties=properties,
   include_deleted=False,
)

Create a target by proposal reference:

result = await client.target.create_by_proposal_reference(
   proposal_reference="GN-2026A-Q-1",
   properties=properties,
   include_deleted=False,
)

Retrieving Targets

Get a target by ID:

result = await client.target.get_by_id(
   target_id="t-123",
   include_deleted=False,
)

Get multiple targets:

result = await client.target.get_all(
   include_deleted=False,
   where=where_input,
   limit=50,
)

Updating Targets

Update a single target by ID:

result = await client.target.update_by_id(
   target_id="t-123",
   properties=properties,
   include_deleted=False,
)

Update multiple targets:

result = await client.target.update_all(
   properties=properties,
   include_deleted=False,
   where=where_input,
   limit=25,
)

Cloning Targets

Clone a target:

result = await client.target.clone(
   target_id="t-123",
   include_deleted=False,
   properties=properties,
   replace_in=["o-123", "o-456"],
)

The optional replace_in argument may be used to replace the cloned target in one or more observations.

Delete and Restore

Delete a target by ID:

result = await client.target.delete_by_id(target_id="t-123")

Restore a target by ID:

result = await client.target.restore_by_id(target_id="t-123")

Subscriptions

Subscribe to target edit events:

async for event in client.target.subscribe_edits():
   print(event)

Restrict the subscription to a single target:

async for event in client.target.subscribe_edits(
   target_id="t-123"
):
   print(event)

Notes

All target operations use GraphQL and return generated response models.

Subscription methods return asynchronous iterators.

API Reference

class gpp_client.domains.target.TargetDomain(*, graphql: GraphQLClient, rest: RESTClient, settings: GPPSettings)[source]

Bases: BaseDomain

async clone(target_id: str, *, include_deleted: bool = False, properties: TargetPropertiesInput | None = None, replace_in: list[str] | None = None) CloneTarget[source]

Clone a target.

Parameters:
  • target_id (str) – The target ID to clone.

  • include_deleted (bool, default=False) – Whether deleted program data should be included in the result.

  • properties (TargetPropertiesInput | None, optional) – Optional replacement properties for the cloned target.

  • replace_in (list[str] | None, optional) – Optional observation IDs in which to replace the cloned target.

Returns:

The generated GraphQL response model.

Return type:

CloneTarget

async create_by_program_id(program_id: str, *, properties: TargetPropertiesInput, include_deleted: bool = False) CreateTargetByProgramId[source]

Create a target by program ID.

Parameters:
  • program_id (str) – The program ID.

  • properties (TargetPropertiesInput) – The target properties.

  • include_deleted (bool, default=False) – Whether deleted program data should be included in the result.

Returns:

The generated GraphQL response model.

Return type:

CreateTargetByProgramId

async create_by_program_reference(program_reference: str, *, properties: TargetPropertiesInput, include_deleted: bool = False) CreateTargetByProgramReference[source]

Create a target by program reference.

Parameters:
  • program_reference (str) – The program reference label.

  • properties (TargetPropertiesInput) – The target properties.

  • include_deleted (bool, default=False) – Whether deleted program data should be included in the result.

Returns:

The generated GraphQL response model.

Return type:

CreateTargetByProgramReference

async create_by_proposal_reference(proposal_reference: str, *, properties: TargetPropertiesInput, include_deleted: bool = False) CreateTargetByProposalReference[source]

Create a target by proposal reference.

Parameters:
  • proposal_reference (str) – The proposal reference label.

  • properties (TargetPropertiesInput) – The target properties.

  • include_deleted (bool, default=False) – Whether deleted program data should be included in the result.

Returns:

The generated GraphQL response model.

Return type:

CreateTargetByProposalReference

async delete_by_id(target_id: str) DeleteTargetById[source]

Delete a target by ID.

Parameters:

target_id (str) – The target ID.

Returns:

The generated GraphQL response model.

Return type:

DeleteTargetById

async get_all(*, include_deleted: bool = False, where: WhereTarget | None = None, offset: str | None = None, limit: int | None = None) GetTargets[source]

Get targets matching the provided filters.

Parameters:
  • include_deleted (bool, default=False) – Whether deleted targets should be included.

  • where (WhereTarget | None, optional) – Optional target filter.

  • offset (str | None, optional) – Optional pagination offset.

  • limit (int | None, optional) – Optional page size limit.

Returns:

The generated GraphQL response model.

Return type:

GetTargets

async get_by_id(target_id: str, *, include_deleted: bool = False) GetTargetById[source]

Get a target by ID.

Parameters:
  • target_id (str) – The target ID.

  • include_deleted (bool, default=False) – Whether deleted program data should be included in the result.

Returns:

The generated GraphQL response model.

Return type:

GetTargetById

async restore_by_id(target_id: str) RestoreTargetById[source]

Restore a target by ID.

Parameters:

target_id (str) – The target ID.

Returns:

The generated GraphQL response model.

Return type:

RestoreTargetById

async subscribe_edits(*, target_id: str | None = None) AsyncIterator[TargetEdit][source]

Subscribe to target edit events.

Parameters:

target_id (str | None, optional) – Restrict the subscription to a single target ID.

Yields:

TargetEdit – Target edit events.

async update_all(*, properties: TargetPropertiesInput, include_deleted: bool = False, where: WhereTarget | None = None, limit: int | None = None) UpdateTargets[source]

Update targets in bulk.

Parameters:
  • properties (TargetPropertiesInput) – The properties to update.

  • include_deleted (bool, default=False) – Whether deleted targets should be included in the update selection/result.

  • where (WhereTarget | None, optional) – Optional target filter.

  • limit (int | None, optional) – Optional update limit.

Returns:

The generated GraphQL response model.

Return type:

UpdateTargets

async update_by_id(target_id: str, *, properties: TargetPropertiesInput, include_deleted: bool = False) UpdateTargetById[source]

Update a target by ID.

Parameters:
  • target_id (str) – The target ID.

  • properties (TargetPropertiesInput) – The properties to update.

  • include_deleted (bool, default=False) – Whether deleted program data should be included in the result.

Returns:

The generated GraphQL response model.

Return type:

UpdateTargetById