async def update_page(
        self,
        request: gcdc_page.UpdatePageRequest = None,
        *,
        page: gcdc_page.Page = None,
        update_mask: field_mask.FieldMask = None,
        retry: retries.Retry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> gcdc_page.Page:
        r"""Updates the specified page.

        Args:
            request (:class:`~.gcdc_page.UpdatePageRequest`):
                The request object. The request message for
                [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage].
            page (:class:`~.gcdc_page.Page`):
                Required. The page to update.
                This corresponds to the ``page`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            update_mask (:class:`~.field_mask.FieldMask`):
                The mask to control which fields get
                updated. If the mask is not present, all
                fields will be updated.
                This corresponds to the ``update_mask`` 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([page, update_mask])
        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.UpdatePageRequest(request)

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

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

        # Wrap the RPC method; this adds retry and timeout information,
        # and friendly error handling.
        rpc = gapic_v1.method_async.wrap_method(
            self._client._transport.update_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(
                (("page.name", request.page.name),)
            ),
        )

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

        # Done; return the response.
        return response
Ejemplo n.º 2
0
    def update_page(
        self,
        request: Union[gcdc_page.UpdatePageRequest, dict] = None,
        *,
        page: gcdc_page.Page = None,
        update_mask: field_mask_pb2.FieldMask = None,
        retry: OptionalRetry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> gcdc_page.Page:
        r"""Updates the specified page.

        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_update_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.UpdatePageRequest(
                    page=page,
                )

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

                # Handle the response
                print(response)

        Args:
            request (Union[google.cloud.dialogflowcx_v3.types.UpdatePageRequest, dict]):
                The request object. The request message for
                [Pages.UpdatePage][google.cloud.dialogflow.cx.v3.Pages.UpdatePage].
            page (google.cloud.dialogflowcx_v3.types.Page):
                Required. The page to update.
                This corresponds to the ``page`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            update_mask (google.protobuf.field_mask_pb2.FieldMask):
                The mask to control which fields get
                updated. If the mask is not present, all
                fields will be updated.

                This corresponds to the ``update_mask`` 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([page, update_mask])
        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.UpdatePageRequest.
        # There's no risk of modifying the input as we've already verified
        # there are no flattened fields.
        if not isinstance(request, gcdc_page.UpdatePageRequest):
            request = gcdc_page.UpdatePageRequest(request)
            # If we have keyword arguments corresponding to fields on the
            # request, apply these.
            if page is not None:
                request.page = page
            if update_mask is not None:
                request.update_mask = update_mask

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

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

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

        # Done; return the response.
        return response