...

Source file src/cloud.google.com/go/monitoring/apiv3/service_monitoring_client_example_test.go

Documentation: cloud.google.com/go/monitoring/apiv3

     1  // Copyright 2020 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  
    15  // Code generated by protoc-gen-go_gapic. DO NOT EDIT.
    16  
    17  package monitoring_test
    18  
    19  import (
    20  	"context"
    21  
    22  	monitoring "cloud.google.com/go/monitoring/apiv3"
    23  	"cloud.google.com/go/monitoring/apiv3/v2/monitoringpb"
    24  	"google.golang.org/api/iterator"
    25  )
    26  
    27  func ExampleNewServiceMonitoringClient() {
    28  	ctx := context.Background()
    29  	c, err := monitoring.NewServiceMonitoringClient(ctx)
    30  	if err != nil {
    31  		// TODO: Handle error.
    32  	}
    33  	// TODO: Use client.
    34  	_ = c
    35  }
    36  
    37  func ExampleServiceMonitoringClient_CreateService() {
    38  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    39  
    40  	ctx := context.Background()
    41  	c, err := monitoring.NewServiceMonitoringClient(ctx)
    42  	if err != nil {
    43  		// TODO: Handle error.
    44  	}
    45  
    46  	req := &monitoringpb.CreateServiceRequest{
    47  		// TODO: Fill request struct fields.
    48  	}
    49  	resp, err := c.CreateService(ctx, req)
    50  	if err != nil {
    51  		// TODO: Handle error.
    52  	}
    53  	// TODO: Use resp.
    54  	_ = resp
    55  }
    56  
    57  func ExampleServiceMonitoringClient_GetService() {
    58  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    59  
    60  	ctx := context.Background()
    61  	c, err := monitoring.NewServiceMonitoringClient(ctx)
    62  	if err != nil {
    63  		// TODO: Handle error.
    64  	}
    65  
    66  	req := &monitoringpb.GetServiceRequest{
    67  		// TODO: Fill request struct fields.
    68  	}
    69  	resp, err := c.GetService(ctx, req)
    70  	if err != nil {
    71  		// TODO: Handle error.
    72  	}
    73  	// TODO: Use resp.
    74  	_ = resp
    75  }
    76  
    77  func ExampleServiceMonitoringClient_ListServices() {
    78  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
    79  	// import "google.golang.org/api/iterator"
    80  
    81  	ctx := context.Background()
    82  	c, err := monitoring.NewServiceMonitoringClient(ctx)
    83  	if err != nil {
    84  		// TODO: Handle error.
    85  	}
    86  
    87  	req := &monitoringpb.ListServicesRequest{
    88  		// TODO: Fill request struct fields.
    89  	}
    90  	it := c.ListServices(ctx, req)
    91  	for {
    92  		resp, err := it.Next()
    93  		if err == iterator.Done {
    94  			break
    95  		}
    96  		if err != nil {
    97  			// TODO: Handle error.
    98  		}
    99  		// TODO: Use resp.
   100  		_ = resp
   101  	}
   102  }
   103  
   104  func ExampleServiceMonitoringClient_UpdateService() {
   105  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   106  
   107  	ctx := context.Background()
   108  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   109  	if err != nil {
   110  		// TODO: Handle error.
   111  	}
   112  
   113  	req := &monitoringpb.UpdateServiceRequest{
   114  		// TODO: Fill request struct fields.
   115  	}
   116  	resp, err := c.UpdateService(ctx, req)
   117  	if err != nil {
   118  		// TODO: Handle error.
   119  	}
   120  	// TODO: Use resp.
   121  	_ = resp
   122  }
   123  
   124  func ExampleServiceMonitoringClient_DeleteService() {
   125  	ctx := context.Background()
   126  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   127  	if err != nil {
   128  		// TODO: Handle error.
   129  	}
   130  
   131  	req := &monitoringpb.DeleteServiceRequest{
   132  		// TODO: Fill request struct fields.
   133  	}
   134  	err = c.DeleteService(ctx, req)
   135  	if err != nil {
   136  		// TODO: Handle error.
   137  	}
   138  }
   139  
   140  func ExampleServiceMonitoringClient_CreateServiceLevelObjective() {
   141  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   142  
   143  	ctx := context.Background()
   144  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   145  	if err != nil {
   146  		// TODO: Handle error.
   147  	}
   148  
   149  	req := &monitoringpb.CreateServiceLevelObjectiveRequest{
   150  		// TODO: Fill request struct fields.
   151  	}
   152  	resp, err := c.CreateServiceLevelObjective(ctx, req)
   153  	if err != nil {
   154  		// TODO: Handle error.
   155  	}
   156  	// TODO: Use resp.
   157  	_ = resp
   158  }
   159  
   160  func ExampleServiceMonitoringClient_GetServiceLevelObjective() {
   161  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   162  
   163  	ctx := context.Background()
   164  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   165  	if err != nil {
   166  		// TODO: Handle error.
   167  	}
   168  
   169  	req := &monitoringpb.GetServiceLevelObjectiveRequest{
   170  		// TODO: Fill request struct fields.
   171  	}
   172  	resp, err := c.GetServiceLevelObjective(ctx, req)
   173  	if err != nil {
   174  		// TODO: Handle error.
   175  	}
   176  	// TODO: Use resp.
   177  	_ = resp
   178  }
   179  
   180  func ExampleServiceMonitoringClient_ListServiceLevelObjectives() {
   181  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   182  	// import "google.golang.org/api/iterator"
   183  
   184  	ctx := context.Background()
   185  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   186  	if err != nil {
   187  		// TODO: Handle error.
   188  	}
   189  
   190  	req := &monitoringpb.ListServiceLevelObjectivesRequest{
   191  		// TODO: Fill request struct fields.
   192  	}
   193  	it := c.ListServiceLevelObjectives(ctx, req)
   194  	for {
   195  		resp, err := it.Next()
   196  		if err == iterator.Done {
   197  			break
   198  		}
   199  		if err != nil {
   200  			// TODO: Handle error.
   201  		}
   202  		// TODO: Use resp.
   203  		_ = resp
   204  	}
   205  }
   206  
   207  func ExampleServiceMonitoringClient_UpdateServiceLevelObjective() {
   208  	// import monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
   209  
   210  	ctx := context.Background()
   211  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   212  	if err != nil {
   213  		// TODO: Handle error.
   214  	}
   215  
   216  	req := &monitoringpb.UpdateServiceLevelObjectiveRequest{
   217  		// TODO: Fill request struct fields.
   218  	}
   219  	resp, err := c.UpdateServiceLevelObjective(ctx, req)
   220  	if err != nil {
   221  		// TODO: Handle error.
   222  	}
   223  	// TODO: Use resp.
   224  	_ = resp
   225  }
   226  
   227  func ExampleServiceMonitoringClient_DeleteServiceLevelObjective() {
   228  	ctx := context.Background()
   229  	c, err := monitoring.NewServiceMonitoringClient(ctx)
   230  	if err != nil {
   231  		// TODO: Handle error.
   232  	}
   233  
   234  	req := &monitoringpb.DeleteServiceLevelObjectiveRequest{
   235  		// TODO: Fill request struct fields.
   236  	}
   237  	err = c.DeleteServiceLevelObjective(ctx, req)
   238  	if err != nil {
   239  		// TODO: Handle error.
   240  	}
   241  }
   242  

View as plain text