Skip to content

list_campaigns

list_campaigns(
    catalog: Catalog,
    *,
    config_overrides: Optional[PartnerCentralMarketingClientConfig] = None,
    campaign_identifiers: Optional[CampaignIdentifierList] = None,
    name: Optional[CampaignName] = None,
    states: Optional[CampaignStateList] = None,
    sort: Optional[CampaignSort] = None,
    max_results: Optional[MaxResults] = None,
    next_token: Optional[NextToken] = None,
) -> ListCampaignsResponse

Lists campaigns with optional filters and pagination.

Parameters:

  • catalog (Catalog) –

    The catalog (AWS or Sandbox).

  • campaign_identifiers (Optional[CampaignIdentifierList], default: None ) –

    Only these campaigns, each named by its id or its campaign ARN. A campaign that does not exist, was deleted, or whose ARN names another account or catalog is left out rather than refused.

  • name (Optional[CampaignName], default: None ) –

    Only campaigns whose name contains this, compared case-insensitively.

  • states (Optional[CampaignStateList], default: None ) –

    Only campaigns in one of these states.

  • sort (Optional[CampaignSort], default: None ) –

    The order of the results. Default: CREATED_AT, DESCENDING.

  • max_results (Optional[MaxResults], default: None ) –

    Maximum results per page.

  • next_token (Optional[NextToken], default: None ) –

    Pagination token. Bound to the filters and sort it was issued for: a request that changes CampaignIdentifiers, Name, States or Sort between pages is refused with ValidationException. MaxResults may change.

Raises:

  • AccessDeniedException –

    You do not have sufficient access to perform this action. An IAM denial carries no Reason. A refusal for the caller's Partner Central state carries one, so a client tells the two apart by its presence.

  • InternalServerException –

    An unexpected error occurred during the processing of the request.

  • ThrottlingException –

    The request was denied due to request throttling.

  • ValidationException –

    The input fails to satisfy the constraints specified by the service. A caller branches on Reason, and where the rejection is attributable to particular fields it reads FieldList rather than parsing Message, which is prose and may change.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

List campaigns

>>> client.list_campaigns(catalog='AWS')
Name the campaigns a page links to
>>> client.list_campaigns(catalog='AWS', campaign_identifiers=['arn:aws:partnercentral:us-east-1:123456789012:catalog/AWS/campaign/camp-5Hq2m8x4k1p9w', 'camp-8Rt3w6y1n4b2v'])
Search active campaigns by name, by launch date
>>> client.list_campaigns(catalog='AWS', name='genai', states=['ACTIVE'], sort={'SortBy': 'START_ON', 'SortOrder': 'ASCENDING'}, max_results=20)
Source code in docs_src/capo_partnercentral_marketing/_services/partner_central_marketing.py
def list_campaigns(
    self,
    catalog: "capo_partnercentral_marketing.types.catalog.Catalog",
    *,
    config_overrides: Optional[PartnerCentralMarketingClientConfig] = None,
    campaign_identifiers: Optional[
        "capo_partnercentral_marketing.types.campaign_identifier_list.CampaignIdentifierList"
    ] = None,
    name: Optional[
        "capo_partnercentral_marketing.types.campaign_name.CampaignName"
    ] = None,
    states: Optional[
        "capo_partnercentral_marketing.types.campaign_state_list.CampaignStateList"
    ] = None,
    sort: Optional[
        "capo_partnercentral_marketing.types.campaign_sort.CampaignSort"
    ] = None,
    max_results: Optional[
        "capo_partnercentral_marketing.types.max_results.MaxResults"
    ] = None,
    next_token: Optional[
        "capo_partnercentral_marketing.types.next_token.NextToken"
    ] = None,
) -> "capo_partnercentral_marketing.types.list_campaigns_response.ListCampaignsResponse":
    """Lists campaigns with optional filters and pagination.

    Args:
        catalog: The catalog (AWS or Sandbox).
        campaign_identifiers: Only these campaigns, each named by its id or its campaign ARN. A campaign that does not exist, was deleted, or whose ARN names another account or catalog is left out rather than refused.
        name: Only campaigns whose name contains this, compared case-insensitively.
        states: Only campaigns in one of these states.
        sort: The order of the results. Default: `CREATED_AT`, `DESCENDING`.
        max_results: Maximum results per page.
        next_token: Pagination token. Bound to the filters and sort it was issued for: a request that changes `CampaignIdentifiers`, `Name`, `States` or `Sort` between pages is refused with `ValidationException`. `MaxResults` may change.

    Raises:
        capo_partnercentral_marketing.errors.access_denied_exception.AccessDeniedException: You do not have sufficient access to perform this action. An IAM denial carries no `Reason`. A refusal for the caller's Partner Central state carries one, so a client tells the two apart by its presence.
        capo_partnercentral_marketing.errors.internal_server_exception.InternalServerException: An unexpected error occurred during the processing of the request.
        capo_partnercentral_marketing.errors.throttling_exception.ThrottlingException: The request was denied due to request throttling.
        capo_partnercentral_marketing.errors.validation_exception.ValidationException: The input fails to satisfy the constraints specified by the service. A caller branches on `Reason`, and where the rejection is attributable to particular fields it reads `FieldList` rather than parsing `Message`, which is prose and may change.
        capo_partnercentral_marketing.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        List campaigns

        >>> client.list_campaigns(catalog='AWS')
        Name the campaigns a page links to

        >>> client.list_campaigns(catalog='AWS', campaign_identifiers=['arn:aws:partnercentral:us-east-1:123456789012:catalog/AWS/campaign/camp-5Hq2m8x4k1p9w', 'camp-8Rt3w6y1n4b2v'])
        Search active campaigns by name, by launch date

        >>> client.list_campaigns(catalog='AWS', name='genai', states=['ACTIVE'], sort={'SortBy': 'START_ON', 'SortOrder': 'ASCENDING'}, max_results=20)
    """

    def _handler(
        req: "OperationRequest[capo_partnercentral_marketing.types.list_campaigns_request.ListCampaignsRequest]",
    ) -> OperationResponse[
        "capo_partnercentral_marketing.types.list_campaigns_response.ListCampaignsResponse"
    ]:
        import capo_partnercentral_marketing._operations.aws_partner_demand_generator.list_campaigns

        output, http_response = (
            capo_partnercentral_marketing._operations.aws_partner_demand_generator.list_campaigns.list_campaigns(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("ListCampaigns")
    )
    input_: capo_partnercentral_marketing.types.list_campaigns_request.ListCampaignsRequest = {
        "catalog": catalog
    }
    if campaign_identifiers is not None:
        input_["campaign_identifiers"] = campaign_identifiers
    if name is not None:
        input_["name"] = name
    if states is not None:
        input_["states"] = states
    if sort is not None:
        input_["sort"] = sort
    if max_results is not None:
        input_["max_results"] = max_results
    if next_token is not None:
        input_["next_token"] = next_token

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output