You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

88 lines
2.0 KiB

  1. // Copyright 2019 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. // Code generated by gapic-generator. DO NOT EDIT.
  15. package dialogflow_test
  16. import (
  17. "context"
  18. "io"
  19. dialogflow "cloud.google.com/go/dialogflow/apiv2"
  20. dialogflowpb "google.golang.org/genproto/googleapis/cloud/dialogflow/v2"
  21. )
  22. func ExampleNewSessionsClient() {
  23. ctx := context.Background()
  24. c, err := dialogflow.NewSessionsClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExampleSessionsClient_DetectIntent() {
  32. ctx := context.Background()
  33. c, err := dialogflow.NewSessionsClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &dialogflowpb.DetectIntentRequest{
  38. // TODO: Fill request struct fields.
  39. }
  40. resp, err := c.DetectIntent(ctx, req)
  41. if err != nil {
  42. // TODO: Handle error.
  43. }
  44. // TODO: Use resp.
  45. _ = resp
  46. }
  47. func ExampleSessionsClient_StreamingDetectIntent() {
  48. ctx := context.Background()
  49. c, err := dialogflow.NewSessionsClient(ctx)
  50. if err != nil {
  51. // TODO: Handle error.
  52. }
  53. stream, err := c.StreamingDetectIntent(ctx)
  54. if err != nil {
  55. // TODO: Handle error.
  56. }
  57. go func() {
  58. reqs := []*dialogflowpb.StreamingDetectIntentRequest{
  59. // TODO: Create requests.
  60. }
  61. for _, req := range reqs {
  62. if err := stream.Send(req); err != nil {
  63. // TODO: Handle error.
  64. }
  65. }
  66. stream.CloseSend()
  67. }()
  68. for {
  69. resp, err := stream.Recv()
  70. if err == io.EOF {
  71. break
  72. }
  73. if err != nil {
  74. // TODO: handle error.
  75. }
  76. // TODO: Use resp.
  77. _ = resp
  78. }
  79. }