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.
 
 
 

130 lines
2.9 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 monitoring_test
  16. import (
  17. "context"
  18. monitoring "cloud.google.com/go/monitoring/apiv3"
  19. "google.golang.org/api/iterator"
  20. monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
  21. )
  22. func ExampleNewAlertPolicyClient() {
  23. ctx := context.Background()
  24. c, err := monitoring.NewAlertPolicyClient(ctx)
  25. if err != nil {
  26. // TODO: Handle error.
  27. }
  28. // TODO: Use client.
  29. _ = c
  30. }
  31. func ExampleAlertPolicyClient_ListAlertPolicies() {
  32. ctx := context.Background()
  33. c, err := monitoring.NewAlertPolicyClient(ctx)
  34. if err != nil {
  35. // TODO: Handle error.
  36. }
  37. req := &monitoringpb.ListAlertPoliciesRequest{
  38. // TODO: Fill request struct fields.
  39. }
  40. it := c.ListAlertPolicies(ctx, req)
  41. for {
  42. resp, err := it.Next()
  43. if err == iterator.Done {
  44. break
  45. }
  46. if err != nil {
  47. // TODO: Handle error.
  48. }
  49. // TODO: Use resp.
  50. _ = resp
  51. }
  52. }
  53. func ExampleAlertPolicyClient_GetAlertPolicy() {
  54. ctx := context.Background()
  55. c, err := monitoring.NewAlertPolicyClient(ctx)
  56. if err != nil {
  57. // TODO: Handle error.
  58. }
  59. req := &monitoringpb.GetAlertPolicyRequest{
  60. // TODO: Fill request struct fields.
  61. }
  62. resp, err := c.GetAlertPolicy(ctx, req)
  63. if err != nil {
  64. // TODO: Handle error.
  65. }
  66. // TODO: Use resp.
  67. _ = resp
  68. }
  69. func ExampleAlertPolicyClient_CreateAlertPolicy() {
  70. ctx := context.Background()
  71. c, err := monitoring.NewAlertPolicyClient(ctx)
  72. if err != nil {
  73. // TODO: Handle error.
  74. }
  75. req := &monitoringpb.CreateAlertPolicyRequest{
  76. // TODO: Fill request struct fields.
  77. }
  78. resp, err := c.CreateAlertPolicy(ctx, req)
  79. if err != nil {
  80. // TODO: Handle error.
  81. }
  82. // TODO: Use resp.
  83. _ = resp
  84. }
  85. func ExampleAlertPolicyClient_DeleteAlertPolicy() {
  86. ctx := context.Background()
  87. c, err := monitoring.NewAlertPolicyClient(ctx)
  88. if err != nil {
  89. // TODO: Handle error.
  90. }
  91. req := &monitoringpb.DeleteAlertPolicyRequest{
  92. // TODO: Fill request struct fields.
  93. }
  94. err = c.DeleteAlertPolicy(ctx, req)
  95. if err != nil {
  96. // TODO: Handle error.
  97. }
  98. }
  99. func ExampleAlertPolicyClient_UpdateAlertPolicy() {
  100. ctx := context.Background()
  101. c, err := monitoring.NewAlertPolicyClient(ctx)
  102. if err != nil {
  103. // TODO: Handle error.
  104. }
  105. req := &monitoringpb.UpdateAlertPolicyRequest{
  106. // TODO: Fill request struct fields.
  107. }
  108. resp, err := c.UpdateAlertPolicy(ctx, req)
  109. if err != nil {
  110. // TODO: Handle error.
  111. }
  112. // TODO: Use resp.
  113. _ = resp
  114. }