Skip to content

create_product

create_product(
    display_name: ProductName,
    *,
    config_overrides: Optional[APIPortalClientConfig] = None,
    description: Optional[ProductDescription] = None,
    tags: Optional[Tags] = None,
    api_selection_configuration: Optional[ApiSelectionConfiguration] = None,
) -> CreateProductResponse

Creates a product. A product groups Managed APIs with their API pages and product pages so a portal can publish them together.

Parameters:

  • display_name (ProductName) –

    The name of the product, from 1 to 255 characters.

  • description (Optional[ProductDescription], default: None ) –

    A description of the product, up to 1024 characters.

  • api_selection_configuration (Optional[ApiSelectionConfiguration], default: None ) –

    How Managed APIs are selected for the product. The selection mode can't be changed after the product is created.

Raises:

  • AccessDeniedException –

    You do not have permission to perform this operation.

  • BadRequestException –

    The request is not valid. The message identifies the field or value that failed validation.

  • LimitExceededException –

    The request rate or a service quota was exceeded. Reduce the request rate or the number of resources and try again.

  • UnknownServiceError –

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

Source code in docs_src/capo_apiportal/_services/api_portal.py
def create_product(
    self,
    display_name: "capo_apiportal.types.product_name.ProductName",
    *,
    config_overrides: Optional[APIPortalClientConfig] = None,
    description: Optional[
        "capo_apiportal.types.product_description.ProductDescription"
    ] = None,
    tags: Optional["capo_apiportal.types.tags.Tags"] = None,
    api_selection_configuration: Optional[
        "capo_apiportal.types.api_selection_configuration.ApiSelectionConfiguration"
    ] = None,
) -> "capo_apiportal.types.create_product_response.CreateProductResponse":
    """Creates a product. A product groups Managed APIs with their API pages and product pages so a portal can publish them together.

    Args:
        display_name: The name of the product, from 1 to 255 characters.
        description: A description of the product, up to 1024 characters.
        api_selection_configuration: How Managed APIs are selected for the product. The selection mode can't be changed after the product is created.

    Raises:
        capo_apiportal.errors.access_denied_exception.AccessDeniedException: You do not have permission to perform this operation.
        capo_apiportal.errors.bad_request_exception.BadRequestException: The request is not valid. The message identifies the field or value that failed validation.
        capo_apiportal.errors.limit_exceeded_exception.LimitExceededException: The request rate or a service quota was exceeded. Reduce the request rate or the number of resources and try again.
        capo_apiportal.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_apiportal.types.create_product_request.CreateProductRequest]",
    ) -> OperationResponse[
        "capo_apiportal.types.create_product_response.CreateProductResponse"
    ]:
        import capo_apiportal._operations.api_portal_control_service.create_product

        output, http_response = (
            capo_apiportal._operations.api_portal_control_service.create_product.create_product(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateProduct")
    )
    input_: capo_apiportal.types.create_product_request.CreateProductRequest = {
        "display_name": display_name
    }
    if description is not None:
        input_["description"] = description
    if tags is not None:
        input_["tags"] = tags
    if api_selection_configuration is not None:
        input_["api_selection_configuration"] = api_selection_configuration

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