async def create_page(
        self,
        request: gcdc_page.CreatePageRequest = None,
        *,
        parent: str = None,
        page: gcdc_page.Page = None,
        retry: retries.Retry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> gcdc_page.Page:
        r"""Creates a page in the specified flow.

        Args:
            request (:class:`~.gcdc_page.CreatePageRequest`):
                The request object. The request message for
                [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage].
            parent (:class:`str`):
                Required. The flow to create a page for. Format:
                ``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>``.
                This corresponds to the ``parent`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            page (:class:`~.gcdc_page.Page`):
                Required. The page to create.
                This corresponds to the ``page`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.

            retry (google.api_core.retry.Retry): Designation of what errors, if any,
                should be retried.
            timeout (float): The timeout for this request.
            metadata (Sequence[Tuple[str, str]]): Strings which should be
                sent along with the request as metadata.

        Returns:
            ~.gcdc_page.Page:
                A Dialogflow CX conversation (session) can be described
                and visualized as a state machine. The states of a CX
                session are represented by pages.

                For each flow, you define many pages, where your
                combined pages can handle a complete conversation on the
                topics the flow is designed for. At any given moment,
                exactly one page is the current page, the current page
                is considered active, and the flow associated with that
                page is considered active. Every flow has a special
                start page. When a flow initially becomes active, the
                start page page becomes the current page. For each
                conversational turn, the current page will either stay
                the same or transition to another page.

                You configure each page to collect information from the
                end-user that is relevant for the conversational state
                represented by the page.

                For more information, see the `Page
                guide <https://cloud.google.com/dialogflow/cx/docs/concept/page>`__.

        """
        # Create or coerce a protobuf request object.
        # Sanity check: If we got a request object, we should *not* have
        # gotten any keyword arguments that map to the request.
        has_flattened_params = any([parent, page])
        if request is not None and has_flattened_params:
            raise ValueError(
                "If the `request` argument is set, then none of "
                "the individual field arguments should be set."
            )

        request = gcdc_page.CreatePageRequest(request)

        # If we have keyword arguments corresponding to fields on the
        # request, apply these.

        if parent is not None:
            request.parent = parent
        if page is not None:
            request.page = page

        # Wrap the RPC method; this adds retry and timeout information,
        # and friendly error handling.
        rpc = gapic_v1.method_async.wrap_method(
            self._client._transport.create_page,
            default_timeout=None,
            client_info=DEFAULT_CLIENT_INFO,
        )

        # Certain fields should be provided within the metadata header;
        # add these here.
        metadata = tuple(metadata) + (
            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
        )

        # Send the request.
        response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

        # Done; return the response.
        return response
Esempio n. 2
0
    def create_page(
        self,
        request: Union[gcdc_page.CreatePageRequest, dict] = None,
        *,
        parent: str = None,
        page: gcdc_page.Page = None,
        retry: OptionalRetry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> gcdc_page.Page:
        r"""Creates a page in the specified flow.

        Note: You should always train a flow prior to sending it
        queries. See the `training
        documentation <https://cloud.google.com/dialogflow/cx/docs/concept/training>`__.



        .. code-block::

            from google.cloud import dialogflowcx_v3

            def sample_create_page():
                # Create a client
                client = dialogflowcx_v3.PagesClient()

                # Initialize request argument(s)
                page = dialogflowcx_v3.Page()
                page.display_name = "display_name_value"

                request = dialogflowcx_v3.CreatePageRequest(
                    parent="parent_value",
                    page=page,
                )

                # Make the request
                response = client.create_page(request=request)

                # Handle the response
                print(response)

        Args:
            request (Union[google.cloud.dialogflowcx_v3.types.CreatePageRequest, dict]):
                The request object. The request message for
                [Pages.CreatePage][google.cloud.dialogflow.cx.v3.Pages.CreatePage].
            parent (str):
                Required. The flow to create a page for. Format:
                ``projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>/flows/<Flow ID>``.

                This corresponds to the ``parent`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            page (google.cloud.dialogflowcx_v3.types.Page):
                Required. The page to create.
                This corresponds to the ``page`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            retry (google.api_core.retry.Retry): Designation of what errors, if any,
                should be retried.
            timeout (float): The timeout for this request.
            metadata (Sequence[Tuple[str, str]]): Strings which should be
                sent along with the request as metadata.

        Returns:
            google.cloud.dialogflowcx_v3.types.Page:
                A Dialogflow CX conversation (session) can be described and visualized as a
                   state machine. The states of a CX session are
                   represented by pages.

                   For each flow, you define many pages, where your
                   combined pages can handle a complete conversation on
                   the topics the flow is designed for. At any given
                   moment, exactly one page is the current page, the
                   current page is considered active, and the flow
                   associated with that page is considered active. Every
                   flow has a special start page. When a flow initially
                   becomes active, the start page page becomes the
                   current page. For each conversational turn, the
                   current page will either stay the same or transition
                   to another page.

                   You configure each page to collect information from
                   the end-user that is relevant for the conversational
                   state represented by the page.

                   For more information, see the [Page
                   guide](\ https://cloud.google.com/dialogflow/cx/docs/concept/page).

        """
        # Create or coerce a protobuf request object.
        # Quick check: If we got a request object, we should *not* have
        # gotten any keyword arguments that map to the request.
        has_flattened_params = any([parent, page])
        if request is not None and has_flattened_params:
            raise ValueError(
                "If the `request` argument is set, then none of "
                "the individual field arguments should be set."
            )

        # Minor optimization to avoid making a copy if the user passes
        # in a gcdc_page.CreatePageRequest.
        # There's no risk of modifying the input as we've already verified
        # there are no flattened fields.
        if not isinstance(request, gcdc_page.CreatePageRequest):
            request = gcdc_page.CreatePageRequest(request)
            # If we have keyword arguments corresponding to fields on the
            # request, apply these.
            if parent is not None:
                request.parent = parent
            if page is not None:
                request.page = page

        # Wrap the RPC method; this adds retry and timeout information,
        # and friendly error handling.
        rpc = self._transport._wrapped_methods[self._transport.create_page]

        # Certain fields should be provided within the metadata header;
        # add these here.
        metadata = tuple(metadata) + (
            gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
        )

        # Send the request.
        response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)

        # Done; return the response.
        return response