Ejemplo n.º 1
0
    def update_answer_record(
        self,
        request: gcd_answer_record.UpdateAnswerRecordRequest = None,
        *,
        answer_record: gcd_answer_record.AnswerRecord = None,
        update_mask: field_mask.FieldMask = None,
        retry: retries.Retry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> gcd_answer_record.AnswerRecord:
        r"""Updates the specified answer record.

        Args:
            request (google.cloud.dialogflow_v2.types.UpdateAnswerRecordRequest):
                The request object. Request message for
                [AnswerRecords.UpdateAnswerRecord][google.cloud.dialogflow.v2.AnswerRecords.UpdateAnswerRecord].
            answer_record (google.cloud.dialogflow_v2.types.AnswerRecord):
                Required. Answer record to update.
                This corresponds to the ``answer_record`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            update_mask (google.protobuf.field_mask_pb2.FieldMask):
                Required. The mask to control which
                fields get 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.dialogflow_v2.types.AnswerRecord:
                Answer records are records to manage answer history and feedbacks for
                   Dialogflow.

                   Currently, answer record includes:

                   -  human agent assistant article suggestion
                   -  human agent assistant faq article

                   It doesn't include:

                   -  DetectIntent intent matching
                   -  DetectIntent knowledge

                   Answer records are not related to the conversation
                   history in the Dialogflow Console. A Record is
                   generated even when the end-user disables
                   conversation history in the console. Records are
                   created when there's a human agent assistant
                   suggestion generated.

                   A typical workflow for customers provide feedback to
                   an answer is:

                   1. For human agent assistant, customers get
                      suggestion via ListSuggestions API. Together with
                      the answers,
                      [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name]
                      are returned to the customers.

                   2. The customer uses the
                   [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name]
                   to call the [UpdateAnswerRecord][] method to send
                   feedback about a specific answer that they believe is
                   wrong.

        """
        # 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([answer_record, 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 gcd_answer_record.UpdateAnswerRecordRequest.
        # There's no risk of modifying the input as we've already verified
        # there are no flattened fields.
        if not isinstance(request, gcd_answer_record.UpdateAnswerRecordRequest):
            request = gcd_answer_record.UpdateAnswerRecordRequest(request)

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

            if answer_record is not None:
                request.answer_record = answer_record
            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_answer_record]

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

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

        # Done; return the response.
        return response
Ejemplo n.º 2
0
    async def update_answer_record(
        self,
        request: Union[gcd_answer_record.UpdateAnswerRecordRequest,
                       dict] = None,
        *,
        answer_record: gcd_answer_record.AnswerRecord = None,
        update_mask: field_mask_pb2.FieldMask = None,
        retry: OptionalRetry = gapic_v1.method.DEFAULT,
        timeout: float = None,
        metadata: Sequence[Tuple[str, str]] = (),
    ) -> gcd_answer_record.AnswerRecord:
        r"""Updates the specified answer record.

        .. code-block:: python

            from google.cloud import dialogflow_v2

            async def sample_update_answer_record():
                # Create a client
                client = dialogflow_v2.AnswerRecordsAsyncClient()

                # Initialize request argument(s)
                request = dialogflow_v2.UpdateAnswerRecordRequest(
                )

                # Make the request
                response = await client.update_answer_record(request=request)

                # Handle the response
                print(response)

        Args:
            request (Union[google.cloud.dialogflow_v2.types.UpdateAnswerRecordRequest, dict]):
                The request object. Request message for
                [AnswerRecords.UpdateAnswerRecord][google.cloud.dialogflow.v2.AnswerRecords.UpdateAnswerRecord].
            answer_record (:class:`google.cloud.dialogflow_v2.types.AnswerRecord`):
                Required. Answer record to update.
                This corresponds to the ``answer_record`` field
                on the ``request`` instance; if ``request`` is provided, this
                should not be set.
            update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
                Required. The mask to control which
                fields get 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.dialogflow_v2.types.AnswerRecord:
                Answer records are records to manage answer history and feedbacks for
                   Dialogflow.

                   Currently, answer record includes:

                   -  human agent assistant article suggestion
                   -  human agent assistant faq article

                   It doesn't include:

                   -  DetectIntent intent matching
                   -  DetectIntent knowledge

                   Answer records are not related to the conversation
                   history in the Dialogflow Console. A Record is
                   generated even when the end-user disables
                   conversation history in the console. Records are
                   created when there's a human agent assistant
                   suggestion generated.

                   A typical workflow for customers provide feedback to
                   an answer is:

                   1. For human agent assistant, customers get
                      suggestion via ListSuggestions API. Together with
                      the answers,
                      [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name]
                      are returned to the customers.
                   2. The customer uses the
                      [AnswerRecord.name][google.cloud.dialogflow.v2.AnswerRecord.name]
                      to call the [UpdateAnswerRecord][] method to send
                      feedback about a specific answer that they believe
                      is wrong.

        """
        # 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([answer_record, 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 = gcd_answer_record.UpdateAnswerRecordRequest(request)

        # If we have keyword arguments corresponding to fields on the
        # request, apply these.
        if answer_record is not None:
            request.answer_record = answer_record
        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_answer_record,
            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(
            (("answer_record.name", request.answer_record.name), )), )

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

        # Done; return the response.
        return response