1// Copyright 2021 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 admin 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 "google.golang.org/api/option/internaloption" 31 gtransport "google.golang.org/api/transport/grpc" 32 adminpb "google.golang.org/genproto/googleapis/analytics/admin/v1alpha" 33 "google.golang.org/grpc" 34 "google.golang.org/grpc/codes" 35 "google.golang.org/grpc/metadata" 36) 37 38var newAnalyticsAdminClientHook clientHook 39 40// AnalyticsAdminCallOptions contains the retry settings for each method of AnalyticsAdminClient. 41type AnalyticsAdminCallOptions struct { 42 GetAccount []gax.CallOption 43 ListAccounts []gax.CallOption 44 DeleteAccount []gax.CallOption 45 UpdateAccount []gax.CallOption 46 ProvisionAccountTicket []gax.CallOption 47 ListAccountSummaries []gax.CallOption 48 GetProperty []gax.CallOption 49 ListProperties []gax.CallOption 50 CreateProperty []gax.CallOption 51 DeleteProperty []gax.CallOption 52 UpdateProperty []gax.CallOption 53 GetUserLink []gax.CallOption 54 BatchGetUserLinks []gax.CallOption 55 ListUserLinks []gax.CallOption 56 AuditUserLinks []gax.CallOption 57 CreateUserLink []gax.CallOption 58 BatchCreateUserLinks []gax.CallOption 59 UpdateUserLink []gax.CallOption 60 BatchUpdateUserLinks []gax.CallOption 61 DeleteUserLink []gax.CallOption 62 BatchDeleteUserLinks []gax.CallOption 63 GetWebDataStream []gax.CallOption 64 DeleteWebDataStream []gax.CallOption 65 UpdateWebDataStream []gax.CallOption 66 CreateWebDataStream []gax.CallOption 67 ListWebDataStreams []gax.CallOption 68 GetIosAppDataStream []gax.CallOption 69 DeleteIosAppDataStream []gax.CallOption 70 UpdateIosAppDataStream []gax.CallOption 71 CreateIosAppDataStream []gax.CallOption 72 ListIosAppDataStreams []gax.CallOption 73 GetAndroidAppDataStream []gax.CallOption 74 DeleteAndroidAppDataStream []gax.CallOption 75 UpdateAndroidAppDataStream []gax.CallOption 76 CreateAndroidAppDataStream []gax.CallOption 77 ListAndroidAppDataStreams []gax.CallOption 78 GetEnhancedMeasurementSettings []gax.CallOption 79 UpdateEnhancedMeasurementSettings []gax.CallOption 80 CreateFirebaseLink []gax.CallOption 81 UpdateFirebaseLink []gax.CallOption 82 DeleteFirebaseLink []gax.CallOption 83 ListFirebaseLinks []gax.CallOption 84 GetGlobalSiteTag []gax.CallOption 85 CreateGoogleAdsLink []gax.CallOption 86 UpdateGoogleAdsLink []gax.CallOption 87 DeleteGoogleAdsLink []gax.CallOption 88 ListGoogleAdsLinks []gax.CallOption 89 GetDataSharingSettings []gax.CallOption 90} 91 92func defaultAnalyticsAdminClientOptions() []option.ClientOption { 93 return []option.ClientOption{ 94 internaloption.WithDefaultEndpoint("analyticsadmin.googleapis.com:443"), 95 internaloption.WithDefaultMTLSEndpoint("analyticsadmin.mtls.googleapis.com:443"), 96 internaloption.WithDefaultAudience("https://analyticsadmin.googleapis.com/"), 97 internaloption.WithDefaultScopes(DefaultAuthScopes()...), 98 option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), 99 option.WithGRPCDialOption(grpc.WithDefaultCallOptions( 100 grpc.MaxCallRecvMsgSize(math.MaxInt32))), 101 } 102} 103 104func defaultAnalyticsAdminCallOptions() *AnalyticsAdminCallOptions { 105 return &AnalyticsAdminCallOptions{ 106 GetAccount: []gax.CallOption{}, 107 ListAccounts: []gax.CallOption{}, 108 DeleteAccount: []gax.CallOption{}, 109 UpdateAccount: []gax.CallOption{}, 110 ProvisionAccountTicket: []gax.CallOption{}, 111 ListAccountSummaries: []gax.CallOption{ 112 gax.WithRetry(func() gax.Retryer { 113 return gax.OnCodes([]codes.Code{ 114 codes.Unavailable, 115 codes.Unknown, 116 }, gax.Backoff{ 117 Initial: 1000 * time.Millisecond, 118 Max: 60000 * time.Millisecond, 119 Multiplier: 1.30, 120 }) 121 }), 122 }, 123 GetProperty: []gax.CallOption{}, 124 ListProperties: []gax.CallOption{}, 125 CreateProperty: []gax.CallOption{}, 126 DeleteProperty: []gax.CallOption{}, 127 UpdateProperty: []gax.CallOption{}, 128 GetUserLink: []gax.CallOption{}, 129 BatchGetUserLinks: []gax.CallOption{}, 130 ListUserLinks: []gax.CallOption{}, 131 AuditUserLinks: []gax.CallOption{}, 132 CreateUserLink: []gax.CallOption{}, 133 BatchCreateUserLinks: []gax.CallOption{}, 134 UpdateUserLink: []gax.CallOption{}, 135 BatchUpdateUserLinks: []gax.CallOption{}, 136 DeleteUserLink: []gax.CallOption{}, 137 BatchDeleteUserLinks: []gax.CallOption{}, 138 GetWebDataStream: []gax.CallOption{}, 139 DeleteWebDataStream: []gax.CallOption{ 140 gax.WithRetry(func() gax.Retryer { 141 return gax.OnCodes([]codes.Code{ 142 codes.Unavailable, 143 codes.Unknown, 144 }, gax.Backoff{ 145 Initial: 1000 * time.Millisecond, 146 Max: 60000 * time.Millisecond, 147 Multiplier: 1.30, 148 }) 149 }), 150 }, 151 UpdateWebDataStream: []gax.CallOption{}, 152 CreateWebDataStream: []gax.CallOption{}, 153 ListWebDataStreams: []gax.CallOption{}, 154 GetIosAppDataStream: []gax.CallOption{}, 155 DeleteIosAppDataStream: []gax.CallOption{}, 156 UpdateIosAppDataStream: []gax.CallOption{}, 157 CreateIosAppDataStream: []gax.CallOption{}, 158 ListIosAppDataStreams: []gax.CallOption{}, 159 GetAndroidAppDataStream: []gax.CallOption{}, 160 DeleteAndroidAppDataStream: []gax.CallOption{}, 161 UpdateAndroidAppDataStream: []gax.CallOption{}, 162 CreateAndroidAppDataStream: []gax.CallOption{}, 163 ListAndroidAppDataStreams: []gax.CallOption{}, 164 GetEnhancedMeasurementSettings: []gax.CallOption{}, 165 UpdateEnhancedMeasurementSettings: []gax.CallOption{}, 166 CreateFirebaseLink: []gax.CallOption{}, 167 UpdateFirebaseLink: []gax.CallOption{}, 168 DeleteFirebaseLink: []gax.CallOption{}, 169 ListFirebaseLinks: []gax.CallOption{}, 170 GetGlobalSiteTag: []gax.CallOption{}, 171 CreateGoogleAdsLink: []gax.CallOption{}, 172 UpdateGoogleAdsLink: []gax.CallOption{}, 173 DeleteGoogleAdsLink: []gax.CallOption{}, 174 ListGoogleAdsLinks: []gax.CallOption{}, 175 GetDataSharingSettings: []gax.CallOption{ 176 gax.WithRetry(func() gax.Retryer { 177 return gax.OnCodes([]codes.Code{ 178 codes.Unavailable, 179 codes.Unknown, 180 }, gax.Backoff{ 181 Initial: 1000 * time.Millisecond, 182 Max: 60000 * time.Millisecond, 183 Multiplier: 1.30, 184 }) 185 }), 186 }, 187 } 188} 189 190// AnalyticsAdminClient is a client for interacting with Google Analytics Admin API. 191// 192// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. 193type AnalyticsAdminClient struct { 194 // Connection pool of gRPC connections to the service. 195 connPool gtransport.ConnPool 196 197 // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE 198 disableDeadlines bool 199 200 // The gRPC API client. 201 analyticsAdminClient adminpb.AnalyticsAdminServiceClient 202 203 // The call options for this service. 204 CallOptions *AnalyticsAdminCallOptions 205 206 // The x-goog-* metadata to be sent with each request. 207 xGoogMetadata metadata.MD 208} 209 210// NewAnalyticsAdminClient creates a new analytics admin service client. 211// 212// Service Interface for the Analytics Admin API (GA4). 213func NewAnalyticsAdminClient(ctx context.Context, opts ...option.ClientOption) (*AnalyticsAdminClient, error) { 214 clientOpts := defaultAnalyticsAdminClientOptions() 215 216 if newAnalyticsAdminClientHook != nil { 217 hookOpts, err := newAnalyticsAdminClientHook(ctx, clientHookParams{}) 218 if err != nil { 219 return nil, err 220 } 221 clientOpts = append(clientOpts, hookOpts...) 222 } 223 224 disableDeadlines, err := checkDisableDeadlines() 225 if err != nil { 226 return nil, err 227 } 228 229 connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) 230 if err != nil { 231 return nil, err 232 } 233 c := &AnalyticsAdminClient{ 234 connPool: connPool, 235 disableDeadlines: disableDeadlines, 236 CallOptions: defaultAnalyticsAdminCallOptions(), 237 238 analyticsAdminClient: adminpb.NewAnalyticsAdminServiceClient(connPool), 239 } 240 c.setGoogleClientInfo() 241 242 return c, nil 243} 244 245// Connection returns a connection to the API service. 246// 247// Deprecated. 248func (c *AnalyticsAdminClient) Connection() *grpc.ClientConn { 249 return c.connPool.Conn() 250} 251 252// Close closes the connection to the API service. The user should invoke this when 253// the client is no longer required. 254func (c *AnalyticsAdminClient) Close() error { 255 return c.connPool.Close() 256} 257 258// setGoogleClientInfo sets the name and version of the application in 259// the `x-goog-api-client` header passed on each request. Intended for 260// use by Google-written clients. 261func (c *AnalyticsAdminClient) setGoogleClientInfo(keyval ...string) { 262 kv := append([]string{"gl-go", versionGo()}, keyval...) 263 kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) 264 c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) 265} 266 267// GetAccount lookup for a single Account. 268func (c *AnalyticsAdminClient) GetAccount(ctx context.Context, req *adminpb.GetAccountRequest, opts ...gax.CallOption) (*adminpb.Account, error) { 269 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 270 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 271 defer cancel() 272 ctx = cctx 273 } 274 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 275 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 276 opts = append(c.CallOptions.GetAccount[0:len(c.CallOptions.GetAccount):len(c.CallOptions.GetAccount)], opts...) 277 var resp *adminpb.Account 278 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 279 var err error 280 resp, err = c.analyticsAdminClient.GetAccount(ctx, req, settings.GRPC...) 281 return err 282 }, opts...) 283 if err != nil { 284 return nil, err 285 } 286 return resp, nil 287} 288 289// ListAccounts returns all accounts accessible by the caller. 290// 291// Note that these accounts might not currently have GA4 properties. 292// Soft-deleted (ie: “trashed”) accounts are excluded by default. 293// Returns an empty list if no relevant accounts are found. 294func (c *AnalyticsAdminClient) ListAccounts(ctx context.Context, req *adminpb.ListAccountsRequest, opts ...gax.CallOption) *AccountIterator { 295 ctx = insertMetadata(ctx, c.xGoogMetadata) 296 opts = append(c.CallOptions.ListAccounts[0:len(c.CallOptions.ListAccounts):len(c.CallOptions.ListAccounts)], opts...) 297 it := &AccountIterator{} 298 req = proto.Clone(req).(*adminpb.ListAccountsRequest) 299 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.Account, string, error) { 300 var resp *adminpb.ListAccountsResponse 301 req.PageToken = pageToken 302 if pageSize > math.MaxInt32 { 303 req.PageSize = math.MaxInt32 304 } else { 305 req.PageSize = int32(pageSize) 306 } 307 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 308 var err error 309 resp, err = c.analyticsAdminClient.ListAccounts(ctx, req, settings.GRPC...) 310 return err 311 }, opts...) 312 if err != nil { 313 return nil, "", err 314 } 315 316 it.Response = resp 317 return resp.GetAccounts(), resp.GetNextPageToken(), nil 318 } 319 fetch := func(pageSize int, pageToken string) (string, error) { 320 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 321 if err != nil { 322 return "", err 323 } 324 it.items = append(it.items, items...) 325 return nextPageToken, nil 326 } 327 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 328 it.pageInfo.MaxSize = int(req.GetPageSize()) 329 it.pageInfo.Token = req.GetPageToken() 330 return it 331} 332 333// DeleteAccount marks target Account as soft-deleted (ie: “trashed”) and returns it. 334// 335// This API does not have a method to restore soft-deleted accounts. 336// However, they can be restored using the Trash Can UI. 337// 338// If the accounts are not restored before the expiration time, the account 339// and all child resources (eg: Properties, GoogleAdsLinks, Streams, 340// UserLinks) will be permanently purged. 341// https://support.google.com/analytics/answer/6154772 (at https://support.google.com/analytics/answer/6154772) 342// 343// Returns an error if the target is not found. 344func (c *AnalyticsAdminClient) DeleteAccount(ctx context.Context, req *adminpb.DeleteAccountRequest, opts ...gax.CallOption) error { 345 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 346 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 347 defer cancel() 348 ctx = cctx 349 } 350 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 351 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 352 opts = append(c.CallOptions.DeleteAccount[0:len(c.CallOptions.DeleteAccount):len(c.CallOptions.DeleteAccount)], opts...) 353 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 354 var err error 355 _, err = c.analyticsAdminClient.DeleteAccount(ctx, req, settings.GRPC...) 356 return err 357 }, opts...) 358 return err 359} 360 361// UpdateAccount updates an account. 362func (c *AnalyticsAdminClient) UpdateAccount(ctx context.Context, req *adminpb.UpdateAccountRequest, opts ...gax.CallOption) (*adminpb.Account, error) { 363 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 364 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 365 defer cancel() 366 ctx = cctx 367 } 368 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "account.name", url.QueryEscape(req.GetAccount().GetName()))) 369 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 370 opts = append(c.CallOptions.UpdateAccount[0:len(c.CallOptions.UpdateAccount):len(c.CallOptions.UpdateAccount)], opts...) 371 var resp *adminpb.Account 372 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 373 var err error 374 resp, err = c.analyticsAdminClient.UpdateAccount(ctx, req, settings.GRPC...) 375 return err 376 }, opts...) 377 if err != nil { 378 return nil, err 379 } 380 return resp, nil 381} 382 383// ProvisionAccountTicket requests a ticket for creating an account. 384func (c *AnalyticsAdminClient) ProvisionAccountTicket(ctx context.Context, req *adminpb.ProvisionAccountTicketRequest, opts ...gax.CallOption) (*adminpb.ProvisionAccountTicketResponse, error) { 385 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 386 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 387 defer cancel() 388 ctx = cctx 389 } 390 ctx = insertMetadata(ctx, c.xGoogMetadata) 391 opts = append(c.CallOptions.ProvisionAccountTicket[0:len(c.CallOptions.ProvisionAccountTicket):len(c.CallOptions.ProvisionAccountTicket)], opts...) 392 var resp *adminpb.ProvisionAccountTicketResponse 393 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 394 var err error 395 resp, err = c.analyticsAdminClient.ProvisionAccountTicket(ctx, req, settings.GRPC...) 396 return err 397 }, opts...) 398 if err != nil { 399 return nil, err 400 } 401 return resp, nil 402} 403 404// ListAccountSummaries returns summaries of all accounts accessible by the caller. 405func (c *AnalyticsAdminClient) ListAccountSummaries(ctx context.Context, req *adminpb.ListAccountSummariesRequest, opts ...gax.CallOption) *AccountSummaryIterator { 406 ctx = insertMetadata(ctx, c.xGoogMetadata) 407 opts = append(c.CallOptions.ListAccountSummaries[0:len(c.CallOptions.ListAccountSummaries):len(c.CallOptions.ListAccountSummaries)], opts...) 408 it := &AccountSummaryIterator{} 409 req = proto.Clone(req).(*adminpb.ListAccountSummariesRequest) 410 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.AccountSummary, string, error) { 411 var resp *adminpb.ListAccountSummariesResponse 412 req.PageToken = pageToken 413 if pageSize > math.MaxInt32 { 414 req.PageSize = math.MaxInt32 415 } else { 416 req.PageSize = int32(pageSize) 417 } 418 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 419 var err error 420 resp, err = c.analyticsAdminClient.ListAccountSummaries(ctx, req, settings.GRPC...) 421 return err 422 }, opts...) 423 if err != nil { 424 return nil, "", err 425 } 426 427 it.Response = resp 428 return resp.GetAccountSummaries(), resp.GetNextPageToken(), nil 429 } 430 fetch := func(pageSize int, pageToken string) (string, error) { 431 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 432 if err != nil { 433 return "", err 434 } 435 it.items = append(it.items, items...) 436 return nextPageToken, nil 437 } 438 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 439 it.pageInfo.MaxSize = int(req.GetPageSize()) 440 it.pageInfo.Token = req.GetPageToken() 441 return it 442} 443 444// GetProperty lookup for a single “GA4” Property. 445func (c *AnalyticsAdminClient) GetProperty(ctx context.Context, req *adminpb.GetPropertyRequest, opts ...gax.CallOption) (*adminpb.Property, error) { 446 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 447 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 448 defer cancel() 449 ctx = cctx 450 } 451 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 452 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 453 opts = append(c.CallOptions.GetProperty[0:len(c.CallOptions.GetProperty):len(c.CallOptions.GetProperty)], opts...) 454 var resp *adminpb.Property 455 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 456 var err error 457 resp, err = c.analyticsAdminClient.GetProperty(ctx, req, settings.GRPC...) 458 return err 459 }, opts...) 460 if err != nil { 461 return nil, err 462 } 463 return resp, nil 464} 465 466// ListProperties returns child Properties under the specified parent Account. 467// 468// Only “GA4” properties will be returned. 469// Properties will be excluded if the caller does not have access. 470// Soft-deleted (ie: “trashed”) properties are excluded by default. 471// Returns an empty list if no relevant properties are found. 472func (c *AnalyticsAdminClient) ListProperties(ctx context.Context, req *adminpb.ListPropertiesRequest, opts ...gax.CallOption) *PropertyIterator { 473 ctx = insertMetadata(ctx, c.xGoogMetadata) 474 opts = append(c.CallOptions.ListProperties[0:len(c.CallOptions.ListProperties):len(c.CallOptions.ListProperties)], opts...) 475 it := &PropertyIterator{} 476 req = proto.Clone(req).(*adminpb.ListPropertiesRequest) 477 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.Property, string, error) { 478 var resp *adminpb.ListPropertiesResponse 479 req.PageToken = pageToken 480 if pageSize > math.MaxInt32 { 481 req.PageSize = math.MaxInt32 482 } else { 483 req.PageSize = int32(pageSize) 484 } 485 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 486 var err error 487 resp, err = c.analyticsAdminClient.ListProperties(ctx, req, settings.GRPC...) 488 return err 489 }, opts...) 490 if err != nil { 491 return nil, "", err 492 } 493 494 it.Response = resp 495 return resp.GetProperties(), resp.GetNextPageToken(), nil 496 } 497 fetch := func(pageSize int, pageToken string) (string, error) { 498 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 499 if err != nil { 500 return "", err 501 } 502 it.items = append(it.items, items...) 503 return nextPageToken, nil 504 } 505 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 506 it.pageInfo.MaxSize = int(req.GetPageSize()) 507 it.pageInfo.Token = req.GetPageToken() 508 return it 509} 510 511// CreateProperty creates an “GA4” property with the specified location and attributes. 512func (c *AnalyticsAdminClient) CreateProperty(ctx context.Context, req *adminpb.CreatePropertyRequest, opts ...gax.CallOption) (*adminpb.Property, error) { 513 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 514 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 515 defer cancel() 516 ctx = cctx 517 } 518 ctx = insertMetadata(ctx, c.xGoogMetadata) 519 opts = append(c.CallOptions.CreateProperty[0:len(c.CallOptions.CreateProperty):len(c.CallOptions.CreateProperty)], opts...) 520 var resp *adminpb.Property 521 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 522 var err error 523 resp, err = c.analyticsAdminClient.CreateProperty(ctx, req, settings.GRPC...) 524 return err 525 }, opts...) 526 if err != nil { 527 return nil, err 528 } 529 return resp, nil 530} 531 532// DeleteProperty marks target Property as soft-deleted (ie: “trashed”) and returns it. 533// 534// This API does not have a method to restore soft-deleted properties. 535// However, they can be restored using the Trash Can UI. 536// 537// If the properties are not restored before the expiration time, the Property 538// and all child resources (eg: GoogleAdsLinks, Streams, UserLinks) 539// will be permanently purged. 540// https://support.google.com/analytics/answer/6154772 (at https://support.google.com/analytics/answer/6154772) 541// 542// Returns an error if the target is not found, or is not an GA4 Property. 543func (c *AnalyticsAdminClient) DeleteProperty(ctx context.Context, req *adminpb.DeletePropertyRequest, opts ...gax.CallOption) error { 544 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 545 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 546 defer cancel() 547 ctx = cctx 548 } 549 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 550 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 551 opts = append(c.CallOptions.DeleteProperty[0:len(c.CallOptions.DeleteProperty):len(c.CallOptions.DeleteProperty)], opts...) 552 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 553 var err error 554 _, err = c.analyticsAdminClient.DeleteProperty(ctx, req, settings.GRPC...) 555 return err 556 }, opts...) 557 return err 558} 559 560// UpdateProperty updates a property. 561func (c *AnalyticsAdminClient) UpdateProperty(ctx context.Context, req *adminpb.UpdatePropertyRequest, opts ...gax.CallOption) (*adminpb.Property, error) { 562 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 563 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 564 defer cancel() 565 ctx = cctx 566 } 567 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "property.name", url.QueryEscape(req.GetProperty().GetName()))) 568 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 569 opts = append(c.CallOptions.UpdateProperty[0:len(c.CallOptions.UpdateProperty):len(c.CallOptions.UpdateProperty)], opts...) 570 var resp *adminpb.Property 571 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 572 var err error 573 resp, err = c.analyticsAdminClient.UpdateProperty(ctx, req, settings.GRPC...) 574 return err 575 }, opts...) 576 if err != nil { 577 return nil, err 578 } 579 return resp, nil 580} 581 582// GetUserLink gets information about a user’s link to an account or property. 583func (c *AnalyticsAdminClient) GetUserLink(ctx context.Context, req *adminpb.GetUserLinkRequest, opts ...gax.CallOption) (*adminpb.UserLink, error) { 584 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 585 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 586 defer cancel() 587 ctx = cctx 588 } 589 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 590 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 591 opts = append(c.CallOptions.GetUserLink[0:len(c.CallOptions.GetUserLink):len(c.CallOptions.GetUserLink)], opts...) 592 var resp *adminpb.UserLink 593 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 594 var err error 595 resp, err = c.analyticsAdminClient.GetUserLink(ctx, req, settings.GRPC...) 596 return err 597 }, opts...) 598 if err != nil { 599 return nil, err 600 } 601 return resp, nil 602} 603 604// BatchGetUserLinks gets information about multiple users’ links to an account or property. 605func (c *AnalyticsAdminClient) BatchGetUserLinks(ctx context.Context, req *adminpb.BatchGetUserLinksRequest, opts ...gax.CallOption) (*adminpb.BatchGetUserLinksResponse, error) { 606 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 607 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 608 defer cancel() 609 ctx = cctx 610 } 611 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 612 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 613 opts = append(c.CallOptions.BatchGetUserLinks[0:len(c.CallOptions.BatchGetUserLinks):len(c.CallOptions.BatchGetUserLinks)], opts...) 614 var resp *adminpb.BatchGetUserLinksResponse 615 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 616 var err error 617 resp, err = c.analyticsAdminClient.BatchGetUserLinks(ctx, req, settings.GRPC...) 618 return err 619 }, opts...) 620 if err != nil { 621 return nil, err 622 } 623 return resp, nil 624} 625 626// ListUserLinks lists all user links on an account or property. 627func (c *AnalyticsAdminClient) ListUserLinks(ctx context.Context, req *adminpb.ListUserLinksRequest, opts ...gax.CallOption) *UserLinkIterator { 628 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 629 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 630 opts = append(c.CallOptions.ListUserLinks[0:len(c.CallOptions.ListUserLinks):len(c.CallOptions.ListUserLinks)], opts...) 631 it := &UserLinkIterator{} 632 req = proto.Clone(req).(*adminpb.ListUserLinksRequest) 633 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.UserLink, string, error) { 634 var resp *adminpb.ListUserLinksResponse 635 req.PageToken = pageToken 636 if pageSize > math.MaxInt32 { 637 req.PageSize = math.MaxInt32 638 } else { 639 req.PageSize = int32(pageSize) 640 } 641 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 642 var err error 643 resp, err = c.analyticsAdminClient.ListUserLinks(ctx, req, settings.GRPC...) 644 return err 645 }, opts...) 646 if err != nil { 647 return nil, "", err 648 } 649 650 it.Response = resp 651 return resp.GetUserLinks(), resp.GetNextPageToken(), nil 652 } 653 fetch := func(pageSize int, pageToken string) (string, error) { 654 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 655 if err != nil { 656 return "", err 657 } 658 it.items = append(it.items, items...) 659 return nextPageToken, nil 660 } 661 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 662 it.pageInfo.MaxSize = int(req.GetPageSize()) 663 it.pageInfo.Token = req.GetPageToken() 664 return it 665} 666 667// AuditUserLinks lists all user links on an account or property, including implicit ones 668// that come from effective permissions granted by groups or organization 669// admin roles. 670// 671// If a returned user link does not have direct permissions, they cannot 672// be removed from the account or property directly with the DeleteUserLink 673// command. They have to be removed from the group/etc that gives them 674// permissions, which is currently only usable/discoverable in the GA or GMP 675// UIs. 676func (c *AnalyticsAdminClient) AuditUserLinks(ctx context.Context, req *adminpb.AuditUserLinksRequest, opts ...gax.CallOption) *AuditUserLinkIterator { 677 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 678 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 679 opts = append(c.CallOptions.AuditUserLinks[0:len(c.CallOptions.AuditUserLinks):len(c.CallOptions.AuditUserLinks)], opts...) 680 it := &AuditUserLinkIterator{} 681 req = proto.Clone(req).(*adminpb.AuditUserLinksRequest) 682 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.AuditUserLink, string, error) { 683 var resp *adminpb.AuditUserLinksResponse 684 req.PageToken = pageToken 685 if pageSize > math.MaxInt32 { 686 req.PageSize = math.MaxInt32 687 } else { 688 req.PageSize = int32(pageSize) 689 } 690 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 691 var err error 692 resp, err = c.analyticsAdminClient.AuditUserLinks(ctx, req, settings.GRPC...) 693 return err 694 }, opts...) 695 if err != nil { 696 return nil, "", err 697 } 698 699 it.Response = resp 700 return resp.GetUserLinks(), resp.GetNextPageToken(), nil 701 } 702 fetch := func(pageSize int, pageToken string) (string, error) { 703 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 704 if err != nil { 705 return "", err 706 } 707 it.items = append(it.items, items...) 708 return nextPageToken, nil 709 } 710 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 711 it.pageInfo.MaxSize = int(req.GetPageSize()) 712 it.pageInfo.Token = req.GetPageToken() 713 return it 714} 715 716// CreateUserLink creates a user link on an account or property. 717// 718// If the user with the specified email already has permissions on the 719// account or property, then the user’s existing permissions will be unioned 720// with the permissions specified in the new UserLink. 721func (c *AnalyticsAdminClient) CreateUserLink(ctx context.Context, req *adminpb.CreateUserLinkRequest, opts ...gax.CallOption) (*adminpb.UserLink, error) { 722 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 723 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 724 defer cancel() 725 ctx = cctx 726 } 727 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 728 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 729 opts = append(c.CallOptions.CreateUserLink[0:len(c.CallOptions.CreateUserLink):len(c.CallOptions.CreateUserLink)], opts...) 730 var resp *adminpb.UserLink 731 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 732 var err error 733 resp, err = c.analyticsAdminClient.CreateUserLink(ctx, req, settings.GRPC...) 734 return err 735 }, opts...) 736 if err != nil { 737 return nil, err 738 } 739 return resp, nil 740} 741 742// BatchCreateUserLinks creates information about multiple users’ links to an account or property. 743// 744// This method is transactional. If any UserLink cannot be created, none of 745// the UserLinks will be created. 746func (c *AnalyticsAdminClient) BatchCreateUserLinks(ctx context.Context, req *adminpb.BatchCreateUserLinksRequest, opts ...gax.CallOption) (*adminpb.BatchCreateUserLinksResponse, error) { 747 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 748 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 749 defer cancel() 750 ctx = cctx 751 } 752 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 753 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 754 opts = append(c.CallOptions.BatchCreateUserLinks[0:len(c.CallOptions.BatchCreateUserLinks):len(c.CallOptions.BatchCreateUserLinks)], opts...) 755 var resp *adminpb.BatchCreateUserLinksResponse 756 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 757 var err error 758 resp, err = c.analyticsAdminClient.BatchCreateUserLinks(ctx, req, settings.GRPC...) 759 return err 760 }, opts...) 761 if err != nil { 762 return nil, err 763 } 764 return resp, nil 765} 766 767// UpdateUserLink updates a user link on an account or property. 768func (c *AnalyticsAdminClient) UpdateUserLink(ctx context.Context, req *adminpb.UpdateUserLinkRequest, opts ...gax.CallOption) (*adminpb.UserLink, error) { 769 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 770 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 771 defer cancel() 772 ctx = cctx 773 } 774 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "user_link.name", url.QueryEscape(req.GetUserLink().GetName()))) 775 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 776 opts = append(c.CallOptions.UpdateUserLink[0:len(c.CallOptions.UpdateUserLink):len(c.CallOptions.UpdateUserLink)], opts...) 777 var resp *adminpb.UserLink 778 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 779 var err error 780 resp, err = c.analyticsAdminClient.UpdateUserLink(ctx, req, settings.GRPC...) 781 return err 782 }, opts...) 783 if err != nil { 784 return nil, err 785 } 786 return resp, nil 787} 788 789// BatchUpdateUserLinks updates information about multiple users’ links to an account or property. 790func (c *AnalyticsAdminClient) BatchUpdateUserLinks(ctx context.Context, req *adminpb.BatchUpdateUserLinksRequest, opts ...gax.CallOption) (*adminpb.BatchUpdateUserLinksResponse, error) { 791 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 792 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 793 defer cancel() 794 ctx = cctx 795 } 796 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 797 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 798 opts = append(c.CallOptions.BatchUpdateUserLinks[0:len(c.CallOptions.BatchUpdateUserLinks):len(c.CallOptions.BatchUpdateUserLinks)], opts...) 799 var resp *adminpb.BatchUpdateUserLinksResponse 800 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 801 var err error 802 resp, err = c.analyticsAdminClient.BatchUpdateUserLinks(ctx, req, settings.GRPC...) 803 return err 804 }, opts...) 805 if err != nil { 806 return nil, err 807 } 808 return resp, nil 809} 810 811// DeleteUserLink deletes a user link on an account or property. 812func (c *AnalyticsAdminClient) DeleteUserLink(ctx context.Context, req *adminpb.DeleteUserLinkRequest, opts ...gax.CallOption) error { 813 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 814 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 815 defer cancel() 816 ctx = cctx 817 } 818 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 819 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 820 opts = append(c.CallOptions.DeleteUserLink[0:len(c.CallOptions.DeleteUserLink):len(c.CallOptions.DeleteUserLink)], opts...) 821 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 822 var err error 823 _, err = c.analyticsAdminClient.DeleteUserLink(ctx, req, settings.GRPC...) 824 return err 825 }, opts...) 826 return err 827} 828 829// BatchDeleteUserLinks deletes information about multiple users’ links to an account or property. 830func (c *AnalyticsAdminClient) BatchDeleteUserLinks(ctx context.Context, req *adminpb.BatchDeleteUserLinksRequest, opts ...gax.CallOption) error { 831 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 832 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 833 defer cancel() 834 ctx = cctx 835 } 836 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 837 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 838 opts = append(c.CallOptions.BatchDeleteUserLinks[0:len(c.CallOptions.BatchDeleteUserLinks):len(c.CallOptions.BatchDeleteUserLinks)], opts...) 839 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 840 var err error 841 _, err = c.analyticsAdminClient.BatchDeleteUserLinks(ctx, req, settings.GRPC...) 842 return err 843 }, opts...) 844 return err 845} 846 847// GetWebDataStream lookup for a single WebDataStream 848func (c *AnalyticsAdminClient) GetWebDataStream(ctx context.Context, req *adminpb.GetWebDataStreamRequest, opts ...gax.CallOption) (*adminpb.WebDataStream, error) { 849 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 850 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 851 defer cancel() 852 ctx = cctx 853 } 854 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 855 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 856 opts = append(c.CallOptions.GetWebDataStream[0:len(c.CallOptions.GetWebDataStream):len(c.CallOptions.GetWebDataStream)], opts...) 857 var resp *adminpb.WebDataStream 858 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 859 var err error 860 resp, err = c.analyticsAdminClient.GetWebDataStream(ctx, req, settings.GRPC...) 861 return err 862 }, opts...) 863 if err != nil { 864 return nil, err 865 } 866 return resp, nil 867} 868 869// DeleteWebDataStream deletes a web stream on a property. 870func (c *AnalyticsAdminClient) DeleteWebDataStream(ctx context.Context, req *adminpb.DeleteWebDataStreamRequest, opts ...gax.CallOption) error { 871 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 872 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 873 defer cancel() 874 ctx = cctx 875 } 876 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 877 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 878 opts = append(c.CallOptions.DeleteWebDataStream[0:len(c.CallOptions.DeleteWebDataStream):len(c.CallOptions.DeleteWebDataStream)], opts...) 879 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 880 var err error 881 _, err = c.analyticsAdminClient.DeleteWebDataStream(ctx, req, settings.GRPC...) 882 return err 883 }, opts...) 884 return err 885} 886 887// UpdateWebDataStream updates a web stream on a property. 888func (c *AnalyticsAdminClient) UpdateWebDataStream(ctx context.Context, req *adminpb.UpdateWebDataStreamRequest, opts ...gax.CallOption) (*adminpb.WebDataStream, error) { 889 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 890 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 891 defer cancel() 892 ctx = cctx 893 } 894 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "web_data_stream.name", url.QueryEscape(req.GetWebDataStream().GetName()))) 895 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 896 opts = append(c.CallOptions.UpdateWebDataStream[0:len(c.CallOptions.UpdateWebDataStream):len(c.CallOptions.UpdateWebDataStream)], opts...) 897 var resp *adminpb.WebDataStream 898 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 899 var err error 900 resp, err = c.analyticsAdminClient.UpdateWebDataStream(ctx, req, settings.GRPC...) 901 return err 902 }, opts...) 903 if err != nil { 904 return nil, err 905 } 906 return resp, nil 907} 908 909// CreateWebDataStream creates a web stream with the specified location and attributes. 910func (c *AnalyticsAdminClient) CreateWebDataStream(ctx context.Context, req *adminpb.CreateWebDataStreamRequest, opts ...gax.CallOption) (*adminpb.WebDataStream, error) { 911 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 912 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 913 defer cancel() 914 ctx = cctx 915 } 916 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 917 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 918 opts = append(c.CallOptions.CreateWebDataStream[0:len(c.CallOptions.CreateWebDataStream):len(c.CallOptions.CreateWebDataStream)], opts...) 919 var resp *adminpb.WebDataStream 920 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 921 var err error 922 resp, err = c.analyticsAdminClient.CreateWebDataStream(ctx, req, settings.GRPC...) 923 return err 924 }, opts...) 925 if err != nil { 926 return nil, err 927 } 928 return resp, nil 929} 930 931// ListWebDataStreams returns child web data streams under the specified parent property. 932// 933// Web data streams will be excluded if the caller does not have access. 934// Returns an empty list if no relevant web data streams are found. 935func (c *AnalyticsAdminClient) ListWebDataStreams(ctx context.Context, req *adminpb.ListWebDataStreamsRequest, opts ...gax.CallOption) *WebDataStreamIterator { 936 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 937 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 938 opts = append(c.CallOptions.ListWebDataStreams[0:len(c.CallOptions.ListWebDataStreams):len(c.CallOptions.ListWebDataStreams)], opts...) 939 it := &WebDataStreamIterator{} 940 req = proto.Clone(req).(*adminpb.ListWebDataStreamsRequest) 941 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.WebDataStream, string, error) { 942 var resp *adminpb.ListWebDataStreamsResponse 943 req.PageToken = pageToken 944 if pageSize > math.MaxInt32 { 945 req.PageSize = math.MaxInt32 946 } else { 947 req.PageSize = int32(pageSize) 948 } 949 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 950 var err error 951 resp, err = c.analyticsAdminClient.ListWebDataStreams(ctx, req, settings.GRPC...) 952 return err 953 }, opts...) 954 if err != nil { 955 return nil, "", err 956 } 957 958 it.Response = resp 959 return resp.GetWebDataStreams(), resp.GetNextPageToken(), nil 960 } 961 fetch := func(pageSize int, pageToken string) (string, error) { 962 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 963 if err != nil { 964 return "", err 965 } 966 it.items = append(it.items, items...) 967 return nextPageToken, nil 968 } 969 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 970 it.pageInfo.MaxSize = int(req.GetPageSize()) 971 it.pageInfo.Token = req.GetPageToken() 972 return it 973} 974 975// GetIosAppDataStream lookup for a single IosAppDataStream 976func (c *AnalyticsAdminClient) GetIosAppDataStream(ctx context.Context, req *adminpb.GetIosAppDataStreamRequest, opts ...gax.CallOption) (*adminpb.IosAppDataStream, error) { 977 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 978 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 979 defer cancel() 980 ctx = cctx 981 } 982 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 983 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 984 opts = append(c.CallOptions.GetIosAppDataStream[0:len(c.CallOptions.GetIosAppDataStream):len(c.CallOptions.GetIosAppDataStream)], opts...) 985 var resp *adminpb.IosAppDataStream 986 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 987 var err error 988 resp, err = c.analyticsAdminClient.GetIosAppDataStream(ctx, req, settings.GRPC...) 989 return err 990 }, opts...) 991 if err != nil { 992 return nil, err 993 } 994 return resp, nil 995} 996 997// DeleteIosAppDataStream deletes an iOS app stream on a property. 998func (c *AnalyticsAdminClient) DeleteIosAppDataStream(ctx context.Context, req *adminpb.DeleteIosAppDataStreamRequest, opts ...gax.CallOption) error { 999 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1000 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1001 defer cancel() 1002 ctx = cctx 1003 } 1004 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1005 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1006 opts = append(c.CallOptions.DeleteIosAppDataStream[0:len(c.CallOptions.DeleteIosAppDataStream):len(c.CallOptions.DeleteIosAppDataStream)], opts...) 1007 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1008 var err error 1009 _, err = c.analyticsAdminClient.DeleteIosAppDataStream(ctx, req, settings.GRPC...) 1010 return err 1011 }, opts...) 1012 return err 1013} 1014 1015// UpdateIosAppDataStream updates an iOS app stream on a property. 1016func (c *AnalyticsAdminClient) UpdateIosAppDataStream(ctx context.Context, req *adminpb.UpdateIosAppDataStreamRequest, opts ...gax.CallOption) (*adminpb.IosAppDataStream, error) { 1017 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1018 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1019 defer cancel() 1020 ctx = cctx 1021 } 1022 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "ios_app_data_stream.name", url.QueryEscape(req.GetIosAppDataStream().GetName()))) 1023 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1024 opts = append(c.CallOptions.UpdateIosAppDataStream[0:len(c.CallOptions.UpdateIosAppDataStream):len(c.CallOptions.UpdateIosAppDataStream)], opts...) 1025 var resp *adminpb.IosAppDataStream 1026 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1027 var err error 1028 resp, err = c.analyticsAdminClient.UpdateIosAppDataStream(ctx, req, settings.GRPC...) 1029 return err 1030 }, opts...) 1031 if err != nil { 1032 return nil, err 1033 } 1034 return resp, nil 1035} 1036 1037// CreateIosAppDataStream creates an iOS app stream with the specified location and attributes. 1038// 1039// Note that an iOS app stream must be linked to a Firebase app to receive 1040// traffic. 1041// 1042// To create a working app stream, make sure your property is linked to a 1043// Firebase project. Then, use the Firebase API to create a Firebase app, 1044// which will also create an appropriate data stream in Analytics (may take up 1045// to 24 hours). 1046func (c *AnalyticsAdminClient) CreateIosAppDataStream(ctx context.Context, req *adminpb.CreateIosAppDataStreamRequest, opts ...gax.CallOption) (*adminpb.IosAppDataStream, error) { 1047 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1048 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1049 defer cancel() 1050 ctx = cctx 1051 } 1052 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1053 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1054 opts = append(c.CallOptions.CreateIosAppDataStream[0:len(c.CallOptions.CreateIosAppDataStream):len(c.CallOptions.CreateIosAppDataStream)], opts...) 1055 var resp *adminpb.IosAppDataStream 1056 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1057 var err error 1058 resp, err = c.analyticsAdminClient.CreateIosAppDataStream(ctx, req, settings.GRPC...) 1059 return err 1060 }, opts...) 1061 if err != nil { 1062 return nil, err 1063 } 1064 return resp, nil 1065} 1066 1067// ListIosAppDataStreams returns child iOS app data streams under the specified parent property. 1068// 1069// iOS app data streams will be excluded if the caller does not have access. 1070// Returns an empty list if no relevant iOS app data streams are found. 1071func (c *AnalyticsAdminClient) ListIosAppDataStreams(ctx context.Context, req *adminpb.ListIosAppDataStreamsRequest, opts ...gax.CallOption) *IosAppDataStreamIterator { 1072 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1073 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1074 opts = append(c.CallOptions.ListIosAppDataStreams[0:len(c.CallOptions.ListIosAppDataStreams):len(c.CallOptions.ListIosAppDataStreams)], opts...) 1075 it := &IosAppDataStreamIterator{} 1076 req = proto.Clone(req).(*adminpb.ListIosAppDataStreamsRequest) 1077 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.IosAppDataStream, string, error) { 1078 var resp *adminpb.ListIosAppDataStreamsResponse 1079 req.PageToken = pageToken 1080 if pageSize > math.MaxInt32 { 1081 req.PageSize = math.MaxInt32 1082 } else { 1083 req.PageSize = int32(pageSize) 1084 } 1085 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1086 var err error 1087 resp, err = c.analyticsAdminClient.ListIosAppDataStreams(ctx, req, settings.GRPC...) 1088 return err 1089 }, opts...) 1090 if err != nil { 1091 return nil, "", err 1092 } 1093 1094 it.Response = resp 1095 return resp.GetIosAppDataStreams(), resp.GetNextPageToken(), nil 1096 } 1097 fetch := func(pageSize int, pageToken string) (string, error) { 1098 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1099 if err != nil { 1100 return "", err 1101 } 1102 it.items = append(it.items, items...) 1103 return nextPageToken, nil 1104 } 1105 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1106 it.pageInfo.MaxSize = int(req.GetPageSize()) 1107 it.pageInfo.Token = req.GetPageToken() 1108 return it 1109} 1110 1111// GetAndroidAppDataStream lookup for a single AndroidAppDataStream 1112func (c *AnalyticsAdminClient) GetAndroidAppDataStream(ctx context.Context, req *adminpb.GetAndroidAppDataStreamRequest, opts ...gax.CallOption) (*adminpb.AndroidAppDataStream, error) { 1113 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1114 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1115 defer cancel() 1116 ctx = cctx 1117 } 1118 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1119 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1120 opts = append(c.CallOptions.GetAndroidAppDataStream[0:len(c.CallOptions.GetAndroidAppDataStream):len(c.CallOptions.GetAndroidAppDataStream)], opts...) 1121 var resp *adminpb.AndroidAppDataStream 1122 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1123 var err error 1124 resp, err = c.analyticsAdminClient.GetAndroidAppDataStream(ctx, req, settings.GRPC...) 1125 return err 1126 }, opts...) 1127 if err != nil { 1128 return nil, err 1129 } 1130 return resp, nil 1131} 1132 1133// DeleteAndroidAppDataStream deletes an android app stream on a property. 1134func (c *AnalyticsAdminClient) DeleteAndroidAppDataStream(ctx context.Context, req *adminpb.DeleteAndroidAppDataStreamRequest, opts ...gax.CallOption) error { 1135 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1136 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1137 defer cancel() 1138 ctx = cctx 1139 } 1140 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1141 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1142 opts = append(c.CallOptions.DeleteAndroidAppDataStream[0:len(c.CallOptions.DeleteAndroidAppDataStream):len(c.CallOptions.DeleteAndroidAppDataStream)], opts...) 1143 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1144 var err error 1145 _, err = c.analyticsAdminClient.DeleteAndroidAppDataStream(ctx, req, settings.GRPC...) 1146 return err 1147 }, opts...) 1148 return err 1149} 1150 1151// UpdateAndroidAppDataStream updates an android app stream on a property. 1152func (c *AnalyticsAdminClient) UpdateAndroidAppDataStream(ctx context.Context, req *adminpb.UpdateAndroidAppDataStreamRequest, opts ...gax.CallOption) (*adminpb.AndroidAppDataStream, error) { 1153 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1154 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1155 defer cancel() 1156 ctx = cctx 1157 } 1158 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "android_app_data_stream.name", url.QueryEscape(req.GetAndroidAppDataStream().GetName()))) 1159 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1160 opts = append(c.CallOptions.UpdateAndroidAppDataStream[0:len(c.CallOptions.UpdateAndroidAppDataStream):len(c.CallOptions.UpdateAndroidAppDataStream)], opts...) 1161 var resp *adminpb.AndroidAppDataStream 1162 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1163 var err error 1164 resp, err = c.analyticsAdminClient.UpdateAndroidAppDataStream(ctx, req, settings.GRPC...) 1165 return err 1166 }, opts...) 1167 if err != nil { 1168 return nil, err 1169 } 1170 return resp, nil 1171} 1172 1173// CreateAndroidAppDataStream creates an Android app stream with the specified location and attributes. 1174// 1175// Note that an Android app stream must be linked to a Firebase app to receive 1176// traffic. 1177// 1178// To create a working app stream, make sure your property is linked to a 1179// Firebase project. Then, use the Firebase API to create a Firebase app, 1180// which will also create an appropriate data stream in Analytics (may take up 1181// to 24 hours). 1182func (c *AnalyticsAdminClient) CreateAndroidAppDataStream(ctx context.Context, req *adminpb.CreateAndroidAppDataStreamRequest, opts ...gax.CallOption) (*adminpb.AndroidAppDataStream, error) { 1183 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1184 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1185 defer cancel() 1186 ctx = cctx 1187 } 1188 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1189 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1190 opts = append(c.CallOptions.CreateAndroidAppDataStream[0:len(c.CallOptions.CreateAndroidAppDataStream):len(c.CallOptions.CreateAndroidAppDataStream)], opts...) 1191 var resp *adminpb.AndroidAppDataStream 1192 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1193 var err error 1194 resp, err = c.analyticsAdminClient.CreateAndroidAppDataStream(ctx, req, settings.GRPC...) 1195 return err 1196 }, opts...) 1197 if err != nil { 1198 return nil, err 1199 } 1200 return resp, nil 1201} 1202 1203// ListAndroidAppDataStreams returns child android app streams under the specified parent property. 1204// 1205// Android app streams will be excluded if the caller does not have access. 1206// Returns an empty list if no relevant android app streams are found. 1207func (c *AnalyticsAdminClient) ListAndroidAppDataStreams(ctx context.Context, req *adminpb.ListAndroidAppDataStreamsRequest, opts ...gax.CallOption) *AndroidAppDataStreamIterator { 1208 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1209 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1210 opts = append(c.CallOptions.ListAndroidAppDataStreams[0:len(c.CallOptions.ListAndroidAppDataStreams):len(c.CallOptions.ListAndroidAppDataStreams)], opts...) 1211 it := &AndroidAppDataStreamIterator{} 1212 req = proto.Clone(req).(*adminpb.ListAndroidAppDataStreamsRequest) 1213 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.AndroidAppDataStream, string, error) { 1214 var resp *adminpb.ListAndroidAppDataStreamsResponse 1215 req.PageToken = pageToken 1216 if pageSize > math.MaxInt32 { 1217 req.PageSize = math.MaxInt32 1218 } else { 1219 req.PageSize = int32(pageSize) 1220 } 1221 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1222 var err error 1223 resp, err = c.analyticsAdminClient.ListAndroidAppDataStreams(ctx, req, settings.GRPC...) 1224 return err 1225 }, opts...) 1226 if err != nil { 1227 return nil, "", err 1228 } 1229 1230 it.Response = resp 1231 return resp.GetAndroidAppDataStreams(), resp.GetNextPageToken(), nil 1232 } 1233 fetch := func(pageSize int, pageToken string) (string, error) { 1234 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1235 if err != nil { 1236 return "", err 1237 } 1238 it.items = append(it.items, items...) 1239 return nextPageToken, nil 1240 } 1241 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1242 it.pageInfo.MaxSize = int(req.GetPageSize()) 1243 it.pageInfo.Token = req.GetPageToken() 1244 return it 1245} 1246 1247// GetEnhancedMeasurementSettings returns the singleton enhanced measurement settings for this web stream. 1248// Note that the stream must enable enhanced measurement for these settings to 1249// take effect. 1250func (c *AnalyticsAdminClient) GetEnhancedMeasurementSettings(ctx context.Context, req *adminpb.GetEnhancedMeasurementSettingsRequest, opts ...gax.CallOption) (*adminpb.EnhancedMeasurementSettings, error) { 1251 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1252 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1253 defer cancel() 1254 ctx = cctx 1255 } 1256 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1257 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1258 opts = append(c.CallOptions.GetEnhancedMeasurementSettings[0:len(c.CallOptions.GetEnhancedMeasurementSettings):len(c.CallOptions.GetEnhancedMeasurementSettings)], opts...) 1259 var resp *adminpb.EnhancedMeasurementSettings 1260 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1261 var err error 1262 resp, err = c.analyticsAdminClient.GetEnhancedMeasurementSettings(ctx, req, settings.GRPC...) 1263 return err 1264 }, opts...) 1265 if err != nil { 1266 return nil, err 1267 } 1268 return resp, nil 1269} 1270 1271// UpdateEnhancedMeasurementSettings updates the singleton enhanced measurement settings for this web stream. 1272// Note that the stream must enable enhanced measurement for these settings to 1273// take effect. 1274func (c *AnalyticsAdminClient) UpdateEnhancedMeasurementSettings(ctx context.Context, req *adminpb.UpdateEnhancedMeasurementSettingsRequest, opts ...gax.CallOption) (*adminpb.EnhancedMeasurementSettings, error) { 1275 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1276 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1277 defer cancel() 1278 ctx = cctx 1279 } 1280 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "enhanced_measurement_settings.name", url.QueryEscape(req.GetEnhancedMeasurementSettings().GetName()))) 1281 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1282 opts = append(c.CallOptions.UpdateEnhancedMeasurementSettings[0:len(c.CallOptions.UpdateEnhancedMeasurementSettings):len(c.CallOptions.UpdateEnhancedMeasurementSettings)], opts...) 1283 var resp *adminpb.EnhancedMeasurementSettings 1284 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1285 var err error 1286 resp, err = c.analyticsAdminClient.UpdateEnhancedMeasurementSettings(ctx, req, settings.GRPC...) 1287 return err 1288 }, opts...) 1289 if err != nil { 1290 return nil, err 1291 } 1292 return resp, nil 1293} 1294 1295// CreateFirebaseLink creates a FirebaseLink. 1296// 1297// Properties can have at most one FirebaseLink. 1298func (c *AnalyticsAdminClient) CreateFirebaseLink(ctx context.Context, req *adminpb.CreateFirebaseLinkRequest, opts ...gax.CallOption) (*adminpb.FirebaseLink, error) { 1299 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1300 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1301 defer cancel() 1302 ctx = cctx 1303 } 1304 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1305 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1306 opts = append(c.CallOptions.CreateFirebaseLink[0:len(c.CallOptions.CreateFirebaseLink):len(c.CallOptions.CreateFirebaseLink)], opts...) 1307 var resp *adminpb.FirebaseLink 1308 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1309 var err error 1310 resp, err = c.analyticsAdminClient.CreateFirebaseLink(ctx, req, settings.GRPC...) 1311 return err 1312 }, opts...) 1313 if err != nil { 1314 return nil, err 1315 } 1316 return resp, nil 1317} 1318 1319// UpdateFirebaseLink updates a FirebaseLink on a property 1320func (c *AnalyticsAdminClient) UpdateFirebaseLink(ctx context.Context, req *adminpb.UpdateFirebaseLinkRequest, opts ...gax.CallOption) (*adminpb.FirebaseLink, error) { 1321 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1322 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1323 defer cancel() 1324 ctx = cctx 1325 } 1326 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "firebase_link.name", url.QueryEscape(req.GetFirebaseLink().GetName()))) 1327 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1328 opts = append(c.CallOptions.UpdateFirebaseLink[0:len(c.CallOptions.UpdateFirebaseLink):len(c.CallOptions.UpdateFirebaseLink)], opts...) 1329 var resp *adminpb.FirebaseLink 1330 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1331 var err error 1332 resp, err = c.analyticsAdminClient.UpdateFirebaseLink(ctx, req, settings.GRPC...) 1333 return err 1334 }, opts...) 1335 if err != nil { 1336 return nil, err 1337 } 1338 return resp, nil 1339} 1340 1341// DeleteFirebaseLink deletes a FirebaseLink on a property 1342func (c *AnalyticsAdminClient) DeleteFirebaseLink(ctx context.Context, req *adminpb.DeleteFirebaseLinkRequest, opts ...gax.CallOption) error { 1343 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1344 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1345 defer cancel() 1346 ctx = cctx 1347 } 1348 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1349 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1350 opts = append(c.CallOptions.DeleteFirebaseLink[0:len(c.CallOptions.DeleteFirebaseLink):len(c.CallOptions.DeleteFirebaseLink)], opts...) 1351 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1352 var err error 1353 _, err = c.analyticsAdminClient.DeleteFirebaseLink(ctx, req, settings.GRPC...) 1354 return err 1355 }, opts...) 1356 return err 1357} 1358 1359// ListFirebaseLinks lists FirebaseLinks on a property. 1360// Properties can have at most one FirebaseLink. 1361func (c *AnalyticsAdminClient) ListFirebaseLinks(ctx context.Context, req *adminpb.ListFirebaseLinksRequest, opts ...gax.CallOption) *FirebaseLinkIterator { 1362 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1363 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1364 opts = append(c.CallOptions.ListFirebaseLinks[0:len(c.CallOptions.ListFirebaseLinks):len(c.CallOptions.ListFirebaseLinks)], opts...) 1365 it := &FirebaseLinkIterator{} 1366 req = proto.Clone(req).(*adminpb.ListFirebaseLinksRequest) 1367 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.FirebaseLink, string, error) { 1368 var resp *adminpb.ListFirebaseLinksResponse 1369 req.PageToken = pageToken 1370 if pageSize > math.MaxInt32 { 1371 req.PageSize = math.MaxInt32 1372 } else { 1373 req.PageSize = int32(pageSize) 1374 } 1375 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1376 var err error 1377 resp, err = c.analyticsAdminClient.ListFirebaseLinks(ctx, req, settings.GRPC...) 1378 return err 1379 }, opts...) 1380 if err != nil { 1381 return nil, "", err 1382 } 1383 1384 it.Response = resp 1385 return resp.GetFirebaseLinks(), resp.GetNextPageToken(), nil 1386 } 1387 fetch := func(pageSize int, pageToken string) (string, error) { 1388 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1389 if err != nil { 1390 return "", err 1391 } 1392 it.items = append(it.items, items...) 1393 return nextPageToken, nil 1394 } 1395 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1396 it.pageInfo.MaxSize = int(req.GetPageSize()) 1397 it.pageInfo.Token = req.GetPageToken() 1398 return it 1399} 1400 1401// GetGlobalSiteTag returns the Site Tag for the specified web stream. 1402// Site Tags are immutable singletons. 1403func (c *AnalyticsAdminClient) GetGlobalSiteTag(ctx context.Context, req *adminpb.GetGlobalSiteTagRequest, opts ...gax.CallOption) (*adminpb.GlobalSiteTag, error) { 1404 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1405 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1406 defer cancel() 1407 ctx = cctx 1408 } 1409 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1410 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1411 opts = append(c.CallOptions.GetGlobalSiteTag[0:len(c.CallOptions.GetGlobalSiteTag):len(c.CallOptions.GetGlobalSiteTag)], opts...) 1412 var resp *adminpb.GlobalSiteTag 1413 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1414 var err error 1415 resp, err = c.analyticsAdminClient.GetGlobalSiteTag(ctx, req, settings.GRPC...) 1416 return err 1417 }, opts...) 1418 if err != nil { 1419 return nil, err 1420 } 1421 return resp, nil 1422} 1423 1424// CreateGoogleAdsLink creates a GoogleAdsLink. 1425func (c *AnalyticsAdminClient) CreateGoogleAdsLink(ctx context.Context, req *adminpb.CreateGoogleAdsLinkRequest, opts ...gax.CallOption) (*adminpb.GoogleAdsLink, error) { 1426 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1427 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1428 defer cancel() 1429 ctx = cctx 1430 } 1431 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1432 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1433 opts = append(c.CallOptions.CreateGoogleAdsLink[0:len(c.CallOptions.CreateGoogleAdsLink):len(c.CallOptions.CreateGoogleAdsLink)], opts...) 1434 var resp *adminpb.GoogleAdsLink 1435 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1436 var err error 1437 resp, err = c.analyticsAdminClient.CreateGoogleAdsLink(ctx, req, settings.GRPC...) 1438 return err 1439 }, opts...) 1440 if err != nil { 1441 return nil, err 1442 } 1443 return resp, nil 1444} 1445 1446// UpdateGoogleAdsLink updates a GoogleAdsLink on a property 1447func (c *AnalyticsAdminClient) UpdateGoogleAdsLink(ctx context.Context, req *adminpb.UpdateGoogleAdsLinkRequest, opts ...gax.CallOption) (*adminpb.GoogleAdsLink, error) { 1448 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1449 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1450 defer cancel() 1451 ctx = cctx 1452 } 1453 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "google_ads_link.name", url.QueryEscape(req.GetGoogleAdsLink().GetName()))) 1454 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1455 opts = append(c.CallOptions.UpdateGoogleAdsLink[0:len(c.CallOptions.UpdateGoogleAdsLink):len(c.CallOptions.UpdateGoogleAdsLink)], opts...) 1456 var resp *adminpb.GoogleAdsLink 1457 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1458 var err error 1459 resp, err = c.analyticsAdminClient.UpdateGoogleAdsLink(ctx, req, settings.GRPC...) 1460 return err 1461 }, opts...) 1462 if err != nil { 1463 return nil, err 1464 } 1465 return resp, nil 1466} 1467 1468// DeleteGoogleAdsLink deletes a GoogleAdsLink on a property 1469func (c *AnalyticsAdminClient) DeleteGoogleAdsLink(ctx context.Context, req *adminpb.DeleteGoogleAdsLinkRequest, opts ...gax.CallOption) error { 1470 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1471 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1472 defer cancel() 1473 ctx = cctx 1474 } 1475 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1476 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1477 opts = append(c.CallOptions.DeleteGoogleAdsLink[0:len(c.CallOptions.DeleteGoogleAdsLink):len(c.CallOptions.DeleteGoogleAdsLink)], opts...) 1478 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1479 var err error 1480 _, err = c.analyticsAdminClient.DeleteGoogleAdsLink(ctx, req, settings.GRPC...) 1481 return err 1482 }, opts...) 1483 return err 1484} 1485 1486// ListGoogleAdsLinks lists GoogleAdsLinks on a property. 1487func (c *AnalyticsAdminClient) ListGoogleAdsLinks(ctx context.Context, req *adminpb.ListGoogleAdsLinksRequest, opts ...gax.CallOption) *GoogleAdsLinkIterator { 1488 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) 1489 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1490 opts = append(c.CallOptions.ListGoogleAdsLinks[0:len(c.CallOptions.ListGoogleAdsLinks):len(c.CallOptions.ListGoogleAdsLinks)], opts...) 1491 it := &GoogleAdsLinkIterator{} 1492 req = proto.Clone(req).(*adminpb.ListGoogleAdsLinksRequest) 1493 it.InternalFetch = func(pageSize int, pageToken string) ([]*adminpb.GoogleAdsLink, string, error) { 1494 var resp *adminpb.ListGoogleAdsLinksResponse 1495 req.PageToken = pageToken 1496 if pageSize > math.MaxInt32 { 1497 req.PageSize = math.MaxInt32 1498 } else { 1499 req.PageSize = int32(pageSize) 1500 } 1501 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1502 var err error 1503 resp, err = c.analyticsAdminClient.ListGoogleAdsLinks(ctx, req, settings.GRPC...) 1504 return err 1505 }, opts...) 1506 if err != nil { 1507 return nil, "", err 1508 } 1509 1510 it.Response = resp 1511 return resp.GetGoogleAdsLinks(), resp.GetNextPageToken(), nil 1512 } 1513 fetch := func(pageSize int, pageToken string) (string, error) { 1514 items, nextPageToken, err := it.InternalFetch(pageSize, pageToken) 1515 if err != nil { 1516 return "", err 1517 } 1518 it.items = append(it.items, items...) 1519 return nextPageToken, nil 1520 } 1521 it.pageInfo, it.nextFunc = iterator.NewPageInfo(fetch, it.bufLen, it.takeBuf) 1522 it.pageInfo.MaxSize = int(req.GetPageSize()) 1523 it.pageInfo.Token = req.GetPageToken() 1524 return it 1525} 1526 1527// GetDataSharingSettings get data sharing settings on an account. 1528// Data sharing settings are singletons. 1529func (c *AnalyticsAdminClient) GetDataSharingSettings(ctx context.Context, req *adminpb.GetDataSharingSettingsRequest, opts ...gax.CallOption) (*adminpb.DataSharingSettings, error) { 1530 if _, ok := ctx.Deadline(); !ok && !c.disableDeadlines { 1531 cctx, cancel := context.WithTimeout(ctx, 60000*time.Millisecond) 1532 defer cancel() 1533 ctx = cctx 1534 } 1535 md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) 1536 ctx = insertMetadata(ctx, c.xGoogMetadata, md) 1537 opts = append(c.CallOptions.GetDataSharingSettings[0:len(c.CallOptions.GetDataSharingSettings):len(c.CallOptions.GetDataSharingSettings)], opts...) 1538 var resp *adminpb.DataSharingSettings 1539 err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { 1540 var err error 1541 resp, err = c.analyticsAdminClient.GetDataSharingSettings(ctx, req, settings.GRPC...) 1542 return err 1543 }, opts...) 1544 if err != nil { 1545 return nil, err 1546 } 1547 return resp, nil 1548} 1549 1550// AccountIterator manages a stream of *adminpb.Account. 1551type AccountIterator struct { 1552 items []*adminpb.Account 1553 pageInfo *iterator.PageInfo 1554 nextFunc func() error 1555 1556 // Response is the raw response for the current page. 1557 // It must be cast to the RPC response type. 1558 // Calling Next() or InternalFetch() updates this value. 1559 Response interface{} 1560 1561 // InternalFetch is for use by the Google Cloud Libraries only. 1562 // It is not part of the stable interface of this package. 1563 // 1564 // InternalFetch returns results from a single call to the underlying RPC. 1565 // The number of results is no greater than pageSize. 1566 // If there are no more results, nextPageToken is empty and err is nil. 1567 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.Account, nextPageToken string, err error) 1568} 1569 1570// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1571func (it *AccountIterator) PageInfo() *iterator.PageInfo { 1572 return it.pageInfo 1573} 1574 1575// Next returns the next result. Its second return value is iterator.Done if there are no more 1576// results. Once Next returns Done, all subsequent calls will return Done. 1577func (it *AccountIterator) Next() (*adminpb.Account, error) { 1578 var item *adminpb.Account 1579 if err := it.nextFunc(); err != nil { 1580 return item, err 1581 } 1582 item = it.items[0] 1583 it.items = it.items[1:] 1584 return item, nil 1585} 1586 1587func (it *AccountIterator) bufLen() int { 1588 return len(it.items) 1589} 1590 1591func (it *AccountIterator) takeBuf() interface{} { 1592 b := it.items 1593 it.items = nil 1594 return b 1595} 1596 1597// AccountSummaryIterator manages a stream of *adminpb.AccountSummary. 1598type AccountSummaryIterator struct { 1599 items []*adminpb.AccountSummary 1600 pageInfo *iterator.PageInfo 1601 nextFunc func() error 1602 1603 // Response is the raw response for the current page. 1604 // It must be cast to the RPC response type. 1605 // Calling Next() or InternalFetch() updates this value. 1606 Response interface{} 1607 1608 // InternalFetch is for use by the Google Cloud Libraries only. 1609 // It is not part of the stable interface of this package. 1610 // 1611 // InternalFetch returns results from a single call to the underlying RPC. 1612 // The number of results is no greater than pageSize. 1613 // If there are no more results, nextPageToken is empty and err is nil. 1614 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.AccountSummary, nextPageToken string, err error) 1615} 1616 1617// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1618func (it *AccountSummaryIterator) PageInfo() *iterator.PageInfo { 1619 return it.pageInfo 1620} 1621 1622// Next returns the next result. Its second return value is iterator.Done if there are no more 1623// results. Once Next returns Done, all subsequent calls will return Done. 1624func (it *AccountSummaryIterator) Next() (*adminpb.AccountSummary, error) { 1625 var item *adminpb.AccountSummary 1626 if err := it.nextFunc(); err != nil { 1627 return item, err 1628 } 1629 item = it.items[0] 1630 it.items = it.items[1:] 1631 return item, nil 1632} 1633 1634func (it *AccountSummaryIterator) bufLen() int { 1635 return len(it.items) 1636} 1637 1638func (it *AccountSummaryIterator) takeBuf() interface{} { 1639 b := it.items 1640 it.items = nil 1641 return b 1642} 1643 1644// AndroidAppDataStreamIterator manages a stream of *adminpb.AndroidAppDataStream. 1645type AndroidAppDataStreamIterator struct { 1646 items []*adminpb.AndroidAppDataStream 1647 pageInfo *iterator.PageInfo 1648 nextFunc func() error 1649 1650 // Response is the raw response for the current page. 1651 // It must be cast to the RPC response type. 1652 // Calling Next() or InternalFetch() updates this value. 1653 Response interface{} 1654 1655 // InternalFetch is for use by the Google Cloud Libraries only. 1656 // It is not part of the stable interface of this package. 1657 // 1658 // InternalFetch returns results from a single call to the underlying RPC. 1659 // The number of results is no greater than pageSize. 1660 // If there are no more results, nextPageToken is empty and err is nil. 1661 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.AndroidAppDataStream, nextPageToken string, err error) 1662} 1663 1664// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1665func (it *AndroidAppDataStreamIterator) PageInfo() *iterator.PageInfo { 1666 return it.pageInfo 1667} 1668 1669// Next returns the next result. Its second return value is iterator.Done if there are no more 1670// results. Once Next returns Done, all subsequent calls will return Done. 1671func (it *AndroidAppDataStreamIterator) Next() (*adminpb.AndroidAppDataStream, error) { 1672 var item *adminpb.AndroidAppDataStream 1673 if err := it.nextFunc(); err != nil { 1674 return item, err 1675 } 1676 item = it.items[0] 1677 it.items = it.items[1:] 1678 return item, nil 1679} 1680 1681func (it *AndroidAppDataStreamIterator) bufLen() int { 1682 return len(it.items) 1683} 1684 1685func (it *AndroidAppDataStreamIterator) takeBuf() interface{} { 1686 b := it.items 1687 it.items = nil 1688 return b 1689} 1690 1691// AuditUserLinkIterator manages a stream of *adminpb.AuditUserLink. 1692type AuditUserLinkIterator struct { 1693 items []*adminpb.AuditUserLink 1694 pageInfo *iterator.PageInfo 1695 nextFunc func() error 1696 1697 // Response is the raw response for the current page. 1698 // It must be cast to the RPC response type. 1699 // Calling Next() or InternalFetch() updates this value. 1700 Response interface{} 1701 1702 // InternalFetch is for use by the Google Cloud Libraries only. 1703 // It is not part of the stable interface of this package. 1704 // 1705 // InternalFetch returns results from a single call to the underlying RPC. 1706 // The number of results is no greater than pageSize. 1707 // If there are no more results, nextPageToken is empty and err is nil. 1708 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.AuditUserLink, nextPageToken string, err error) 1709} 1710 1711// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1712func (it *AuditUserLinkIterator) PageInfo() *iterator.PageInfo { 1713 return it.pageInfo 1714} 1715 1716// Next returns the next result. Its second return value is iterator.Done if there are no more 1717// results. Once Next returns Done, all subsequent calls will return Done. 1718func (it *AuditUserLinkIterator) Next() (*adminpb.AuditUserLink, error) { 1719 var item *adminpb.AuditUserLink 1720 if err := it.nextFunc(); err != nil { 1721 return item, err 1722 } 1723 item = it.items[0] 1724 it.items = it.items[1:] 1725 return item, nil 1726} 1727 1728func (it *AuditUserLinkIterator) bufLen() int { 1729 return len(it.items) 1730} 1731 1732func (it *AuditUserLinkIterator) takeBuf() interface{} { 1733 b := it.items 1734 it.items = nil 1735 return b 1736} 1737 1738// FirebaseLinkIterator manages a stream of *adminpb.FirebaseLink. 1739type FirebaseLinkIterator struct { 1740 items []*adminpb.FirebaseLink 1741 pageInfo *iterator.PageInfo 1742 nextFunc func() error 1743 1744 // Response is the raw response for the current page. 1745 // It must be cast to the RPC response type. 1746 // Calling Next() or InternalFetch() updates this value. 1747 Response interface{} 1748 1749 // InternalFetch is for use by the Google Cloud Libraries only. 1750 // It is not part of the stable interface of this package. 1751 // 1752 // InternalFetch returns results from a single call to the underlying RPC. 1753 // The number of results is no greater than pageSize. 1754 // If there are no more results, nextPageToken is empty and err is nil. 1755 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.FirebaseLink, nextPageToken string, err error) 1756} 1757 1758// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1759func (it *FirebaseLinkIterator) PageInfo() *iterator.PageInfo { 1760 return it.pageInfo 1761} 1762 1763// Next returns the next result. Its second return value is iterator.Done if there are no more 1764// results. Once Next returns Done, all subsequent calls will return Done. 1765func (it *FirebaseLinkIterator) Next() (*adminpb.FirebaseLink, error) { 1766 var item *adminpb.FirebaseLink 1767 if err := it.nextFunc(); err != nil { 1768 return item, err 1769 } 1770 item = it.items[0] 1771 it.items = it.items[1:] 1772 return item, nil 1773} 1774 1775func (it *FirebaseLinkIterator) bufLen() int { 1776 return len(it.items) 1777} 1778 1779func (it *FirebaseLinkIterator) takeBuf() interface{} { 1780 b := it.items 1781 it.items = nil 1782 return b 1783} 1784 1785// GoogleAdsLinkIterator manages a stream of *adminpb.GoogleAdsLink. 1786type GoogleAdsLinkIterator struct { 1787 items []*adminpb.GoogleAdsLink 1788 pageInfo *iterator.PageInfo 1789 nextFunc func() error 1790 1791 // Response is the raw response for the current page. 1792 // It must be cast to the RPC response type. 1793 // Calling Next() or InternalFetch() updates this value. 1794 Response interface{} 1795 1796 // InternalFetch is for use by the Google Cloud Libraries only. 1797 // It is not part of the stable interface of this package. 1798 // 1799 // InternalFetch returns results from a single call to the underlying RPC. 1800 // The number of results is no greater than pageSize. 1801 // If there are no more results, nextPageToken is empty and err is nil. 1802 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.GoogleAdsLink, nextPageToken string, err error) 1803} 1804 1805// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1806func (it *GoogleAdsLinkIterator) PageInfo() *iterator.PageInfo { 1807 return it.pageInfo 1808} 1809 1810// Next returns the next result. Its second return value is iterator.Done if there are no more 1811// results. Once Next returns Done, all subsequent calls will return Done. 1812func (it *GoogleAdsLinkIterator) Next() (*adminpb.GoogleAdsLink, error) { 1813 var item *adminpb.GoogleAdsLink 1814 if err := it.nextFunc(); err != nil { 1815 return item, err 1816 } 1817 item = it.items[0] 1818 it.items = it.items[1:] 1819 return item, nil 1820} 1821 1822func (it *GoogleAdsLinkIterator) bufLen() int { 1823 return len(it.items) 1824} 1825 1826func (it *GoogleAdsLinkIterator) takeBuf() interface{} { 1827 b := it.items 1828 it.items = nil 1829 return b 1830} 1831 1832// IosAppDataStreamIterator manages a stream of *adminpb.IosAppDataStream. 1833type IosAppDataStreamIterator struct { 1834 items []*adminpb.IosAppDataStream 1835 pageInfo *iterator.PageInfo 1836 nextFunc func() error 1837 1838 // Response is the raw response for the current page. 1839 // It must be cast to the RPC response type. 1840 // Calling Next() or InternalFetch() updates this value. 1841 Response interface{} 1842 1843 // InternalFetch is for use by the Google Cloud Libraries only. 1844 // It is not part of the stable interface of this package. 1845 // 1846 // InternalFetch returns results from a single call to the underlying RPC. 1847 // The number of results is no greater than pageSize. 1848 // If there are no more results, nextPageToken is empty and err is nil. 1849 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.IosAppDataStream, nextPageToken string, err error) 1850} 1851 1852// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1853func (it *IosAppDataStreamIterator) PageInfo() *iterator.PageInfo { 1854 return it.pageInfo 1855} 1856 1857// Next returns the next result. Its second return value is iterator.Done if there are no more 1858// results. Once Next returns Done, all subsequent calls will return Done. 1859func (it *IosAppDataStreamIterator) Next() (*adminpb.IosAppDataStream, error) { 1860 var item *adminpb.IosAppDataStream 1861 if err := it.nextFunc(); err != nil { 1862 return item, err 1863 } 1864 item = it.items[0] 1865 it.items = it.items[1:] 1866 return item, nil 1867} 1868 1869func (it *IosAppDataStreamIterator) bufLen() int { 1870 return len(it.items) 1871} 1872 1873func (it *IosAppDataStreamIterator) takeBuf() interface{} { 1874 b := it.items 1875 it.items = nil 1876 return b 1877} 1878 1879// PropertyIterator manages a stream of *adminpb.Property. 1880type PropertyIterator struct { 1881 items []*adminpb.Property 1882 pageInfo *iterator.PageInfo 1883 nextFunc func() error 1884 1885 // Response is the raw response for the current page. 1886 // It must be cast to the RPC response type. 1887 // Calling Next() or InternalFetch() updates this value. 1888 Response interface{} 1889 1890 // InternalFetch is for use by the Google Cloud Libraries only. 1891 // It is not part of the stable interface of this package. 1892 // 1893 // InternalFetch returns results from a single call to the underlying RPC. 1894 // The number of results is no greater than pageSize. 1895 // If there are no more results, nextPageToken is empty and err is nil. 1896 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.Property, nextPageToken string, err error) 1897} 1898 1899// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1900func (it *PropertyIterator) PageInfo() *iterator.PageInfo { 1901 return it.pageInfo 1902} 1903 1904// Next returns the next result. Its second return value is iterator.Done if there are no more 1905// results. Once Next returns Done, all subsequent calls will return Done. 1906func (it *PropertyIterator) Next() (*adminpb.Property, error) { 1907 var item *adminpb.Property 1908 if err := it.nextFunc(); err != nil { 1909 return item, err 1910 } 1911 item = it.items[0] 1912 it.items = it.items[1:] 1913 return item, nil 1914} 1915 1916func (it *PropertyIterator) bufLen() int { 1917 return len(it.items) 1918} 1919 1920func (it *PropertyIterator) takeBuf() interface{} { 1921 b := it.items 1922 it.items = nil 1923 return b 1924} 1925 1926// UserLinkIterator manages a stream of *adminpb.UserLink. 1927type UserLinkIterator struct { 1928 items []*adminpb.UserLink 1929 pageInfo *iterator.PageInfo 1930 nextFunc func() error 1931 1932 // Response is the raw response for the current page. 1933 // It must be cast to the RPC response type. 1934 // Calling Next() or InternalFetch() updates this value. 1935 Response interface{} 1936 1937 // InternalFetch is for use by the Google Cloud Libraries only. 1938 // It is not part of the stable interface of this package. 1939 // 1940 // InternalFetch returns results from a single call to the underlying RPC. 1941 // The number of results is no greater than pageSize. 1942 // If there are no more results, nextPageToken is empty and err is nil. 1943 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.UserLink, nextPageToken string, err error) 1944} 1945 1946// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1947func (it *UserLinkIterator) PageInfo() *iterator.PageInfo { 1948 return it.pageInfo 1949} 1950 1951// Next returns the next result. Its second return value is iterator.Done if there are no more 1952// results. Once Next returns Done, all subsequent calls will return Done. 1953func (it *UserLinkIterator) Next() (*adminpb.UserLink, error) { 1954 var item *adminpb.UserLink 1955 if err := it.nextFunc(); err != nil { 1956 return item, err 1957 } 1958 item = it.items[0] 1959 it.items = it.items[1:] 1960 return item, nil 1961} 1962 1963func (it *UserLinkIterator) bufLen() int { 1964 return len(it.items) 1965} 1966 1967func (it *UserLinkIterator) takeBuf() interface{} { 1968 b := it.items 1969 it.items = nil 1970 return b 1971} 1972 1973// WebDataStreamIterator manages a stream of *adminpb.WebDataStream. 1974type WebDataStreamIterator struct { 1975 items []*adminpb.WebDataStream 1976 pageInfo *iterator.PageInfo 1977 nextFunc func() error 1978 1979 // Response is the raw response for the current page. 1980 // It must be cast to the RPC response type. 1981 // Calling Next() or InternalFetch() updates this value. 1982 Response interface{} 1983 1984 // InternalFetch is for use by the Google Cloud Libraries only. 1985 // It is not part of the stable interface of this package. 1986 // 1987 // InternalFetch returns results from a single call to the underlying RPC. 1988 // The number of results is no greater than pageSize. 1989 // If there are no more results, nextPageToken is empty and err is nil. 1990 InternalFetch func(pageSize int, pageToken string) (results []*adminpb.WebDataStream, nextPageToken string, err error) 1991} 1992 1993// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. 1994func (it *WebDataStreamIterator) PageInfo() *iterator.PageInfo { 1995 return it.pageInfo 1996} 1997 1998// Next returns the next result. Its second return value is iterator.Done if there are no more 1999// results. Once Next returns Done, all subsequent calls will return Done. 2000func (it *WebDataStreamIterator) Next() (*adminpb.WebDataStream, error) { 2001 var item *adminpb.WebDataStream 2002 if err := it.nextFunc(); err != nil { 2003 return item, err 2004 } 2005 item = it.items[0] 2006 it.items = it.items[1:] 2007 return item, nil 2008} 2009 2010func (it *WebDataStreamIterator) bufLen() int { 2011 return len(it.items) 2012} 2013 2014func (it *WebDataStreamIterator) takeBuf() interface{} { 2015 b := it.items 2016 it.items = nil 2017 return b 2018} 2019