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 17package irm 18 19import ( 20 "context" 21 "fmt" 22 "math" 23 "net/url" 24 "time" 25 26 "github.com/golang/protobuf/proto" 27 gax "github.com/googleapis/gax-go/v2" 28 "google.golang.org/api/iterator" 29 "google.golang.org/api/option" 30 gtransport "google.golang.org/api/transport/grpc" 31 irmpb "google.golang.org/genproto/googleapis/cloud/irm/v1alpha2" 32 "google.golang.org/grpc" 33 "google.golang.org/grpc/codes" 34 "google.golang.org/grpc/metadata" 35) 36 37// IncidentCallOptions contains the retry settings for each method of IncidentClient. 38type IncidentCallOptions struct { 39 CreateIncident []gax.CallOption 40 GetIncident []gax.CallOption 41 SearchIncidents []gax.CallOption 42 UpdateIncident []gax.CallOption 43 SearchSimilarIncidents []gax.CallOption 44 CreateAnnotation []gax.CallOption 45 ListAnnotations []gax.CallOption 46 CreateTag []gax.CallOption 47 DeleteTag []gax.CallOption 48 ListTags []gax.CallOption 49 CreateSignal []gax.CallOption 50 SearchSignals []gax.CallOption 51 LookupSignal []gax.CallOption 52 GetSignal []gax.CallOption 53 UpdateSignal []gax.CallOption 54 EscalateIncident []gax.CallOption 55 CreateArtifact []gax.CallOption 56 ListArtifacts []gax.CallOption 57 UpdateArtifact []gax.CallOption 58 DeleteArtifact []gax.CallOption 59 SendShiftHandoff []gax.CallOption 60 CreateSubscription []gax.CallOption 61 UpdateSubscription []gax.CallOption 62 ListSubscriptions []gax.CallOption 63 DeleteSubscription []gax.CallOption 64 CreateIncidentRoleAssignment []gax.CallOption 65 DeleteIncidentRoleAssignment []gax.CallOption 66 ListIncidentRoleAssignments []gax.CallOption 67 RequestIncidentRoleHandover []gax.CallOption 68 ConfirmIncidentRoleHandover []gax.CallOption 69 ForceIncidentRoleHandover []gax.CallOption 70 CancelIncidentRoleHandover []gax.CallOption 71} 72 73func defaultIncidentClientOptions() []option.ClientOption { 74 return []option.ClientOption{ 75 option.WithEndpoint("irm.googleapis.com:443"), 76 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 77 option.WithScopes(DefaultAuthScopes()...), 78 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 79 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 80 } 81} 82 83func defaultIncidentCallOptions() *IncidentCallOptions { 84 return &IncidentCallOptions{ 85 CreateIncident: []gax.CallOption{}, 86 GetIncident: []gax.CallOption{ 87 gax.WithRetry(func() gax.Retryer { 88 return gax.OnCodes([]codes.Code{ 89 codes.DeadlineExceeded, 90 codes.Unavailable, 91 }, gax.Backoff{ 92 Initial: 100 * time.Millisecond, 93 Max: 60000 * time.Millisecond, 94 Multiplier: 1.30, 95 }) 96 }), 97 }, 98 SearchIncidents: []gax.CallOption{ 99 gax.WithRetry(func() gax.Retryer { 100 return gax.OnCodes([]codes.Code{ 101 codes.DeadlineExceeded, 102 codes.Unavailable, 103 }, gax.Backoff{ 104 Initial: 100 * time.Millisecond, 105 Max: 60000 * time.Millisecond, 106 Multiplier: 1.30, 107 }) 108 }), 109 }, 110 UpdateIncident: []gax.CallOption{}, 111 SearchSimilarIncidents: []gax.CallOption{ 112 gax.WithRetry(func() gax.Retryer { 113 return gax.OnCodes([]codes.Code{ 114 codes.DeadlineExceeded, 115 codes.Unavailable, 116 }, gax.Backoff{ 117 Initial: 100 * time.Millisecond, 118 Max: 60000 * time.Millisecond, 119 Multiplier: 1.30, 120 }) 121 }), 122 }, 123 CreateAnnotation: []gax.CallOption{}, 124 ListAnnotations: []gax.CallOption{ 125 gax.WithRetry(func() gax.Retryer { 126 return gax.OnCodes([]codes.Code{ 127 codes.DeadlineExceeded, 128 codes.Unavailable, 129 }, gax.Backoff{ 130 Initial: 100 * time.Millisecond, 131 Max: 60000 * time.Millisecond, 132 Multiplier: 1.30, 133 }) 134 }), 135 }, 136 CreateTag: []gax.CallOption{}, 137 DeleteTag: []gax.CallOption{ 138 gax.WithRetry(func() gax.Retryer { 139 return gax.OnCodes([]codes.Code{ 140 codes.DeadlineExceeded, 141 codes.Unavailable, 142 }, gax.Backoff{ 143 Initial: 100 * time.Millisecond, 144 Max: 60000 * time.Millisecond, 145 Multiplier: 1.30, 146 }) 147 }), 148 }, 149 ListTags: []gax.CallOption{ 150 gax.WithRetry(func() gax.Retryer { 151 return gax.OnCodes([]codes.Code{ 152 codes.DeadlineExceeded, 153 codes.Unavailable, 154 }, gax.Backoff{ 155 Initial: 100 * time.Millisecond, 156 Max: 60000 * time.Millisecond, 157 Multiplier: 1.30, 158 }) 159 }), 160 }, 161 CreateSignal: []gax.CallOption{}, 162 SearchSignals: []gax.CallOption{ 163 gax.WithRetry(func() gax.Retryer { 164 return gax.OnCodes([]codes.Code{ 165 codes.DeadlineExceeded, 166 codes.Unavailable, 167 }, gax.Backoff{ 168 Initial: 100 * time.Millisecond, 169 Max: 60000 * time.Millisecond, 170 Multiplier: 1.30, 171 }) 172 }), 173 }, 174 LookupSignal: []gax.CallOption{ 175 gax.WithRetry(func() gax.Retryer { 176 return gax.OnCodes([]codes.Code{ 177 codes.DeadlineExceeded, 178 codes.Unavailable, 179 }, gax.Backoff{ 180 Initial: 100 * time.Millisecond, 181 Max: 60000 * time.Millisecond, 182 Multiplier: 1.30, 183 }) 184 }), 185 }, 186 GetSignal: []gax.CallOption{ 187 gax.WithRetry(func() gax.Retryer { 188 return gax.OnCodes([]codes.Code{ 189 codes.DeadlineExceeded, 190 codes.Unavailable, 191 }, gax.Backoff{ 192 Initial: 100 * time.Millisecond, 193 Max: 60000 * time.Millisecond, 194 Multiplier: 1.30, 195 }) 196 }), 197 }, 198 UpdateSignal: []gax.CallOption{}, 199 EscalateIncident: []gax.CallOption{}, 200 CreateArtifact: []gax.CallOption{}, 201 ListArtifacts: []gax.CallOption{ 202 gax.WithRetry(func() gax.Retryer { 203 return gax.OnCodes([]codes.Code{ 204 codes.DeadlineExceeded, 205 codes.Unavailable, 206 }, gax.Backoff{ 207 Initial: 100 * time.Millisecond, 208 Max: 60000 * time.Millisecond, 209 Multiplier: 1.30, 210 }) 211 }), 212 }, 213 UpdateArtifact: []gax.CallOption{}, 214 DeleteArtifact: []gax.CallOption{ 215 gax.WithRetry(func() gax.Retryer { 216 return gax.OnCodes([]codes.Code{ 217 codes.DeadlineExceeded, 218 codes.Unavailable, 219 }, gax.Backoff{ 220 Initial: 100 * time.Millisecond, 221 Max: 60000 * time.Millisecond, 222 Multiplier: 1.30, 223 }) 224 }), 225 }, 226 SendShiftHandoff: []gax.CallOption{}, 227 CreateSubscription: []gax.CallOption{}, 228 UpdateSubscription: []gax.CallOption{}, 229 ListSubscriptions: []gax.CallOption{ 230 gax.WithRetry(func() gax.Retryer { 231 return gax.OnCodes([]codes.Code{ 232 codes.DeadlineExceeded, 233 codes.Unavailable, 234 }, gax.Backoff{ 235 Initial: 100 * time.Millisecond, 236 Max: 60000 * time.Millisecond, 237 Multiplier: 1.30, 238 }) 239 }), 240 }, 241 DeleteSubscription: []gax.CallOption{ 242 gax.WithRetry(func() gax.Retryer { 243 return gax.OnCodes([]codes.Code{ 244 codes.DeadlineExceeded, 245 codes.Unavailable, 246 }, gax.Backoff{ 247 Initial: 100 * time.Millisecond, 248 Max: 60000 * time.Millisecond, 249 Multiplier: 1.30, 250 }) 251 }), 252 }, 253 CreateIncidentRoleAssignment: []gax.CallOption{}, 254 DeleteIncidentRoleAssignment: []gax.CallOption{ 255 gax.WithRetry(func() gax.Retryer { 256 return gax.OnCodes([]codes.Code{ 257 codes.DeadlineExceeded, 258 codes.Unavailable, 259 }, gax.Backoff{ 260 Initial: 100 * time.Millisecond, 261 Max: 60000 * time.Millisecond, 262 Multiplier: 1.30, 263 }) 264 }), 265 }, 266 ListIncidentRoleAssignments: []gax.CallOption{ 267 gax.WithRetry(func() gax.Retryer { 268 return gax.OnCodes([]codes.Code{ 269 codes.DeadlineExceeded, 270 codes.Unavailable, 271 }, gax.Backoff{ 272 Initial: 100 * time.Millisecond, 273 Max: 60000 * time.Millisecond, 274 Multiplier: 1.30, 275 }) 276 }), 277 }, 278 RequestIncidentRoleHandover: []gax.CallOption{}, 279 ConfirmIncidentRoleHandover: []gax.CallOption{}, 280 ForceIncidentRoleHandover: []gax.CallOption{}, 281 CancelIncidentRoleHandover: []gax.CallOption{}, 282 } 283} 284 285// IncidentClient is a client for interacting with Stackdriver Incident Response & Management API. 286// 287// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 288type IncidentClient struct { 289 // Connection pool of gRPC connections to the service. 290 connPool gtransport.ConnPool 291 292 // The gRPC API client. 293 incidentClient irmpb.IncidentServiceClient 294 295 // The call options for this service. 296 CallOptions *IncidentCallOptions 297 298 // The x-goog-* metadata to be sent with each request. 299 xGoogMetadata metadata.MD 300} 301 302// NewIncidentClient creates a new incident service client. 303// 304// The Incident API for Incident Response & Management. 305func NewIncidentClient(ctx context.Context, opts ...option.ClientOption) (*IncidentClient, error) { 306 connPool, err := gtransport.DialPool(ctx, append(defaultIncidentClientOptions(), opts...)...) 307 if err != nil { 308 return nil, err 309 } 310 c := &IncidentClient{ 311 connPool: connPool, 312 CallOptions: defaultIncidentCallOptions(), 313 314 incidentClient: irmpb.NewIncidentServiceClient(connPool), 315 } 316 c.setGoogleClientInfo() 317 318 return c, nil 319} 320 321// Connection returns a connection to the API service. 322// 323// Deprecated. 324func (c *IncidentClient) Connection() *grpc.ClientConn { 325 return c.connPool.Conn() 326} 327 328// Close closes the connection to the API service. The user should invoke this when 329// the client is no longer required. 330func (c *IncidentClient) Close() error { 331 return c.connPool.Close() 332} 333 334// setGoogleClientInfo sets the name and version of the application in 335// the `x-goog-api-client` header passed on each request. Intended for 336// use by Google-written clients. 337func (c *IncidentClient) setGoogleClientInfo(keyval ...string) { 338 kv := append([]string{"gl-go", versionGo()}, keyval...) 339 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 340 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 341} 342 343// CreateIncident creates a new incident. 344func (c *IncidentClient) CreateIncident(ctx context.Context, req *irmpb.CreateIncidentRequest, opts ...gax.CallOption) (*irmpb.Incident, error) { 345 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 346 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 347 opts = append(c.CallOptions.CreateIncident[0:len(c.CallOptions.CreateIncident):len(c.CallOptions.CreateIncident)], opts...) 348 var resp *irmpb.Incident 349 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 350 var err error 351 resp, err = c.incidentClient.CreateIncident(ctx, req, settings.GRPC...) 352 return err 353 }, opts...) 354 if err != nil { 355 return nil, err 356 } 357 return resp, nil 358} 359 360// GetIncident returns an incident by name. 361func (c *IncidentClient) GetIncident(ctx context.Context, req *irmpb.GetIncidentRequest, opts ...gax.CallOption) (*irmpb.Incident, error) { 362 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 363 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 364 opts = append(c.CallOptions.GetIncident[0:len(c.CallOptions.GetIncident):len(c.CallOptions.GetIncident)], opts...) 365 var resp *irmpb.Incident 366 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 367 var err error 368 resp, err = c.incidentClient.GetIncident(ctx, req, settings.GRPC...) 369 return err 370 }, opts...) 371 if err != nil { 372 return nil, err 373 } 374 return resp, nil 375} 376 377// SearchIncidents returns a list of incidents. 378// Incidents are ordered by start time, with the most recent incidents first. 379func (c *IncidentClient) SearchIncidents(ctx context.Context, req *irmpb.SearchIncidentsRequest, opts ...gax.CallOption) *IncidentIterator { 380 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 381 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 382 opts = append(c.CallOptions.SearchIncidents[0:len(c.CallOptions.SearchIncidents):len(c.CallOptions.SearchIncidents)], opts...) 383 it := &IncidentIterator{} 384 req = proto.Clone(req).(*irmpb.SearchIncidentsRequest) 385 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.Incident, string, error) { 386 var resp *irmpb.SearchIncidentsResponse 387 req.PageToken = pageToken 388 if pageSize > math.MaxInt32 { 389 req.PageSize = math.MaxInt32 390 } else { 391 req.PageSize = int32(pageSize) 392 } 393 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 394 var err error 395 resp, err = c.incidentClient.SearchIncidents(ctx, req, settings.GRPC...) 396 return err 397 }, opts...) 398 if err != nil { 399 return nil, "", err 400 } 401 402 it.Response = resp 403 return resp.Incidents, resp.NextPageToken, nil 404 } 405 fetch := func(pageSize int, pageToken string) (string, error) { 406 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 407 if err != nil { 408 return "", err 409 } 410 it.items = append(it.items, items...) 411 return nextPageToken, nil 412 } 413 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 414 it.pageInfo.MaxSize = int(req.PageSize) 415 it.pageInfo.Token = req.PageToken 416 return it 417} 418 419// UpdateIncident updates an existing incident. 420func (c *IncidentClient) UpdateIncident(ctx context.Context, req *irmpb.UpdateIncidentRequest, opts ...gax.CallOption) (*irmpb.Incident, error) { 421 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "incident.name", url.QueryEscape(req.GetIncident().GetName()))) 422 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 423 opts = append(c.CallOptions.UpdateIncident[0:len(c.CallOptions.UpdateIncident):len(c.CallOptions.UpdateIncident)], opts...) 424 var resp *irmpb.Incident 425 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 426 var err error 427 resp, err = c.incidentClient.UpdateIncident(ctx, req, settings.GRPC...) 428 return err 429 }, opts...) 430 if err != nil { 431 return nil, err 432 } 433 return resp, nil 434} 435 436// SearchSimilarIncidents returns a list of incidents that are “similar” to the specified incident 437// or signal. This functionality is provided on a best-effort basis and the 438// definition of “similar” is subject to change. 439func (c *IncidentClient) SearchSimilarIncidents(ctx context.Context, req *irmpb.SearchSimilarIncidentsRequest, opts ...gax.CallOption) *SearchSimilarIncidentsResponse_ResultIterator { 440 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 441 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 442 opts = append(c.CallOptions.SearchSimilarIncidents[0:len(c.CallOptions.SearchSimilarIncidents):len(c.CallOptions.SearchSimilarIncidents)], opts...) 443 it := &SearchSimilarIncidentsResponse_ResultIterator{} 444 req = proto.Clone(req).(*irmpb.SearchSimilarIncidentsRequest) 445 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.SearchSimilarIncidentsResponse_Result, string, error) { 446 var resp *irmpb.SearchSimilarIncidentsResponse 447 req.PageToken = pageToken 448 if pageSize > math.MaxInt32 { 449 req.PageSize = math.MaxInt32 450 } else { 451 req.PageSize = int32(pageSize) 452 } 453 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 454 var err error 455 resp, err = c.incidentClient.SearchSimilarIncidents(ctx, req, settings.GRPC...) 456 return err 457 }, opts...) 458 if err != nil { 459 return nil, "", err 460 } 461 462 it.Response = resp 463 return resp.Results, resp.NextPageToken, nil 464 } 465 fetch := func(pageSize int, pageToken string) (string, error) { 466 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 467 if err != nil { 468 return "", err 469 } 470 it.items = append(it.items, items...) 471 return nextPageToken, nil 472 } 473 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 474 it.pageInfo.MaxSize = int(req.PageSize) 475 it.pageInfo.Token = req.PageToken 476 return it 477} 478 479// CreateAnnotation creates an annotation on an existing incident. Only ‘text/plain’ and 480// ‘text/markdown’ annotations can be created via this method. 481func (c *IncidentClient) CreateAnnotation(ctx context.Context, req *irmpb.CreateAnnotationRequest, opts ...gax.CallOption) (*irmpb.Annotation, error) { 482 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 483 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 484 opts = append(c.CallOptions.CreateAnnotation[0:len(c.CallOptions.CreateAnnotation):len(c.CallOptions.CreateAnnotation)], opts...) 485 var resp *irmpb.Annotation 486 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 487 var err error 488 resp, err = c.incidentClient.CreateAnnotation(ctx, req, settings.GRPC...) 489 return err 490 }, opts...) 491 if err != nil { 492 return nil, err 493 } 494 return resp, nil 495} 496 497// ListAnnotations lists annotations that are part of an incident. No assumptions should be 498// made on the content-type of the annotation returned. 499func (c *IncidentClient) ListAnnotations(ctx context.Context, req *irmpb.ListAnnotationsRequest, opts ...gax.CallOption) *AnnotationIterator { 500 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 501 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 502 opts = append(c.CallOptions.ListAnnotations[0:len(c.CallOptions.ListAnnotations):len(c.CallOptions.ListAnnotations)], opts...) 503 it := &AnnotationIterator{} 504 req = proto.Clone(req).(*irmpb.ListAnnotationsRequest) 505 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.Annotation, string, error) { 506 var resp *irmpb.ListAnnotationsResponse 507 req.PageToken = pageToken 508 if pageSize > math.MaxInt32 { 509 req.PageSize = math.MaxInt32 510 } else { 511 req.PageSize = int32(pageSize) 512 } 513 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 514 var err error 515 resp, err = c.incidentClient.ListAnnotations(ctx, req, settings.GRPC...) 516 return err 517 }, opts...) 518 if err != nil { 519 return nil, "", err 520 } 521 522 it.Response = resp 523 return resp.Annotations, resp.NextPageToken, nil 524 } 525 fetch := func(pageSize int, pageToken string) (string, error) { 526 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 527 if err != nil { 528 return "", err 529 } 530 it.items = append(it.items, items...) 531 return nextPageToken, nil 532 } 533 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 534 it.pageInfo.MaxSize = int(req.PageSize) 535 it.pageInfo.Token = req.PageToken 536 return it 537} 538 539// CreateTag creates a tag on an existing incident. 540func (c *IncidentClient) CreateTag(ctx context.Context, req *irmpb.CreateTagRequest, opts ...gax.CallOption) (*irmpb.Tag, error) { 541 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 542 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 543 opts = append(c.CallOptions.CreateTag[0:len(c.CallOptions.CreateTag):len(c.CallOptions.CreateTag)], opts...) 544 var resp *irmpb.Tag 545 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 546 var err error 547 resp, err = c.incidentClient.CreateTag(ctx, req, settings.GRPC...) 548 return err 549 }, opts...) 550 if err != nil { 551 return nil, err 552 } 553 return resp, nil 554} 555 556// DeleteTag deletes an existing tag. 557func (c *IncidentClient) DeleteTag(ctx context.Context, req *irmpb.DeleteTagRequest, opts ...gax.CallOption) error { 558 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 559 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 560 opts = append(c.CallOptions.DeleteTag[0:len(c.CallOptions.DeleteTag):len(c.CallOptions.DeleteTag)], opts...) 561 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 562 var err error 563 _, err = c.incidentClient.DeleteTag(ctx, req, settings.GRPC...) 564 return err 565 }, opts...) 566 return err 567} 568 569// ListTags lists tags that are part of an incident. 570func (c *IncidentClient) ListTags(ctx context.Context, req *irmpb.ListTagsRequest, opts ...gax.CallOption) *TagIterator { 571 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 572 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 573 opts = append(c.CallOptions.ListTags[0:len(c.CallOptions.ListTags):len(c.CallOptions.ListTags)], opts...) 574 it := &TagIterator{} 575 req = proto.Clone(req).(*irmpb.ListTagsRequest) 576 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.Tag, string, error) { 577 var resp *irmpb.ListTagsResponse 578 req.PageToken = pageToken 579 if pageSize > math.MaxInt32 { 580 req.PageSize = math.MaxInt32 581 } else { 582 req.PageSize = int32(pageSize) 583 } 584 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 585 var err error 586 resp, err = c.incidentClient.ListTags(ctx, req, settings.GRPC...) 587 return err 588 }, opts...) 589 if err != nil { 590 return nil, "", err 591 } 592 593 it.Response = resp 594 return resp.Tags, resp.NextPageToken, nil 595 } 596 fetch := func(pageSize int, pageToken string) (string, error) { 597 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 598 if err != nil { 599 return "", err 600 } 601 it.items = append(it.items, items...) 602 return nextPageToken, nil 603 } 604 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 605 it.pageInfo.MaxSize = int(req.PageSize) 606 it.pageInfo.Token = req.PageToken 607 return it 608} 609 610// CreateSignal creates a new signal. 611func (c *IncidentClient) CreateSignal(ctx context.Context, req *irmpb.CreateSignalRequest, opts ...gax.CallOption) (*irmpb.Signal, error) { 612 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 613 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 614 opts = append(c.CallOptions.CreateSignal[0:len(c.CallOptions.CreateSignal):len(c.CallOptions.CreateSignal)], opts...) 615 var resp *irmpb.Signal 616 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 617 var err error 618 resp, err = c.incidentClient.CreateSignal(ctx, req, settings.GRPC...) 619 return err 620 }, opts...) 621 if err != nil { 622 return nil, err 623 } 624 return resp, nil 625} 626 627// SearchSignals lists signals that are part of an incident. 628// Signals are returned in reverse chronological order. 629// Note that search should not be relied on for critical functionality. It 630// has lower availability guarantees and might fail to return valid results. 631// Returned results might include stale or extraneous entries. 632func (c *IncidentClient) SearchSignals(ctx context.Context, req *irmpb.SearchSignalsRequest, opts ...gax.CallOption) *SignalIterator { 633 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 634 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 635 opts = append(c.CallOptions.SearchSignals[0:len(c.CallOptions.SearchSignals):len(c.CallOptions.SearchSignals)], opts...) 636 it := &SignalIterator{} 637 req = proto.Clone(req).(*irmpb.SearchSignalsRequest) 638 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.Signal, string, error) { 639 var resp *irmpb.SearchSignalsResponse 640 req.PageToken = pageToken 641 if pageSize > math.MaxInt32 { 642 req.PageSize = math.MaxInt32 643 } else { 644 req.PageSize = int32(pageSize) 645 } 646 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 647 var err error 648 resp, err = c.incidentClient.SearchSignals(ctx, req, settings.GRPC...) 649 return err 650 }, opts...) 651 if err != nil { 652 return nil, "", err 653 } 654 655 it.Response = resp 656 return resp.Signals, resp.NextPageToken, nil 657 } 658 fetch := func(pageSize int, pageToken string) (string, error) { 659 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 660 if err != nil { 661 return "", err 662 } 663 it.items = append(it.items, items...) 664 return nextPageToken, nil 665 } 666 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 667 it.pageInfo.MaxSize = int(req.PageSize) 668 it.pageInfo.Token = req.PageToken 669 return it 670} 671 672// LookupSignal finds a signal by other unique IDs. 673func (c *IncidentClient) LookupSignal(ctx context.Context, req *irmpb.LookupSignalRequest, opts ...gax.CallOption) (*irmpb.Signal, error) { 674 ctx = insertMetadata(ctx, c.xGoogMetadata) 675 opts = append(c.CallOptions.LookupSignal[0:len(c.CallOptions.LookupSignal):len(c.CallOptions.LookupSignal)], opts...) 676 var resp *irmpb.Signal 677 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 678 var err error 679 resp, err = c.incidentClient.LookupSignal(ctx, req, settings.GRPC...) 680 return err 681 }, opts...) 682 if err != nil { 683 return nil, err 684 } 685 return resp, nil 686} 687 688// GetSignal returns a signal by name. 689func (c *IncidentClient) GetSignal(ctx context.Context, req *irmpb.GetSignalRequest, opts ...gax.CallOption) (*irmpb.Signal, error) { 690 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 691 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 692 opts = append(c.CallOptions.GetSignal[0:len(c.CallOptions.GetSignal):len(c.CallOptions.GetSignal)], opts...) 693 var resp *irmpb.Signal 694 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 695 var err error 696 resp, err = c.incidentClient.GetSignal(ctx, req, settings.GRPC...) 697 return err 698 }, opts...) 699 if err != nil { 700 return nil, err 701 } 702 return resp, nil 703} 704 705// UpdateSignal updates an existing signal (for example, to assign/unassign it to an 706// incident). 707func (c *IncidentClient) UpdateSignal(ctx context.Context, req *irmpb.UpdateSignalRequest, opts ...gax.CallOption) (*irmpb.Signal, error) { 708 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "signal.name", url.QueryEscape(req.GetSignal().GetName()))) 709 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 710 opts = append(c.CallOptions.UpdateSignal[0:len(c.CallOptions.UpdateSignal):len(c.CallOptions.UpdateSignal)], opts...) 711 var resp *irmpb.Signal 712 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 713 var err error 714 resp, err = c.incidentClient.UpdateSignal(ctx, req, settings.GRPC...) 715 return err 716 }, opts...) 717 if err != nil { 718 return nil, err 719 } 720 return resp, nil 721} 722 723// EscalateIncident escalates an incident. 724func (c *IncidentClient) EscalateIncident(ctx context.Context, req *irmpb.EscalateIncidentRequest, opts ...gax.CallOption) (*irmpb.EscalateIncidentResponse, error) { 725 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "incident.name", url.QueryEscape(req.GetIncident().GetName()))) 726 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 727 opts = append(c.CallOptions.EscalateIncident[0:len(c.CallOptions.EscalateIncident):len(c.CallOptions.EscalateIncident)], opts...) 728 var resp *irmpb.EscalateIncidentResponse 729 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 730 var err error 731 resp, err = c.incidentClient.EscalateIncident(ctx, req, settings.GRPC...) 732 return err 733 }, opts...) 734 if err != nil { 735 return nil, err 736 } 737 return resp, nil 738} 739 740// CreateArtifact creates a new artifact. 741func (c *IncidentClient) CreateArtifact(ctx context.Context, req *irmpb.CreateArtifactRequest, opts ...gax.CallOption) (*irmpb.Artifact, error) { 742 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 743 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 744 opts = append(c.CallOptions.CreateArtifact[0:len(c.CallOptions.CreateArtifact):len(c.CallOptions.CreateArtifact)], opts...) 745 var resp *irmpb.Artifact 746 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 747 var err error 748 resp, err = c.incidentClient.CreateArtifact(ctx, req, settings.GRPC...) 749 return err 750 }, opts...) 751 if err != nil { 752 return nil, err 753 } 754 return resp, nil 755} 756 757// ListArtifacts returns a list of artifacts for an incident. 758func (c *IncidentClient) ListArtifacts(ctx context.Context, req *irmpb.ListArtifactsRequest, opts ...gax.CallOption) *ArtifactIterator { 759 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 760 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 761 opts = append(c.CallOptions.ListArtifacts[0:len(c.CallOptions.ListArtifacts):len(c.CallOptions.ListArtifacts)], opts...) 762 it := &ArtifactIterator{} 763 req = proto.Clone(req).(*irmpb.ListArtifactsRequest) 764 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.Artifact, string, error) { 765 var resp *irmpb.ListArtifactsResponse 766 req.PageToken = pageToken 767 if pageSize > math.MaxInt32 { 768 req.PageSize = math.MaxInt32 769 } else { 770 req.PageSize = int32(pageSize) 771 } 772 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 773 var err error 774 resp, err = c.incidentClient.ListArtifacts(ctx, req, settings.GRPC...) 775 return err 776 }, opts...) 777 if err != nil { 778 return nil, "", err 779 } 780 781 it.Response = resp 782 return resp.Artifacts, resp.NextPageToken, nil 783 } 784 fetch := func(pageSize int, pageToken string) (string, error) { 785 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 786 if err != nil { 787 return "", err 788 } 789 it.items = append(it.items, items...) 790 return nextPageToken, nil 791 } 792 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 793 it.pageInfo.MaxSize = int(req.PageSize) 794 it.pageInfo.Token = req.PageToken 795 return it 796} 797 798// UpdateArtifact updates an existing artifact. 799func (c *IncidentClient) UpdateArtifact(ctx context.Context, req *irmpb.UpdateArtifactRequest, opts ...gax.CallOption) (*irmpb.Artifact, error) { 800 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "artifact.name", url.QueryEscape(req.GetArtifact().GetName()))) 801 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 802 opts = append(c.CallOptions.UpdateArtifact[0:len(c.CallOptions.UpdateArtifact):len(c.CallOptions.UpdateArtifact)], opts...) 803 var resp *irmpb.Artifact 804 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 805 var err error 806 resp, err = c.incidentClient.UpdateArtifact(ctx, req, settings.GRPC...) 807 return err 808 }, opts...) 809 if err != nil { 810 return nil, err 811 } 812 return resp, nil 813} 814 815// DeleteArtifact deletes an existing artifact. 816func (c *IncidentClient) DeleteArtifact(ctx context.Context, req *irmpb.DeleteArtifactRequest, opts ...gax.CallOption) error { 817 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 818 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 819 opts = append(c.CallOptions.DeleteArtifact[0:len(c.CallOptions.DeleteArtifact):len(c.CallOptions.DeleteArtifact)], opts...) 820 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 821 var err error 822 _, err = c.incidentClient.DeleteArtifact(ctx, req, settings.GRPC...) 823 return err 824 }, opts...) 825 return err 826} 827 828// SendShiftHandoff sends a summary of the shift for oncall handoff. 829func (c *IncidentClient) SendShiftHandoff(ctx context.Context, req *irmpb.SendShiftHandoffRequest, opts ...gax.CallOption) (*irmpb.SendShiftHandoffResponse, error) { 830 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 831 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 832 opts = append(c.CallOptions.SendShiftHandoff[0:len(c.CallOptions.SendShiftHandoff):len(c.CallOptions.SendShiftHandoff)], opts...) 833 var resp *irmpb.SendShiftHandoffResponse 834 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 835 var err error 836 resp, err = c.incidentClient.SendShiftHandoff(ctx, req, settings.GRPC...) 837 return err 838 }, opts...) 839 if err != nil { 840 return nil, err 841 } 842 return resp, nil 843} 844 845// CreateSubscription creates a new subscription. 846// This will fail if: 847// a. there are too many (50) subscriptions in the incident already 848// b. a subscription using the given channel already exists 849func (c *IncidentClient) CreateSubscription(ctx context.Context, req *irmpb.CreateSubscriptionRequest, opts ...gax.CallOption) (*irmpb.Subscription, error) { 850 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 851 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 852 opts = append(c.CallOptions.CreateSubscription[0:len(c.CallOptions.CreateSubscription):len(c.CallOptions.CreateSubscription)], opts...) 853 var resp *irmpb.Subscription 854 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 855 var err error 856 resp, err = c.incidentClient.CreateSubscription(ctx, req, settings.GRPC...) 857 return err 858 }, opts...) 859 if err != nil { 860 return nil, err 861 } 862 return resp, nil 863} 864 865// UpdateSubscription updates a subscription. 866func (c *IncidentClient) UpdateSubscription(ctx context.Context, req *irmpb.UpdateSubscriptionRequest, opts ...gax.CallOption) (*irmpb.Subscription, error) { 867 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "subscription.name", url.QueryEscape(req.GetSubscription().GetName()))) 868 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 869 opts = append(c.CallOptions.UpdateSubscription[0:len(c.CallOptions.UpdateSubscription):len(c.CallOptions.UpdateSubscription)], opts...) 870 var resp *irmpb.Subscription 871 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 872 var err error 873 resp, err = c.incidentClient.UpdateSubscription(ctx, req, settings.GRPC...) 874 return err 875 }, opts...) 876 if err != nil { 877 return nil, err 878 } 879 return resp, nil 880} 881 882// ListSubscriptions returns a list of subscriptions for an incident. 883func (c *IncidentClient) ListSubscriptions(ctx context.Context, req *irmpb.ListSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator { 884 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 885 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 886 opts = append(c.CallOptions.ListSubscriptions[0:len(c.CallOptions.ListSubscriptions):len(c.CallOptions.ListSubscriptions)], opts...) 887 it := &SubscriptionIterator{} 888 req = proto.Clone(req).(*irmpb.ListSubscriptionsRequest) 889 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.Subscription, string, error) { 890 var resp *irmpb.ListSubscriptionsResponse 891 req.PageToken = pageToken 892 if pageSize > math.MaxInt32 { 893 req.PageSize = math.MaxInt32 894 } else { 895 req.PageSize = int32(pageSize) 896 } 897 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 898 var err error 899 resp, err = c.incidentClient.ListSubscriptions(ctx, req, settings.GRPC...) 900 return err 901 }, opts...) 902 if err != nil { 903 return nil, "", err 904 } 905 906 it.Response = resp 907 return resp.Subscriptions, resp.NextPageToken, nil 908 } 909 fetch := func(pageSize int, pageToken string) (string, error) { 910 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 911 if err != nil { 912 return "", err 913 } 914 it.items = append(it.items, items...) 915 return nextPageToken, nil 916 } 917 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 918 it.pageInfo.MaxSize = int(req.PageSize) 919 it.pageInfo.Token = req.PageToken 920 return it 921} 922 923// DeleteSubscription deletes an existing subscription. 924func (c *IncidentClient) DeleteSubscription(ctx context.Context, req *irmpb.DeleteSubscriptionRequest, opts ...gax.CallOption) error { 925 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 926 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 927 opts = append(c.CallOptions.DeleteSubscription[0:len(c.CallOptions.DeleteSubscription):len(c.CallOptions.DeleteSubscription)], opts...) 928 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 929 var err error 930 _, err = c.incidentClient.DeleteSubscription(ctx, req, settings.GRPC...) 931 return err 932 }, opts...) 933 return err 934} 935 936// CreateIncidentRoleAssignment creates a role assignment on an existing incident. Normally, the user field 937// will be set when assigning a role to oneself, and the next field will be 938// set when proposing another user as the assignee. Setting the next field 939// directly to a user other than oneself is equivalent to proposing and 940// force-assigning the role to the user. 941func (c *IncidentClient) CreateIncidentRoleAssignment(ctx context.Context, req *irmpb.CreateIncidentRoleAssignmentRequest, opts ...gax.CallOption) (*irmpb.IncidentRoleAssignment, error) { 942 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 943 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 944 opts = append(c.CallOptions.CreateIncidentRoleAssignment[0:len(c.CallOptions.CreateIncidentRoleAssignment):len(c.CallOptions.CreateIncidentRoleAssignment)], opts...) 945 var resp *irmpb.IncidentRoleAssignment 946 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 947 var err error 948 resp, err = c.incidentClient.CreateIncidentRoleAssignment(ctx, req, settings.GRPC...) 949 return err 950 }, opts...) 951 if err != nil { 952 return nil, err 953 } 954 return resp, nil 955} 956 957// DeleteIncidentRoleAssignment deletes an existing role assignment. 958func (c *IncidentClient) DeleteIncidentRoleAssignment(ctx context.Context, req *irmpb.DeleteIncidentRoleAssignmentRequest, opts ...gax.CallOption) error { 959 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 960 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 961 opts = append(c.CallOptions.DeleteIncidentRoleAssignment[0:len(c.CallOptions.DeleteIncidentRoleAssignment):len(c.CallOptions.DeleteIncidentRoleAssignment)], opts...) 962 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 963 var err error 964 _, err = c.incidentClient.DeleteIncidentRoleAssignment(ctx, req, settings.GRPC...) 965 return err 966 }, opts...) 967 return err 968} 969 970// ListIncidentRoleAssignments lists role assignments that are part of an incident. 971func (c *IncidentClient) ListIncidentRoleAssignments(ctx context.Context, req *irmpb.ListIncidentRoleAssignmentsRequest, opts ...gax.CallOption) *IncidentRoleAssignmentIterator { 972 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 973 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 974 opts = append(c.CallOptions.ListIncidentRoleAssignments[0:len(c.CallOptions.ListIncidentRoleAssignments):len(c.CallOptions.ListIncidentRoleAssignments)], opts...) 975 it := &IncidentRoleAssignmentIterator{} 976 req = proto.Clone(req).(*irmpb.ListIncidentRoleAssignmentsRequest) 977 it.InternalFetch = func(pageSize int, pageToken string) ([]*irmpb.IncidentRoleAssignment, string, error) { 978 var resp *irmpb.ListIncidentRoleAssignmentsResponse 979 req.PageToken = pageToken 980 if pageSize > math.MaxInt32 { 981 req.PageSize = math.MaxInt32 982 } else { 983 req.PageSize = int32(pageSize) 984 } 985 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 986 var err error 987 resp, err = c.incidentClient.ListIncidentRoleAssignments(ctx, req, settings.GRPC...) 988 return err 989 }, opts...) 990 if err != nil { 991 return nil, "", err 992 } 993 994 it.Response = resp 995 return resp.IncidentRoleAssignments, resp.NextPageToken, nil 996 } 997 fetch := func(pageSize int, pageToken string) (string, error) { 998 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 999 if err != nil { 1000 return "", err 1001 } 1002 it.items = append(it.items, items...) 1003 return nextPageToken, nil 1004 } 1005 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1006 it.pageInfo.MaxSize = int(req.PageSize) 1007 it.pageInfo.Token = req.PageToken 1008 return it 1009} 1010 1011// RequestIncidentRoleHandover starts a role handover. The proposed assignee will receive an email 1012// notifying them of the assignment. This will fail if a role handover is 1013// already pending. 1014// Handover to an oncall ladder is not permitted. Use 1015// CreateIncidentRoleAssignment instead. 1016func (c *IncidentClient) RequestIncidentRoleHandover(ctx context.Context, req *irmpb.RequestIncidentRoleHandoverRequest, opts ...gax.CallOption) (*irmpb.IncidentRoleAssignment, error) { 1017 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1018 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1019 opts = append(c.CallOptions.RequestIncidentRoleHandover[0:len(c.CallOptions.RequestIncidentRoleHandover):len(c.CallOptions.RequestIncidentRoleHandover)], opts...) 1020 var resp *irmpb.IncidentRoleAssignment 1021 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1022 var err error 1023 resp, err = c.incidentClient.RequestIncidentRoleHandover(ctx, req, settings.GRPC...) 1024 return err 1025 }, opts...) 1026 if err != nil { 1027 return nil, err 1028 } 1029 return resp, nil 1030} 1031 1032// ConfirmIncidentRoleHandover confirms a role handover. This will fail if the ‘proposed_assignee’ field 1033// of the IncidentRoleAssignment is not equal to the ‘new_assignee’ field of 1034// the request. If the caller is not the new_assignee, 1035// ForceIncidentRoleHandover should be used instead. 1036func (c *IncidentClient) ConfirmIncidentRoleHandover(ctx context.Context, req *irmpb.ConfirmIncidentRoleHandoverRequest, opts ...gax.CallOption) (*irmpb.IncidentRoleAssignment, error) { 1037 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1038 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1039 opts = append(c.CallOptions.ConfirmIncidentRoleHandover[0:len(c.CallOptions.ConfirmIncidentRoleHandover):len(c.CallOptions.ConfirmIncidentRoleHandover)], opts...) 1040 var resp *irmpb.IncidentRoleAssignment 1041 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1042 var err error 1043 resp, err = c.incidentClient.ConfirmIncidentRoleHandover(ctx, req, settings.GRPC...) 1044 return err 1045 }, opts...) 1046 if err != nil { 1047 return nil, err 1048 } 1049 return resp, nil 1050} 1051 1052// ForceIncidentRoleHandover forces a role handover. This will fail if the ‘proposed_assignee’ field of 1053// the IncidentRoleAssignment is not equal to the ‘new_assignee’ field of the 1054// request. If the caller is the new_assignee, ConfirmIncidentRoleHandover 1055// should be used instead. 1056func (c *IncidentClient) ForceIncidentRoleHandover(ctx context.Context, req *irmpb.ForceIncidentRoleHandoverRequest, opts ...gax.CallOption) (*irmpb.IncidentRoleAssignment, error) { 1057 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1058 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1059 opts = append(c.CallOptions.ForceIncidentRoleHandover[0:len(c.CallOptions.ForceIncidentRoleHandover):len(c.CallOptions.ForceIncidentRoleHandover)], opts...) 1060 var resp *irmpb.IncidentRoleAssignment 1061 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1062 var err error 1063 resp, err = c.incidentClient.ForceIncidentRoleHandover(ctx, req, settings.GRPC...) 1064 return err 1065 }, opts...) 1066 if err != nil { 1067 return nil, err 1068 } 1069 return resp, nil 1070} 1071 1072// CancelIncidentRoleHandover cancels a role handover. This will fail if the ‘proposed_assignee’ field of 1073// the IncidentRoleAssignment is not equal to the ‘new_assignee’ field of the 1074// request. 1075func (c *IncidentClient) CancelIncidentRoleHandover(ctx context.Context, req *irmpb.CancelIncidentRoleHandoverRequest, opts ...gax.CallOption) (*irmpb.IncidentRoleAssignment, error) { 1076 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1077 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1078 opts = append(c.CallOptions.CancelIncidentRoleHandover[0:len(c.CallOptions.CancelIncidentRoleHandover):len(c.CallOptions.CancelIncidentRoleHandover)], opts...) 1079 var resp *irmpb.IncidentRoleAssignment 1080 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1081 var err error 1082 resp, err = c.incidentClient.CancelIncidentRoleHandover(ctx, req, settings.GRPC...) 1083 return err 1084 }, opts...) 1085 if err != nil { 1086 return nil, err 1087 } 1088 return resp, nil 1089} 1090 1091// AnnotationIterator manages a stream of *irmpb.Annotation. 1092type AnnotationIterator struct { 1093 items []*irmpb.Annotation 1094 pageInfo *iterator.PageInfo 1095 nextFunc func() error 1096 1097 // Response is the raw response for the current page. 1098 // It must be cast to the RPC response type. 1099 // Calling Next() or InternalFetch() updates this value. 1100 Response interface{} 1101 1102 // InternalFetch is for use by the Google Cloud Libraries only. 1103 // It is not part of the stable interface of this package. 1104 // 1105 // InternalFetch returns results from a single call to the underlying RPC. 1106 // The number of results is no greater than pageSize. 1107 // If there are no more results, nextPageToken is empty and err is nil. 1108 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.Annotation, nextPageToken string, err error) 1109} 1110 1111// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1112func (it *AnnotationIterator) PageInfo() *iterator.PageInfo { 1113 return it.pageInfo 1114} 1115 1116// Next returns the next result. Its second return value is iterator.Done if there are no more 1117// results. Once Next returns Done, all subsequent calls will return Done. 1118func (it *AnnotationIterator) Next() (*irmpb.Annotation, error) { 1119 var item *irmpb.Annotation 1120 if err := it.nextFunc(); err != nil { 1121 return item, err 1122 } 1123 item = it.items[0] 1124 it.items = it.items[1:] 1125 return item, nil 1126} 1127 1128func (it *AnnotationIterator) bufLen() int { 1129 return len(it.items) 1130} 1131 1132func (it *AnnotationIterator) takeBuf() interface{} { 1133 b := it.items 1134 it.items = nil 1135 return b 1136} 1137 1138// ArtifactIterator manages a stream of *irmpb.Artifact. 1139type ArtifactIterator struct { 1140 items []*irmpb.Artifact 1141 pageInfo *iterator.PageInfo 1142 nextFunc func() error 1143 1144 // Response is the raw response for the current page. 1145 // It must be cast to the RPC response type. 1146 // Calling Next() or InternalFetch() updates this value. 1147 Response interface{} 1148 1149 // InternalFetch is for use by the Google Cloud Libraries only. 1150 // It is not part of the stable interface of this package. 1151 // 1152 // InternalFetch returns results from a single call to the underlying RPC. 1153 // The number of results is no greater than pageSize. 1154 // If there are no more results, nextPageToken is empty and err is nil. 1155 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.Artifact, nextPageToken string, err error) 1156} 1157 1158// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1159func (it *ArtifactIterator) PageInfo() *iterator.PageInfo { 1160 return it.pageInfo 1161} 1162 1163// Next returns the next result. Its second return value is iterator.Done if there are no more 1164// results. Once Next returns Done, all subsequent calls will return Done. 1165func (it *ArtifactIterator) Next() (*irmpb.Artifact, error) { 1166 var item *irmpb.Artifact 1167 if err := it.nextFunc(); err != nil { 1168 return item, err 1169 } 1170 item = it.items[0] 1171 it.items = it.items[1:] 1172 return item, nil 1173} 1174 1175func (it *ArtifactIterator) bufLen() int { 1176 return len(it.items) 1177} 1178 1179func (it *ArtifactIterator) takeBuf() interface{} { 1180 b := it.items 1181 it.items = nil 1182 return b 1183} 1184 1185// IncidentIterator manages a stream of *irmpb.Incident. 1186type IncidentIterator struct { 1187 items []*irmpb.Incident 1188 pageInfo *iterator.PageInfo 1189 nextFunc func() error 1190 1191 // Response is the raw response for the current page. 1192 // It must be cast to the RPC response type. 1193 // Calling Next() or InternalFetch() updates this value. 1194 Response interface{} 1195 1196 // InternalFetch is for use by the Google Cloud Libraries only. 1197 // It is not part of the stable interface of this package. 1198 // 1199 // InternalFetch returns results from a single call to the underlying RPC. 1200 // The number of results is no greater than pageSize. 1201 // If there are no more results, nextPageToken is empty and err is nil. 1202 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.Incident, nextPageToken string, err error) 1203} 1204 1205// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1206func (it *IncidentIterator) PageInfo() *iterator.PageInfo { 1207 return it.pageInfo 1208} 1209 1210// Next returns the next result. Its second return value is iterator.Done if there are no more 1211// results. Once Next returns Done, all subsequent calls will return Done. 1212func (it *IncidentIterator) Next() (*irmpb.Incident, error) { 1213 var item *irmpb.Incident 1214 if err := it.nextFunc(); err != nil { 1215 return item, err 1216 } 1217 item = it.items[0] 1218 it.items = it.items[1:] 1219 return item, nil 1220} 1221 1222func (it *IncidentIterator) bufLen() int { 1223 return len(it.items) 1224} 1225 1226func (it *IncidentIterator) takeBuf() interface{} { 1227 b := it.items 1228 it.items = nil 1229 return b 1230} 1231 1232// IncidentRoleAssignmentIterator manages a stream of *irmpb.IncidentRoleAssignment. 1233type IncidentRoleAssignmentIterator struct { 1234 items []*irmpb.IncidentRoleAssignment 1235 pageInfo *iterator.PageInfo 1236 nextFunc func() error 1237 1238 // Response is the raw response for the current page. 1239 // It must be cast to the RPC response type. 1240 // Calling Next() or InternalFetch() updates this value. 1241 Response interface{} 1242 1243 // InternalFetch is for use by the Google Cloud Libraries only. 1244 // It is not part of the stable interface of this package. 1245 // 1246 // InternalFetch returns results from a single call to the underlying RPC. 1247 // The number of results is no greater than pageSize. 1248 // If there are no more results, nextPageToken is empty and err is nil. 1249 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.IncidentRoleAssignment, nextPageToken string, err error) 1250} 1251 1252// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1253func (it *IncidentRoleAssignmentIterator) PageInfo() *iterator.PageInfo { 1254 return it.pageInfo 1255} 1256 1257// Next returns the next result. Its second return value is iterator.Done if there are no more 1258// results. Once Next returns Done, all subsequent calls will return Done. 1259func (it *IncidentRoleAssignmentIterator) Next() (*irmpb.IncidentRoleAssignment, error) { 1260 var item *irmpb.IncidentRoleAssignment 1261 if err := it.nextFunc(); err != nil { 1262 return item, err 1263 } 1264 item = it.items[0] 1265 it.items = it.items[1:] 1266 return item, nil 1267} 1268 1269func (it *IncidentRoleAssignmentIterator) bufLen() int { 1270 return len(it.items) 1271} 1272 1273func (it *IncidentRoleAssignmentIterator) takeBuf() interface{} { 1274 b := it.items 1275 it.items = nil 1276 return b 1277} 1278 1279// SearchSimilarIncidentsResponse_ResultIterator manages a stream of *irmpb.SearchSimilarIncidentsResponse_Result. 1280type SearchSimilarIncidentsResponse_ResultIterator struct { 1281 items []*irmpb.SearchSimilarIncidentsResponse_Result 1282 pageInfo *iterator.PageInfo 1283 nextFunc func() error 1284 1285 // Response is the raw response for the current page. 1286 // It must be cast to the RPC response type. 1287 // Calling Next() or InternalFetch() updates this value. 1288 Response interface{} 1289 1290 // InternalFetch is for use by the Google Cloud Libraries only. 1291 // It is not part of the stable interface of this package. 1292 // 1293 // InternalFetch returns results from a single call to the underlying RPC. 1294 // The number of results is no greater than pageSize. 1295 // If there are no more results, nextPageToken is empty and err is nil. 1296 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.SearchSimilarIncidentsResponse_Result, nextPageToken string, err error) 1297} 1298 1299// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1300func (it *SearchSimilarIncidentsResponse_ResultIterator) PageInfo() *iterator.PageInfo { 1301 return it.pageInfo 1302} 1303 1304// Next returns the next result. Its second return value is iterator.Done if there are no more 1305// results. Once Next returns Done, all subsequent calls will return Done. 1306func (it *SearchSimilarIncidentsResponse_ResultIterator) Next() (*irmpb.SearchSimilarIncidentsResponse_Result, error) { 1307 var item *irmpb.SearchSimilarIncidentsResponse_Result 1308 if err := it.nextFunc(); err != nil { 1309 return item, err 1310 } 1311 item = it.items[0] 1312 it.items = it.items[1:] 1313 return item, nil 1314} 1315 1316func (it *SearchSimilarIncidentsResponse_ResultIterator) bufLen() int { 1317 return len(it.items) 1318} 1319 1320func (it *SearchSimilarIncidentsResponse_ResultIterator) takeBuf() interface{} { 1321 b := it.items 1322 it.items = nil 1323 return b 1324} 1325 1326// SignalIterator manages a stream of *irmpb.Signal. 1327type SignalIterator struct { 1328 items []*irmpb.Signal 1329 pageInfo *iterator.PageInfo 1330 nextFunc func() error 1331 1332 // Response is the raw response for the current page. 1333 // It must be cast to the RPC response type. 1334 // Calling Next() or InternalFetch() updates this value. 1335 Response interface{} 1336 1337 // InternalFetch is for use by the Google Cloud Libraries only. 1338 // It is not part of the stable interface of this package. 1339 // 1340 // InternalFetch returns results from a single call to the underlying RPC. 1341 // The number of results is no greater than pageSize. 1342 // If there are no more results, nextPageToken is empty and err is nil. 1343 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.Signal, nextPageToken string, err error) 1344} 1345 1346// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1347func (it *SignalIterator) PageInfo() *iterator.PageInfo { 1348 return it.pageInfo 1349} 1350 1351// Next returns the next result. Its second return value is iterator.Done if there are no more 1352// results. Once Next returns Done, all subsequent calls will return Done. 1353func (it *SignalIterator) Next() (*irmpb.Signal, error) { 1354 var item *irmpb.Signal 1355 if err := it.nextFunc(); err != nil { 1356 return item, err 1357 } 1358 item = it.items[0] 1359 it.items = it.items[1:] 1360 return item, nil 1361} 1362 1363func (it *SignalIterator) bufLen() int { 1364 return len(it.items) 1365} 1366 1367func (it *SignalIterator) takeBuf() interface{} { 1368 b := it.items 1369 it.items = nil 1370 return b 1371} 1372 1373// SubscriptionIterator manages a stream of *irmpb.Subscription. 1374type SubscriptionIterator struct { 1375 items []*irmpb.Subscription 1376 pageInfo *iterator.PageInfo 1377 nextFunc func() error 1378 1379 // Response is the raw response for the current page. 1380 // It must be cast to the RPC response type. 1381 // Calling Next() or InternalFetch() updates this value. 1382 Response interface{} 1383 1384 // InternalFetch is for use by the Google Cloud Libraries only. 1385 // It is not part of the stable interface of this package. 1386 // 1387 // InternalFetch returns results from a single call to the underlying RPC. 1388 // The number of results is no greater than pageSize. 1389 // If there are no more results, nextPageToken is empty and err is nil. 1390 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.Subscription, nextPageToken string, err error) 1391} 1392 1393// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1394func (it *SubscriptionIterator) PageInfo() *iterator.PageInfo { 1395 return it.pageInfo 1396} 1397 1398// Next returns the next result. Its second return value is iterator.Done if there are no more 1399// results. Once Next returns Done, all subsequent calls will return Done. 1400func (it *SubscriptionIterator) Next() (*irmpb.Subscription, error) { 1401 var item *irmpb.Subscription 1402 if err := it.nextFunc(); err != nil { 1403 return item, err 1404 } 1405 item = it.items[0] 1406 it.items = it.items[1:] 1407 return item, nil 1408} 1409 1410func (it *SubscriptionIterator) bufLen() int { 1411 return len(it.items) 1412} 1413 1414func (it *SubscriptionIterator) takeBuf() interface{} { 1415 b := it.items 1416 it.items = nil 1417 return b 1418} 1419 1420// TagIterator manages a stream of *irmpb.Tag. 1421type TagIterator struct { 1422 items []*irmpb.Tag 1423 pageInfo *iterator.PageInfo 1424 nextFunc func() error 1425 1426 // Response is the raw response for the current page. 1427 // It must be cast to the RPC response type. 1428 // Calling Next() or InternalFetch() updates this value. 1429 Response interface{} 1430 1431 // InternalFetch is for use by the Google Cloud Libraries only. 1432 // It is not part of the stable interface of this package. 1433 // 1434 // InternalFetch returns results from a single call to the underlying RPC. 1435 // The number of results is no greater than pageSize. 1436 // If there are no more results, nextPageToken is empty and err is nil. 1437 InternalFetch func(pageSize int, pageToken string) (results []*irmpb.Tag, nextPageToken string, err error) 1438} 1439 1440// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1441func (it *TagIterator) PageInfo() *iterator.PageInfo { 1442 return it.pageInfo 1443} 1444 1445// Next returns the next result. Its second return value is iterator.Done if there are no more 1446// results. Once Next returns Done, all subsequent calls will return Done. 1447func (it *TagIterator) Next() (*irmpb.Tag, error) { 1448 var item *irmpb.Tag 1449 if err := it.nextFunc(); err != nil { 1450 return item, err 1451 } 1452 item = it.items[0] 1453 it.items = it.items[1:] 1454 return item, nil 1455} 1456 1457func (it *TagIterator) bufLen() int { 1458 return len(it.items) 1459} 1460 1461func (it *TagIterator) takeBuf() interface{} { 1462 b := it.items 1463 it.items = nil 1464 return b 1465} 1466