1 // Copyright 2024 Google LLC. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Code generated file. DO NOT EDIT. 6 7 // Package admin provides access to the Admin SDK API. 8 // 9 // For product documentation, see: https://developers.google.com/admin-sdk/ 10 // 11 // # Library status 12 // 13 // These client libraries are officially supported by Google. However, this 14 // library is considered complete and is in maintenance mode. This means 15 // that we will address critical bugs and security issues but will not add 16 // any new features. 17 // 18 // When possible, we recommend using our newer 19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go) 20 // that are still actively being worked and iterated on. 21 // 22 // # Creating a client 23 // 24 // Usage example: 25 // 26 // import "google.golang.org/api/admin/reports/v1" 27 // ... 28 // ctx := context.Background() 29 // adminService, err := admin.NewService(ctx) 30 // 31 // In this example, Google Application Default Credentials are used for 32 // authentication. For information on how to create and obtain Application 33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 34 // 35 // # Other authentication options 36 // 37 // By default, all available scopes (see "Constants") are used to authenticate. 38 // To restrict scopes, use [google.golang.org/api/option.WithScopes]: 39 // 40 // adminService, err := admin.NewService(ctx, option.WithScopes(admin.AdminReportsUsageReadonlyScope)) 41 // 42 // To use an API key for authentication (note: some APIs do not support API 43 // keys), use [google.golang.org/api/option.WithAPIKey]: 44 // 45 // adminService, err := admin.NewService(ctx, option.WithAPIKey("AIza...")) 46 // 47 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth 48 // flow, use [google.golang.org/api/option.WithTokenSource]: 49 // 50 // config := &oauth2.Config{...} 51 // // ... 52 // token, err := config.Exchange(ctx, ...) 53 // adminService, err := admin.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 54 // 55 // See [google.golang.org/api/option.ClientOption] for details on options. 56 package admin // import "google.golang.org/api/admin/reports/v1" 57 58 import ( 59 "bytes" 60 "context" 61 "encoding/json" 62 "errors" 63 "fmt" 64 "io" 65 "net/http" 66 "net/url" 67 "strconv" 68 "strings" 69 70 googleapi "google.golang.org/api/googleapi" 71 internal "google.golang.org/api/internal" 72 gensupport "google.golang.org/api/internal/gensupport" 73 option "google.golang.org/api/option" 74 internaloption "google.golang.org/api/option/internaloption" 75 htransport "google.golang.org/api/transport/http" 76 ) 77 78 // Always reference these packages, just in case the auto-generated code 79 // below doesn't. 80 var _ = bytes.NewBuffer 81 var _ = strconv.Itoa 82 var _ = fmt.Sprintf 83 var _ = json.NewDecoder 84 var _ = io.Copy 85 var _ = url.Parse 86 var _ = gensupport.MarshalJSON 87 var _ = googleapi.Version 88 var _ = errors.New 89 var _ = strings.Replace 90 var _ = context.Canceled 91 var _ = internaloption.WithDefaultEndpoint 92 var _ = internal.Version 93 94 const apiId = "admin:reports_v1" 95 const apiName = "admin" 96 const apiVersion = "reports_v1" 97 const basePath = "https://admin.googleapis.com/" 98 const basePathTemplate = "https://admin.UNIVERSE_DOMAIN/" 99 const mtlsBasePath = "https://admin.mtls.googleapis.com/" 100 101 // OAuth2 scopes used by this API. 102 const ( 103 // View audit reports for your G Suite domain 104 AdminReportsAuditReadonlyScope = "https://www.googleapis.com/auth/admin.reports.audit.readonly" 105 106 // View usage reports for your G Suite domain 107 AdminReportsUsageReadonlyScope = "https://www.googleapis.com/auth/admin.reports.usage.readonly" 108 ) 109 110 // NewService creates a new Service. 111 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 112 scopesOption := internaloption.WithDefaultScopes( 113 "https://www.googleapis.com/auth/admin.reports.audit.readonly", 114 "https://www.googleapis.com/auth/admin.reports.usage.readonly", 115 ) 116 // NOTE: prepend, so we don't override user-specified scopes. 117 opts = append([]option.ClientOption{scopesOption}, opts...) 118 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 119 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) 120 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 121 opts = append(opts, internaloption.EnableNewAuthLibrary()) 122 client, endpoint, err := htransport.NewClient(ctx, opts...) 123 if err != nil { 124 return nil, err 125 } 126 s, err := New(client) 127 if err != nil { 128 return nil, err 129 } 130 if endpoint != "" { 131 s.BasePath = endpoint 132 } 133 return s, nil 134 } 135 136 // New creates a new Service. It uses the provided http.Client for requests. 137 // 138 // Deprecated: please use NewService instead. 139 // To provide a custom HTTP client, use option.WithHTTPClient. 140 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead. 141 func New(client *http.Client) (*Service, error) { 142 if client == nil { 143 return nil, errors.New("client is nil") 144 } 145 s := &Service{client: client, BasePath: basePath} 146 s.Activities = NewActivitiesService(s) 147 s.Channels = NewChannelsService(s) 148 s.CustomerUsageReports = NewCustomerUsageReportsService(s) 149 s.EntityUsageReports = NewEntityUsageReportsService(s) 150 s.UserUsageReport = NewUserUsageReportService(s) 151 return s, nil 152 } 153 154 type Service struct { 155 client *http.Client 156 BasePath string // API endpoint base URL 157 UserAgent string // optional additional User-Agent fragment 158 159 Activities *ActivitiesService 160 161 Channels *ChannelsService 162 163 CustomerUsageReports *CustomerUsageReportsService 164 165 EntityUsageReports *EntityUsageReportsService 166 167 UserUsageReport *UserUsageReportService 168 } 169 170 func (s *Service) userAgent() string { 171 if s.UserAgent == "" { 172 return googleapi.UserAgent 173 } 174 return googleapi.UserAgent + " " + s.UserAgent 175 } 176 177 func NewActivitiesService(s *Service) *ActivitiesService { 178 rs := &ActivitiesService{s: s} 179 return rs 180 } 181 182 type ActivitiesService struct { 183 s *Service 184 } 185 186 func NewChannelsService(s *Service) *ChannelsService { 187 rs := &ChannelsService{s: s} 188 return rs 189 } 190 191 type ChannelsService struct { 192 s *Service 193 } 194 195 func NewCustomerUsageReportsService(s *Service) *CustomerUsageReportsService { 196 rs := &CustomerUsageReportsService{s: s} 197 return rs 198 } 199 200 type CustomerUsageReportsService struct { 201 s *Service 202 } 203 204 func NewEntityUsageReportsService(s *Service) *EntityUsageReportsService { 205 rs := &EntityUsageReportsService{s: s} 206 return rs 207 } 208 209 type EntityUsageReportsService struct { 210 s *Service 211 } 212 213 func NewUserUsageReportService(s *Service) *UserUsageReportService { 214 rs := &UserUsageReportService{s: s} 215 return rs 216 } 217 218 type UserUsageReportService struct { 219 s *Service 220 } 221 222 // Activities: JSON template for a collection of activities. 223 type Activities struct { 224 // Etag: ETag of the resource. 225 Etag string `json:"etag,omitempty"` 226 // Items: Each activity record in the response. 227 Items []*Activity `json:"items,omitempty"` 228 // Kind: The type of API resource. For an activity report, the value is 229 // `reports#activities`. 230 Kind string `json:"kind,omitempty"` 231 // NextPageToken: Token for retrieving the follow-on next page of the report. 232 // The `nextPageToken` value is used in the request's `pageToken` query string. 233 NextPageToken string `json:"nextPageToken,omitempty"` 234 235 // ServerResponse contains the HTTP response code and headers from the server. 236 googleapi.ServerResponse `json:"-"` 237 // ForceSendFields is a list of field names (e.g. "Etag") to unconditionally 238 // include in API requests. By default, fields with empty or default values are 239 // omitted from API requests. See 240 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 241 // details. 242 ForceSendFields []string `json:"-"` 243 // NullFields is a list of field names (e.g. "Etag") to include in API requests 244 // with the JSON null value. By default, fields with empty values are omitted 245 // from API requests. See 246 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 247 NullFields []string `json:"-"` 248 } 249 250 func (s *Activities) MarshalJSON() ([]byte, error) { 251 type NoMethod Activities 252 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 253 } 254 255 // Activity: JSON template for the activity resource. 256 type Activity struct { 257 // Actor: User doing the action. 258 Actor *ActivityActor `json:"actor,omitempty"` 259 // Etag: ETag of the entry. 260 Etag string `json:"etag,omitempty"` 261 // Events: Activity events in the report. 262 Events []*ActivityEvents `json:"events,omitempty"` 263 // Id: Unique identifier for each activity record. 264 Id *ActivityId `json:"id,omitempty"` 265 // IpAddress: IP address of the user doing the action. This is the Internet 266 // Protocol (IP) address of the user when logging into Google Workspace, which 267 // may or may not reflect the user's physical location. For example, the IP 268 // address can be the user's proxy server's address or a virtual private 269 // network (VPN) address. The API supports IPv4 and IPv6. 270 IpAddress string `json:"ipAddress,omitempty"` 271 // Kind: The type of API resource. For an activity report, the value is 272 // `audit#activity`. 273 Kind string `json:"kind,omitempty"` 274 // OwnerDomain: This is the domain that is affected by the report's event. For 275 // example domain of Admin console or the Drive application's document owner. 276 OwnerDomain string `json:"ownerDomain,omitempty"` 277 // ForceSendFields is a list of field names (e.g. "Actor") to unconditionally 278 // include in API requests. By default, fields with empty or default values are 279 // omitted from API requests. See 280 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 281 // details. 282 ForceSendFields []string `json:"-"` 283 // NullFields is a list of field names (e.g. "Actor") to include in API 284 // requests with the JSON null value. By default, fields with empty values are 285 // omitted from API requests. See 286 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 287 NullFields []string `json:"-"` 288 } 289 290 func (s *Activity) MarshalJSON() ([]byte, error) { 291 type NoMethod Activity 292 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 293 } 294 295 // ActivityActor: User doing the action. 296 type ActivityActor struct { 297 // CallerType: The type of actor. 298 CallerType string `json:"callerType,omitempty"` 299 // Email: The primary email address of the actor. May be absent if there is no 300 // email address associated with the actor. 301 Email string `json:"email,omitempty"` 302 // Key: Only present when `callerType` is `KEY`. Can be the `consumer_key` of 303 // the requestor for OAuth 2LO API requests or an identifier for robot 304 // accounts. 305 Key string `json:"key,omitempty"` 306 // ProfileId: The unique Google Workspace profile ID of the actor. This value 307 // might be absent if the actor is not a Google Workspace user, or may be the 308 // number 105250506097979753968 which acts as a placeholder ID. 309 ProfileId string `json:"profileId,omitempty"` 310 // ForceSendFields is a list of field names (e.g. "CallerType") to 311 // unconditionally include in API requests. By default, fields with empty or 312 // default values are omitted from API requests. See 313 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 314 // details. 315 ForceSendFields []string `json:"-"` 316 // NullFields is a list of field names (e.g. "CallerType") to include in API 317 // requests with the JSON null value. By default, fields with empty values are 318 // omitted from API requests. See 319 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 320 NullFields []string `json:"-"` 321 } 322 323 func (s *ActivityActor) MarshalJSON() ([]byte, error) { 324 type NoMethod ActivityActor 325 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 326 } 327 328 type ActivityEvents struct { 329 // Name: Name of the event. This is the specific name of the activity reported 330 // by the API. And each `eventName` is related to a specific Google Workspace 331 // service or feature which the API organizes into types of events. For 332 // `eventName` request parameters in general: - If no `eventName` is given, the 333 // report returns all possible instances of an `eventName`. - When you request 334 // an `eventName`, the API's response returns all activities which contain that 335 // `eventName`. For more information about `eventName` properties, see the list 336 // of event names for various applications above in `applicationName`. 337 Name string `json:"name,omitempty"` 338 // Parameters: Parameter value pairs for various applications. For more 339 // information about `eventName` parameters, see the list of event names for 340 // various applications above in `applicationName`. 341 Parameters []*ActivityEventsParameters `json:"parameters,omitempty"` 342 // Type: Type of event. The Google Workspace service or feature that an 343 // administrator changes is identified in the `type` property which identifies 344 // an event using the `eventName` property. For a full list of the API's `type` 345 // categories, see the list of event names for various applications above in 346 // `applicationName`. 347 Type string `json:"type,omitempty"` 348 // ForceSendFields is a list of field names (e.g. "Name") to unconditionally 349 // include in API requests. By default, fields with empty or default values are 350 // omitted from API requests. See 351 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 352 // details. 353 ForceSendFields []string `json:"-"` 354 // NullFields is a list of field names (e.g. "Name") to include in API requests 355 // with the JSON null value. By default, fields with empty values are omitted 356 // from API requests. See 357 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 358 NullFields []string `json:"-"` 359 } 360 361 func (s *ActivityEvents) MarshalJSON() ([]byte, error) { 362 type NoMethod ActivityEvents 363 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 364 } 365 366 type ActivityEventsParameters struct { 367 // BoolValue: Boolean value of the parameter. 368 BoolValue bool `json:"boolValue,omitempty"` 369 // IntValue: Integer value of the parameter. 370 IntValue int64 `json:"intValue,omitempty,string"` 371 // MessageValue: Nested parameter value pairs associated with this parameter. 372 // Complex value type for a parameter are returned as a list of parameter 373 // values. For example, the address parameter may have a value as `[{parameter: 374 // [{name: city, value: abc}]}]` 375 MessageValue *ActivityEventsParametersMessageValue `json:"messageValue,omitempty"` 376 // MultiIntValue: Integer values of the parameter. 377 MultiIntValue googleapi.Int64s `json:"multiIntValue,omitempty"` 378 // MultiMessageValue: List of `messageValue` objects. 379 MultiMessageValue []*ActivityEventsParametersMultiMessageValue `json:"multiMessageValue,omitempty"` 380 // MultiValue: String values of the parameter. 381 MultiValue []string `json:"multiValue,omitempty"` 382 // Name: The name of the parameter. 383 Name string `json:"name,omitempty"` 384 // Value: String value of the parameter. 385 Value string `json:"value,omitempty"` 386 // ForceSendFields is a list of field names (e.g. "BoolValue") to 387 // unconditionally include in API requests. By default, fields with empty or 388 // default values are omitted from API requests. See 389 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 390 // details. 391 ForceSendFields []string `json:"-"` 392 // NullFields is a list of field names (e.g. "BoolValue") to include in API 393 // requests with the JSON null value. By default, fields with empty values are 394 // omitted from API requests. See 395 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 396 NullFields []string `json:"-"` 397 } 398 399 func (s *ActivityEventsParameters) MarshalJSON() ([]byte, error) { 400 type NoMethod ActivityEventsParameters 401 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 402 } 403 404 // ActivityEventsParametersMessageValue: Nested parameter value pairs 405 // associated with this parameter. Complex value type for a parameter are 406 // returned as a list of parameter values. For example, the address parameter 407 // may have a value as `[{parameter: [{name: city, value: abc}]}]` 408 type ActivityEventsParametersMessageValue struct { 409 // Parameter: Parameter values 410 Parameter []*NestedParameter `json:"parameter,omitempty"` 411 // ForceSendFields is a list of field names (e.g. "Parameter") to 412 // unconditionally include in API requests. By default, fields with empty or 413 // default values are omitted from API requests. See 414 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 415 // details. 416 ForceSendFields []string `json:"-"` 417 // NullFields is a list of field names (e.g. "Parameter") to include in API 418 // requests with the JSON null value. By default, fields with empty values are 419 // omitted from API requests. See 420 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 421 NullFields []string `json:"-"` 422 } 423 424 func (s *ActivityEventsParametersMessageValue) MarshalJSON() ([]byte, error) { 425 type NoMethod ActivityEventsParametersMessageValue 426 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 427 } 428 429 type ActivityEventsParametersMultiMessageValue struct { 430 // Parameter: Parameter values 431 Parameter []*NestedParameter `json:"parameter,omitempty"` 432 // ForceSendFields is a list of field names (e.g. "Parameter") to 433 // unconditionally include in API requests. By default, fields with empty or 434 // default values are omitted from API requests. See 435 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 436 // details. 437 ForceSendFields []string `json:"-"` 438 // NullFields is a list of field names (e.g. "Parameter") to include in API 439 // requests with the JSON null value. By default, fields with empty values are 440 // omitted from API requests. See 441 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 442 NullFields []string `json:"-"` 443 } 444 445 func (s *ActivityEventsParametersMultiMessageValue) MarshalJSON() ([]byte, error) { 446 type NoMethod ActivityEventsParametersMultiMessageValue 447 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 448 } 449 450 // ActivityId: Unique identifier for each activity record. 451 type ActivityId struct { 452 // ApplicationName: Application name to which the event belongs. For possible 453 // values see the list of applications above in `applicationName`. 454 ApplicationName string `json:"applicationName,omitempty"` 455 // CustomerId: The unique identifier for a Google Workspace account. 456 CustomerId string `json:"customerId,omitempty"` 457 // Time: Time of occurrence of the activity. This is in UNIX epoch time in 458 // seconds. 459 Time string `json:"time,omitempty"` 460 // UniqueQualifier: Unique qualifier if multiple events have the same time. 461 UniqueQualifier int64 `json:"uniqueQualifier,omitempty,string"` 462 // ForceSendFields is a list of field names (e.g. "ApplicationName") to 463 // unconditionally include in API requests. By default, fields with empty or 464 // default values are omitted from API requests. See 465 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 466 // details. 467 ForceSendFields []string `json:"-"` 468 // NullFields is a list of field names (e.g. "ApplicationName") to include in 469 // API requests with the JSON null value. By default, fields with empty values 470 // are omitted from API requests. See 471 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 472 NullFields []string `json:"-"` 473 } 474 475 func (s *ActivityId) MarshalJSON() ([]byte, error) { 476 type NoMethod ActivityId 477 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 478 } 479 480 // Channel: A notification channel used to watch for resource changes. 481 type Channel struct { 482 // Address: The address where notifications are delivered for this channel. 483 Address string `json:"address,omitempty"` 484 // Expiration: Date and time of notification channel expiration, expressed as a 485 // Unix timestamp, in milliseconds. Optional. 486 Expiration int64 `json:"expiration,omitempty,string"` 487 // Id: A UUID or similar unique string that identifies this channel. 488 Id string `json:"id,omitempty"` 489 // Kind: Identifies this as a notification channel used to watch for changes to 490 // a resource, which is "api#channel". 491 Kind string `json:"kind,omitempty"` 492 // Params: Additional parameters controlling delivery channel behavior. 493 // Optional. 494 Params map[string]string `json:"params,omitempty"` 495 // Payload: A Boolean value to indicate whether payload is wanted. A payload is 496 // data that is sent in the body of an HTTP POST, PUT, or PATCH message and 497 // contains important information about the request. Optional. 498 Payload bool `json:"payload,omitempty"` 499 // ResourceId: An opaque ID that identifies the resource being watched on this 500 // channel. Stable across different API versions. 501 ResourceId string `json:"resourceId,omitempty"` 502 // ResourceUri: A version-specific identifier for the watched resource. 503 ResourceUri string `json:"resourceUri,omitempty"` 504 // Token: An arbitrary string delivered to the target address with each 505 // notification delivered over this channel. Optional. 506 Token string `json:"token,omitempty"` 507 // Type: The type of delivery mechanism used for this channel. The value should 508 // be set to "web_hook". 509 Type string `json:"type,omitempty"` 510 511 // ServerResponse contains the HTTP response code and headers from the server. 512 googleapi.ServerResponse `json:"-"` 513 // ForceSendFields is a list of field names (e.g. "Address") to unconditionally 514 // include in API requests. By default, fields with empty or default values are 515 // omitted from API requests. See 516 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 517 // details. 518 ForceSendFields []string `json:"-"` 519 // NullFields is a list of field names (e.g. "Address") to include in API 520 // requests with the JSON null value. By default, fields with empty values are 521 // omitted from API requests. See 522 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 523 NullFields []string `json:"-"` 524 } 525 526 func (s *Channel) MarshalJSON() ([]byte, error) { 527 type NoMethod Channel 528 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 529 } 530 531 // NestedParameter: JSON template for a parameter used in various reports. 532 type NestedParameter struct { 533 // BoolValue: Boolean value of the parameter. 534 BoolValue bool `json:"boolValue,omitempty"` 535 // IntValue: Integer value of the parameter. 536 IntValue int64 `json:"intValue,omitempty,string"` 537 // MultiBoolValue: Multiple boolean values of the parameter. 538 MultiBoolValue []bool `json:"multiBoolValue,omitempty"` 539 // MultiIntValue: Multiple integer values of the parameter. 540 MultiIntValue googleapi.Int64s `json:"multiIntValue,omitempty"` 541 // MultiValue: Multiple string values of the parameter. 542 MultiValue []string `json:"multiValue,omitempty"` 543 // Name: The name of the parameter. 544 Name string `json:"name,omitempty"` 545 // Value: String value of the parameter. 546 Value string `json:"value,omitempty"` 547 // ForceSendFields is a list of field names (e.g. "BoolValue") to 548 // unconditionally include in API requests. By default, fields with empty or 549 // default values are omitted from API requests. See 550 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 551 // details. 552 ForceSendFields []string `json:"-"` 553 // NullFields is a list of field names (e.g. "BoolValue") to include in API 554 // requests with the JSON null value. By default, fields with empty values are 555 // omitted from API requests. See 556 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 557 NullFields []string `json:"-"` 558 } 559 560 func (s *NestedParameter) MarshalJSON() ([]byte, error) { 561 type NoMethod NestedParameter 562 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 563 } 564 565 // UsageReport: JSON template for a usage report. 566 type UsageReport struct { 567 // Date: Output only. The date of the report request. 568 Date string `json:"date,omitempty"` 569 // Entity: Output only. Information about the type of the item. 570 Entity *UsageReportEntity `json:"entity,omitempty"` 571 // Etag: ETag of the resource. 572 Etag string `json:"etag,omitempty"` 573 // Kind: The type of API resource. For a usage report, the value is 574 // `admin#reports#usageReport`. 575 Kind string `json:"kind,omitempty"` 576 // Parameters: Output only. Parameter value pairs for various applications. For 577 // the Entity Usage Report parameters and values, see the Entity Usage 578 // parameters reference 579 // (/admin-sdk/reports/v1/reference/usage-ref-appendix-a/entities). 580 Parameters []*UsageReportParameters `json:"parameters,omitempty"` 581 // ForceSendFields is a list of field names (e.g. "Date") to unconditionally 582 // include in API requests. By default, fields with empty or default values are 583 // omitted from API requests. See 584 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 585 // details. 586 ForceSendFields []string `json:"-"` 587 // NullFields is a list of field names (e.g. "Date") to include in API requests 588 // with the JSON null value. By default, fields with empty values are omitted 589 // from API requests. See 590 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 591 NullFields []string `json:"-"` 592 } 593 594 func (s *UsageReport) MarshalJSON() ([]byte, error) { 595 type NoMethod UsageReport 596 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 597 } 598 599 // UsageReportEntity: Output only. Information about the type of the item. 600 type UsageReportEntity struct { 601 // CustomerId: Output only. The unique identifier of the customer's account. 602 CustomerId string `json:"customerId,omitempty"` 603 // EntityId: Output only. Object key. Only relevant if entity.type = "OBJECT" 604 // Note: external-facing name of report is "Entities" rather than "Objects". 605 EntityId string `json:"entityId,omitempty"` 606 // ProfileId: Output only. The user's immutable Google Workspace profile 607 // identifier. 608 ProfileId string `json:"profileId,omitempty"` 609 // Type: Output only. The type of item. The value is `user`. 610 Type string `json:"type,omitempty"` 611 // UserEmail: Output only. The user's email address. Only relevant if 612 // entity.type = "USER" 613 UserEmail string `json:"userEmail,omitempty"` 614 // ForceSendFields is a list of field names (e.g. "CustomerId") to 615 // unconditionally include in API requests. By default, fields with empty or 616 // default values are omitted from API requests. See 617 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 618 // details. 619 ForceSendFields []string `json:"-"` 620 // NullFields is a list of field names (e.g. "CustomerId") to include in API 621 // requests with the JSON null value. By default, fields with empty values are 622 // omitted from API requests. See 623 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 624 NullFields []string `json:"-"` 625 } 626 627 func (s *UsageReportEntity) MarshalJSON() ([]byte, error) { 628 type NoMethod UsageReportEntity 629 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 630 } 631 632 type UsageReportParameters struct { 633 // BoolValue: Output only. Boolean value of the parameter. 634 BoolValue bool `json:"boolValue,omitempty"` 635 // DatetimeValue: The RFC 3339 formatted value of the parameter, for example 636 // 2010-10-28T10:26:35.000Z. 637 DatetimeValue string `json:"datetimeValue,omitempty"` 638 // IntValue: Output only. Integer value of the parameter. 639 IntValue int64 `json:"intValue,omitempty,string"` 640 // MsgValue: Output only. Nested message value of the parameter. 641 MsgValue []googleapi.RawMessage `json:"msgValue,omitempty"` 642 // Name: The name of the parameter. For the User Usage Report parameter names, 643 // see the User Usage parameters reference. 644 Name string `json:"name,omitempty"` 645 // StringValue: Output only. String value of the parameter. 646 StringValue string `json:"stringValue,omitempty"` 647 // ForceSendFields is a list of field names (e.g. "BoolValue") to 648 // unconditionally include in API requests. By default, fields with empty or 649 // default values are omitted from API requests. See 650 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 651 // details. 652 ForceSendFields []string `json:"-"` 653 // NullFields is a list of field names (e.g. "BoolValue") to include in API 654 // requests with the JSON null value. By default, fields with empty values are 655 // omitted from API requests. See 656 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 657 NullFields []string `json:"-"` 658 } 659 660 func (s *UsageReportParameters) MarshalJSON() ([]byte, error) { 661 type NoMethod UsageReportParameters 662 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 663 } 664 665 type UsageReports struct { 666 // Etag: ETag of the resource. 667 Etag string `json:"etag,omitempty"` 668 // Kind: The type of API resource. For a usage report, the value is 669 // `admin#reports#usageReports`. 670 Kind string `json:"kind,omitempty"` 671 // NextPageToken: Token to specify next page. A report with multiple pages has 672 // a `nextPageToken` property in the response. For your follow-on requests 673 // getting all of the report's pages, enter the `nextPageToken` value in the 674 // `pageToken` query string. 675 NextPageToken string `json:"nextPageToken,omitempty"` 676 // UsageReports: Various application parameter records. 677 UsageReports []*UsageReport `json:"usageReports,omitempty"` 678 // Warnings: Warnings, if any. 679 Warnings []*UsageReportsWarnings `json:"warnings,omitempty"` 680 681 // ServerResponse contains the HTTP response code and headers from the server. 682 googleapi.ServerResponse `json:"-"` 683 // ForceSendFields is a list of field names (e.g. "Etag") to unconditionally 684 // include in API requests. By default, fields with empty or default values are 685 // omitted from API requests. See 686 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 687 // details. 688 ForceSendFields []string `json:"-"` 689 // NullFields is a list of field names (e.g. "Etag") to include in API requests 690 // with the JSON null value. By default, fields with empty values are omitted 691 // from API requests. See 692 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 693 NullFields []string `json:"-"` 694 } 695 696 func (s *UsageReports) MarshalJSON() ([]byte, error) { 697 type NoMethod UsageReports 698 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 699 } 700 701 type UsageReportsWarnings struct { 702 // Code: Machine readable code or warning type. The warning code value is 703 // `200`. 704 Code string `json:"code,omitempty"` 705 // Data: Key-value pairs to give detailed information on the warning. 706 Data []*UsageReportsWarningsData `json:"data,omitempty"` 707 // Message: The human readable messages for a warning are: - Data is not 708 // available warning - Sorry, data for date yyyy-mm-dd for application 709 // "application name" is not available. - Partial data is available warning - 710 // Data for date yyyy-mm-dd for application "application name" is not 711 // available right now, please try again after a few hours. 712 Message string `json:"message,omitempty"` 713 // ForceSendFields is a list of field names (e.g. "Code") to unconditionally 714 // include in API requests. By default, fields with empty or default values are 715 // omitted from API requests. See 716 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 717 // details. 718 ForceSendFields []string `json:"-"` 719 // NullFields is a list of field names (e.g. "Code") to include in API requests 720 // with the JSON null value. By default, fields with empty values are omitted 721 // from API requests. See 722 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 723 NullFields []string `json:"-"` 724 } 725 726 func (s *UsageReportsWarnings) MarshalJSON() ([]byte, error) { 727 type NoMethod UsageReportsWarnings 728 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 729 } 730 731 type UsageReportsWarningsData struct { 732 // Key: Key associated with a key-value pair to give detailed information on 733 // the warning. 734 Key string `json:"key,omitempty"` 735 // Value: Value associated with a key-value pair to give detailed information 736 // on the warning. 737 Value string `json:"value,omitempty"` 738 // ForceSendFields is a list of field names (e.g. "Key") to unconditionally 739 // include in API requests. By default, fields with empty or default values are 740 // omitted from API requests. See 741 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more 742 // details. 743 ForceSendFields []string `json:"-"` 744 // NullFields is a list of field names (e.g. "Key") to include in API requests 745 // with the JSON null value. By default, fields with empty values are omitted 746 // from API requests. See 747 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details. 748 NullFields []string `json:"-"` 749 } 750 751 func (s *UsageReportsWarningsData) MarshalJSON() ([]byte, error) { 752 type NoMethod UsageReportsWarningsData 753 return gensupport.MarshalJSON(NoMethod(*s), s.ForceSendFields, s.NullFields) 754 } 755 756 type ActivitiesListCall struct { 757 s *Service 758 userKey string 759 applicationName string 760 urlParams_ gensupport.URLParams 761 ifNoneMatch_ string 762 ctx_ context.Context 763 header_ http.Header 764 } 765 766 // List: Retrieves a list of activities for a specific customer's account and 767 // application such as the Admin console application or the Google Drive 768 // application. For more information, see the guides for administrator and 769 // Google Drive activity reports. For more information about the activity 770 // report's parameters, see the activity parameters reference guides. 771 // 772 // - applicationName: Application name for which the events are to be 773 // retrieved. 774 // - userKey: Represents the profile ID or the user email for which the data 775 // should be filtered. Can be `all` for all information, or `userKey` for a 776 // user's unique Google Workspace profile ID or their primary email address. 777 // Must not be a deleted user. For a deleted user, call `users.list` in 778 // Directory API with `showDeleted=true`, then use the returned `ID` as the 779 // `userKey`. 780 func (r *ActivitiesService) List(userKey string, applicationName string) *ActivitiesListCall { 781 c := &ActivitiesListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 782 c.userKey = userKey 783 c.applicationName = applicationName 784 return c 785 } 786 787 // ActorIpAddress sets the optional parameter "actorIpAddress": The Internet 788 // Protocol (IP) Address of host where the event was performed. This is an 789 // additional way to filter a report's summary using the IP address of the user 790 // whose activity is being reported. This IP address may or may not reflect the 791 // user's physical location. For example, the IP address can be the user's 792 // proxy server's address or a virtual private network (VPN) address. This 793 // parameter supports both IPv4 and IPv6 address versions. 794 func (c *ActivitiesListCall) ActorIpAddress(actorIpAddress string) *ActivitiesListCall { 795 c.urlParams_.Set("actorIpAddress", actorIpAddress) 796 return c 797 } 798 799 // CustomerId sets the optional parameter "customerId": The unique ID of the 800 // customer to retrieve data for. 801 func (c *ActivitiesListCall) CustomerId(customerId string) *ActivitiesListCall { 802 c.urlParams_.Set("customerId", customerId) 803 return c 804 } 805 806 // EndTime sets the optional parameter "endTime": Sets the end of the range of 807 // time shown in the report. The date is in the RFC 3339 format, for example 808 // 2010-10-28T10:26:35.000Z. The default value is the approximate time of the 809 // API request. An API report has three basic time concepts: - *Date of the 810 // API's request for a report*: When the API created and retrieved the report. 811 // - *Report's start time*: The beginning of the timespan shown in the report. 812 // The `startTime` must be before the `endTime` (if specified) and the current 813 // time when the request is made, or the API returns an error. - *Report's end 814 // time*: The end of the timespan shown in the report. For example, the 815 // timespan of events summarized in a report can start in April and end in May. 816 // The report itself can be requested in August. If the `endTime` is not 817 // specified, the report returns all activities from the `startTime` until the 818 // current time or the most recent 180 days if the `startTime` is more than 180 819 // days in the past. 820 func (c *ActivitiesListCall) EndTime(endTime string) *ActivitiesListCall { 821 c.urlParams_.Set("endTime", endTime) 822 return c 823 } 824 825 // EventName sets the optional parameter "eventName": The name of the event 826 // being queried by the API. Each `eventName` is related to a specific Google 827 // Workspace service or feature which the API organizes into types of events. 828 // An example is the Google Calendar events in the Admin console application's 829 // reports. The Calendar Settings `type` structure has all of the Calendar 830 // `eventName` activities reported by the API. When an administrator changes a 831 // Calendar setting, the API reports this activity in the Calendar Settings 832 // `type` and `eventName` parameters. For more information about `eventName` 833 // query strings and parameters, see the list of event names for various 834 // applications above in `applicationName`. 835 func (c *ActivitiesListCall) EventName(eventName string) *ActivitiesListCall { 836 c.urlParams_.Set("eventName", eventName) 837 return c 838 } 839 840 // Filters sets the optional parameter "filters": The `filters` query string is 841 // a comma-separated list composed of event parameters manipulated by 842 // relational operators. Event parameters are in the form `{parameter1 843 // name}{relational operator}{parameter1 value},{parameter2 name}{relational 844 // operator}{parameter2 value},...` These event parameters are associated with 845 // a specific `eventName`. An empty report is returned if the request's 846 // parameter doesn't belong to the `eventName`. For more information about the 847 // available `eventName` fields for each application and their associated 848 // parameters, go to the ApplicationName (#applicationname) table, then click 849 // through to the Activity Events page in the Appendix for the application you 850 // want. In the following Drive activity examples, the returned list consists 851 // of all `edit` events where the `doc_id` parameter value matches the 852 // conditions defined by the relational operator. In the first example, the 853 // request returns all edited documents with a `doc_id` value equal to `12345`. 854 // In the second example, the report returns any edited documents where the 855 // `doc_id` value is not equal to `98765`. The `<>` operator is URL-encoded in 856 // the request's query string (`%3C%3E`): ``` 857 // GET...&eventName=edit&filters=doc_id==12345 858 // GET...&eventName=edit&filters=doc_id%3C%3E98765 ``` A `filters` query 859 // supports these relational operators: * `==`—'equal to'. * `<>`—'not 860 // equal to'. Must be URL-encoded (%3C%3E). * `<`—'less than'. Must be 861 // URL-encoded (%3C). * `<=`—'less than or equal to'. Must be URL-encoded 862 // (%3C=). * `>`—'greater than'. Must be URL-encoded (%3E). * `>=`—'greater 863 // than or equal to'. Must be URL-encoded (%3E=). **Note:** The API doesn't 864 // accept multiple values of the same parameter. If a parameter is supplied 865 // more than once in the API request, the API only accepts the last value of 866 // that parameter. In addition, if an invalid parameter is supplied in the API 867 // request, the API ignores that parameter and returns the response 868 // corresponding to the remaining valid parameters. If no parameters are 869 // requested, all parameters are returned. 870 func (c *ActivitiesListCall) Filters(filters string) *ActivitiesListCall { 871 c.urlParams_.Set("filters", filters) 872 return c 873 } 874 875 // GroupIdFilter sets the optional parameter "groupIdFilter": Comma separated 876 // group ids (obfuscated) on which user activities are filtered, i.e. the 877 // response will contain activities for only those users that are a part of at 878 // least one of the group ids mentioned here. Format: "id:abc123,id:xyz456" 879 func (c *ActivitiesListCall) GroupIdFilter(groupIdFilter string) *ActivitiesListCall { 880 c.urlParams_.Set("groupIdFilter", groupIdFilter) 881 return c 882 } 883 884 // MaxResults sets the optional parameter "maxResults": Determines how many 885 // activity records are shown on each response page. For example, if the 886 // request sets `maxResults=1` and the report has two activities, the report 887 // has two pages. The response's `nextPageToken` property has the token to the 888 // second page. The `maxResults` query string is optional in the request. The 889 // default value is 1000. 890 func (c *ActivitiesListCall) MaxResults(maxResults int64) *ActivitiesListCall { 891 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults)) 892 return c 893 } 894 895 // OrgUnitID sets the optional parameter "orgUnitID": ID of the organizational 896 // unit to report on. Activity records will be shown only for users who belong 897 // to the specified organizational unit. Data before Dec 17, 2018 doesn't 898 // appear in the filtered results. 899 func (c *ActivitiesListCall) OrgUnitID(orgUnitID string) *ActivitiesListCall { 900 c.urlParams_.Set("orgUnitID", orgUnitID) 901 return c 902 } 903 904 // PageToken sets the optional parameter "pageToken": The token to specify next 905 // page. A report with multiple pages has a `nextPageToken` property in the 906 // response. In your follow-on request getting the next page of the report, 907 // enter the `nextPageToken` value in the `pageToken` query string. 908 func (c *ActivitiesListCall) PageToken(pageToken string) *ActivitiesListCall { 909 c.urlParams_.Set("pageToken", pageToken) 910 return c 911 } 912 913 // StartTime sets the optional parameter "startTime": Sets the beginning of the 914 // range of time shown in the report. The date is in the RFC 3339 format, for 915 // example 2010-10-28T10:26:35.000Z. The report returns all activities from 916 // `startTime` until `endTime`. The `startTime` must be before the `endTime` 917 // (if specified) and the current time when the request is made, or the API 918 // returns an error. 919 func (c *ActivitiesListCall) StartTime(startTime string) *ActivitiesListCall { 920 c.urlParams_.Set("startTime", startTime) 921 return c 922 } 923 924 // Fields allows partial responses to be retrieved. See 925 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 926 // details. 927 func (c *ActivitiesListCall) Fields(s ...googleapi.Field) *ActivitiesListCall { 928 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 929 return c 930 } 931 932 // IfNoneMatch sets an optional parameter which makes the operation fail if the 933 // object's ETag matches the given value. This is useful for getting updates 934 // only after the object has changed since the last request. 935 func (c *ActivitiesListCall) IfNoneMatch(entityTag string) *ActivitiesListCall { 936 c.ifNoneMatch_ = entityTag 937 return c 938 } 939 940 // Context sets the context to be used in this call's Do method. 941 func (c *ActivitiesListCall) Context(ctx context.Context) *ActivitiesListCall { 942 c.ctx_ = ctx 943 return c 944 } 945 946 // Header returns a http.Header that can be modified by the caller to add 947 // headers to the request. 948 func (c *ActivitiesListCall) Header() http.Header { 949 if c.header_ == nil { 950 c.header_ = make(http.Header) 951 } 952 return c.header_ 953 } 954 955 func (c *ActivitiesListCall) doRequest(alt string) (*http.Response, error) { 956 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 957 if c.ifNoneMatch_ != "" { 958 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 959 } 960 var body io.Reader = nil 961 c.urlParams_.Set("alt", alt) 962 c.urlParams_.Set("prettyPrint", "false") 963 urls := googleapi.ResolveRelative(c.s.BasePath, "admin/reports/v1/activity/users/{userKey}/applications/{applicationName}") 964 urls += "?" + c.urlParams_.Encode() 965 req, err := http.NewRequest("GET", urls, body) 966 if err != nil { 967 return nil, err 968 } 969 req.Header = reqHeaders 970 googleapi.Expand(req.URL, map[string]string{ 971 "userKey": c.userKey, 972 "applicationName": c.applicationName, 973 }) 974 return gensupport.SendRequest(c.ctx_, c.s.client, req) 975 } 976 977 // Do executes the "reports.activities.list" call. 978 // Any non-2xx status code is an error. Response headers are in either 979 // *Activities.ServerResponse.Header or (if a response was returned at all) in 980 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 981 // whether the returned error was because http.StatusNotModified was returned. 982 func (c *ActivitiesListCall) Do(opts ...googleapi.CallOption) (*Activities, error) { 983 gensupport.SetOptions(c.urlParams_, opts...) 984 res, err := c.doRequest("json") 985 if res != nil && res.StatusCode == http.StatusNotModified { 986 if res.Body != nil { 987 res.Body.Close() 988 } 989 return nil, gensupport.WrapError(&googleapi.Error{ 990 Code: res.StatusCode, 991 Header: res.Header, 992 }) 993 } 994 if err != nil { 995 return nil, err 996 } 997 defer googleapi.CloseBody(res) 998 if err := googleapi.CheckResponse(res); err != nil { 999 return nil, gensupport.WrapError(err) 1000 } 1001 ret := &Activities{ 1002 ServerResponse: googleapi.ServerResponse{ 1003 Header: res.Header, 1004 HTTPStatusCode: res.StatusCode, 1005 }, 1006 } 1007 target := &ret 1008 if err := gensupport.DecodeResponse(target, res); err != nil { 1009 return nil, err 1010 } 1011 return ret, nil 1012 } 1013 1014 // Pages invokes f for each page of results. 1015 // A non-nil error returned from f will halt the iteration. 1016 // The provided context supersedes any context provided to the Context method. 1017 func (c *ActivitiesListCall) Pages(ctx context.Context, f func(*Activities) error) error { 1018 c.ctx_ = ctx 1019 defer c.PageToken(c.urlParams_.Get("pageToken")) 1020 for { 1021 x, err := c.Do() 1022 if err != nil { 1023 return err 1024 } 1025 if err := f(x); err != nil { 1026 return err 1027 } 1028 if x.NextPageToken == "" { 1029 return nil 1030 } 1031 c.PageToken(x.NextPageToken) 1032 } 1033 } 1034 1035 type ActivitiesWatchCall struct { 1036 s *Service 1037 userKey string 1038 applicationName string 1039 channel *Channel 1040 urlParams_ gensupport.URLParams 1041 ctx_ context.Context 1042 header_ http.Header 1043 } 1044 1045 // Watch: Start receiving notifications for account activities. For more 1046 // information, see Receiving Push Notifications. 1047 // 1048 // - applicationName: Application name for which the events are to be 1049 // retrieved. 1050 // - userKey: Represents the profile ID or the user email for which the data 1051 // should be filtered. Can be `all` for all information, or `userKey` for a 1052 // user's unique Google Workspace profile ID or their primary email address. 1053 // Must not be a deleted user. For a deleted user, call `users.list` in 1054 // Directory API with `showDeleted=true`, then use the returned `ID` as the 1055 // `userKey`. 1056 func (r *ActivitiesService) Watch(userKey string, applicationName string, channel *Channel) *ActivitiesWatchCall { 1057 c := &ActivitiesWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1058 c.userKey = userKey 1059 c.applicationName = applicationName 1060 c.channel = channel 1061 return c 1062 } 1063 1064 // ActorIpAddress sets the optional parameter "actorIpAddress": The Internet 1065 // Protocol (IP) Address of host where the event was performed. This is an 1066 // additional way to filter a report's summary using the IP address of the user 1067 // whose activity is being reported. This IP address may or may not reflect the 1068 // user's physical location. For example, the IP address can be the user's 1069 // proxy server's address or a virtual private network (VPN) address. This 1070 // parameter supports both IPv4 and IPv6 address versions. 1071 func (c *ActivitiesWatchCall) ActorIpAddress(actorIpAddress string) *ActivitiesWatchCall { 1072 c.urlParams_.Set("actorIpAddress", actorIpAddress) 1073 return c 1074 } 1075 1076 // CustomerId sets the optional parameter "customerId": The unique ID of the 1077 // customer to retrieve data for. 1078 func (c *ActivitiesWatchCall) CustomerId(customerId string) *ActivitiesWatchCall { 1079 c.urlParams_.Set("customerId", customerId) 1080 return c 1081 } 1082 1083 // EndTime sets the optional parameter "endTime": Sets the end of the range of 1084 // time shown in the report. The date is in the RFC 3339 format, for example 1085 // 2010-10-28T10:26:35.000Z. The default value is the approximate time of the 1086 // API request. An API report has three basic time concepts: - *Date of the 1087 // API's request for a report*: When the API created and retrieved the report. 1088 // - *Report's start time*: The beginning of the timespan shown in the report. 1089 // The `startTime` must be before the `endTime` (if specified) and the current 1090 // time when the request is made, or the API returns an error. - *Report's end 1091 // time*: The end of the timespan shown in the report. For example, the 1092 // timespan of events summarized in a report can start in April and end in May. 1093 // The report itself can be requested in August. If the `endTime` is not 1094 // specified, the report returns all activities from the `startTime` until the 1095 // current time or the most recent 180 days if the `startTime` is more than 180 1096 // days in the past. 1097 func (c *ActivitiesWatchCall) EndTime(endTime string) *ActivitiesWatchCall { 1098 c.urlParams_.Set("endTime", endTime) 1099 return c 1100 } 1101 1102 // EventName sets the optional parameter "eventName": The name of the event 1103 // being queried by the API. Each `eventName` is related to a specific Google 1104 // Workspace service or feature which the API organizes into types of events. 1105 // An example is the Google Calendar events in the Admin console application's 1106 // reports. The Calendar Settings `type` structure has all of the Calendar 1107 // `eventName` activities reported by the API. When an administrator changes a 1108 // Calendar setting, the API reports this activity in the Calendar Settings 1109 // `type` and `eventName` parameters. For more information about `eventName` 1110 // query strings and parameters, see the list of event names for various 1111 // applications above in `applicationName`. 1112 func (c *ActivitiesWatchCall) EventName(eventName string) *ActivitiesWatchCall { 1113 c.urlParams_.Set("eventName", eventName) 1114 return c 1115 } 1116 1117 // Filters sets the optional parameter "filters": The `filters` query string is 1118 // a comma-separated list composed of event parameters manipulated by 1119 // relational operators. Event parameters are in the form `{parameter1 1120 // name}{relational operator}{parameter1 value},{parameter2 name}{relational 1121 // operator}{parameter2 value},...` These event parameters are associated with 1122 // a specific `eventName`. An empty report is returned if the request's 1123 // parameter doesn't belong to the `eventName`. For more information about the 1124 // available `eventName` fields for each application and their associated 1125 // parameters, go to the ApplicationName (#applicationname) table, then click 1126 // through to the Activity Events page in the Appendix for the application you 1127 // want. In the following Drive activity examples, the returned list consists 1128 // of all `edit` events where the `doc_id` parameter value matches the 1129 // conditions defined by the relational operator. In the first example, the 1130 // request returns all edited documents with a `doc_id` value equal to `12345`. 1131 // In the second example, the report returns any edited documents where the 1132 // `doc_id` value is not equal to `98765`. The `<>` operator is URL-encoded in 1133 // the request's query string (`%3C%3E`): ``` 1134 // GET...&eventName=edit&filters=doc_id==12345 1135 // GET...&eventName=edit&filters=doc_id%3C%3E98765 ``` A `filters` query 1136 // supports these relational operators: * `==`—'equal to'. * `<>`—'not 1137 // equal to'. Must be URL-encoded (%3C%3E). * `<`—'less than'. Must be 1138 // URL-encoded (%3C). * `<=`—'less than or equal to'. Must be URL-encoded 1139 // (%3C=). * `>`—'greater than'. Must be URL-encoded (%3E). * `>=`—'greater 1140 // than or equal to'. Must be URL-encoded (%3E=). **Note:** The API doesn't 1141 // accept multiple values of the same parameter. If a parameter is supplied 1142 // more than once in the API request, the API only accepts the last value of 1143 // that parameter. In addition, if an invalid parameter is supplied in the API 1144 // request, the API ignores that parameter and returns the response 1145 // corresponding to the remaining valid parameters. If no parameters are 1146 // requested, all parameters are returned. 1147 func (c *ActivitiesWatchCall) Filters(filters string) *ActivitiesWatchCall { 1148 c.urlParams_.Set("filters", filters) 1149 return c 1150 } 1151 1152 // GroupIdFilter sets the optional parameter "groupIdFilter": Comma separated 1153 // group ids (obfuscated) on which user activities are filtered, i.e. the 1154 // response will contain activities for only those users that are a part of at 1155 // least one of the group ids mentioned here. Format: "id:abc123,id:xyz456" 1156 func (c *ActivitiesWatchCall) GroupIdFilter(groupIdFilter string) *ActivitiesWatchCall { 1157 c.urlParams_.Set("groupIdFilter", groupIdFilter) 1158 return c 1159 } 1160 1161 // MaxResults sets the optional parameter "maxResults": Determines how many 1162 // activity records are shown on each response page. For example, if the 1163 // request sets `maxResults=1` and the report has two activities, the report 1164 // has two pages. The response's `nextPageToken` property has the token to the 1165 // second page. The `maxResults` query string is optional in the request. The 1166 // default value is 1000. 1167 func (c *ActivitiesWatchCall) MaxResults(maxResults int64) *ActivitiesWatchCall { 1168 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults)) 1169 return c 1170 } 1171 1172 // OrgUnitID sets the optional parameter "orgUnitID": `Deprecated`. This field 1173 // is deprecated and is no longer supported. ID of the organizational unit to 1174 // report on. Activity records will be shown only for users who belong to the 1175 // specified organizational unit. Data before Dec 17, 2018 doesn't appear in 1176 // the filtered results. 1177 func (c *ActivitiesWatchCall) OrgUnitID(orgUnitID string) *ActivitiesWatchCall { 1178 c.urlParams_.Set("orgUnitID", orgUnitID) 1179 return c 1180 } 1181 1182 // PageToken sets the optional parameter "pageToken": The token to specify next 1183 // page. A report with multiple pages has a `nextPageToken` property in the 1184 // response. In your follow-on request getting the next page of the report, 1185 // enter the `nextPageToken` value in the `pageToken` query string. 1186 func (c *ActivitiesWatchCall) PageToken(pageToken string) *ActivitiesWatchCall { 1187 c.urlParams_.Set("pageToken", pageToken) 1188 return c 1189 } 1190 1191 // StartTime sets the optional parameter "startTime": Sets the beginning of the 1192 // range of time shown in the report. The date is in the RFC 3339 format, for 1193 // example 2010-10-28T10:26:35.000Z. The report returns all activities from 1194 // `startTime` until `endTime`. The `startTime` must be before the `endTime` 1195 // (if specified) and the current time when the request is made, or the API 1196 // returns an error. 1197 func (c *ActivitiesWatchCall) StartTime(startTime string) *ActivitiesWatchCall { 1198 c.urlParams_.Set("startTime", startTime) 1199 return c 1200 } 1201 1202 // Fields allows partial responses to be retrieved. See 1203 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1204 // details. 1205 func (c *ActivitiesWatchCall) Fields(s ...googleapi.Field) *ActivitiesWatchCall { 1206 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1207 return c 1208 } 1209 1210 // Context sets the context to be used in this call's Do method. 1211 func (c *ActivitiesWatchCall) Context(ctx context.Context) *ActivitiesWatchCall { 1212 c.ctx_ = ctx 1213 return c 1214 } 1215 1216 // Header returns a http.Header that can be modified by the caller to add 1217 // headers to the request. 1218 func (c *ActivitiesWatchCall) Header() http.Header { 1219 if c.header_ == nil { 1220 c.header_ = make(http.Header) 1221 } 1222 return c.header_ 1223 } 1224 1225 func (c *ActivitiesWatchCall) doRequest(alt string) (*http.Response, error) { 1226 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1227 var body io.Reader = nil 1228 body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) 1229 if err != nil { 1230 return nil, err 1231 } 1232 c.urlParams_.Set("alt", alt) 1233 c.urlParams_.Set("prettyPrint", "false") 1234 urls := googleapi.ResolveRelative(c.s.BasePath, "admin/reports/v1/activity/users/{userKey}/applications/{applicationName}/watch") 1235 urls += "?" + c.urlParams_.Encode() 1236 req, err := http.NewRequest("POST", urls, body) 1237 if err != nil { 1238 return nil, err 1239 } 1240 req.Header = reqHeaders 1241 googleapi.Expand(req.URL, map[string]string{ 1242 "userKey": c.userKey, 1243 "applicationName": c.applicationName, 1244 }) 1245 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1246 } 1247 1248 // Do executes the "reports.activities.watch" call. 1249 // Any non-2xx status code is an error. Response headers are in either 1250 // *Channel.ServerResponse.Header or (if a response was returned at all) in 1251 // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1252 // whether the returned error was because http.StatusNotModified was returned. 1253 func (c *ActivitiesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) { 1254 gensupport.SetOptions(c.urlParams_, opts...) 1255 res, err := c.doRequest("json") 1256 if res != nil && res.StatusCode == http.StatusNotModified { 1257 if res.Body != nil { 1258 res.Body.Close() 1259 } 1260 return nil, gensupport.WrapError(&googleapi.Error{ 1261 Code: res.StatusCode, 1262 Header: res.Header, 1263 }) 1264 } 1265 if err != nil { 1266 return nil, err 1267 } 1268 defer googleapi.CloseBody(res) 1269 if err := googleapi.CheckResponse(res); err != nil { 1270 return nil, gensupport.WrapError(err) 1271 } 1272 ret := &Channel{ 1273 ServerResponse: googleapi.ServerResponse{ 1274 Header: res.Header, 1275 HTTPStatusCode: res.StatusCode, 1276 }, 1277 } 1278 target := &ret 1279 if err := gensupport.DecodeResponse(target, res); err != nil { 1280 return nil, err 1281 } 1282 return ret, nil 1283 } 1284 1285 type ChannelsStopCall struct { 1286 s *Service 1287 channel *Channel 1288 urlParams_ gensupport.URLParams 1289 ctx_ context.Context 1290 header_ http.Header 1291 } 1292 1293 // Stop: Stop watching resources through this channel. 1294 func (r *ChannelsService) Stop(channel *Channel) *ChannelsStopCall { 1295 c := &ChannelsStopCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1296 c.channel = channel 1297 return c 1298 } 1299 1300 // Fields allows partial responses to be retrieved. See 1301 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1302 // details. 1303 func (c *ChannelsStopCall) Fields(s ...googleapi.Field) *ChannelsStopCall { 1304 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1305 return c 1306 } 1307 1308 // Context sets the context to be used in this call's Do method. 1309 func (c *ChannelsStopCall) Context(ctx context.Context) *ChannelsStopCall { 1310 c.ctx_ = ctx 1311 return c 1312 } 1313 1314 // Header returns a http.Header that can be modified by the caller to add 1315 // headers to the request. 1316 func (c *ChannelsStopCall) Header() http.Header { 1317 if c.header_ == nil { 1318 c.header_ = make(http.Header) 1319 } 1320 return c.header_ 1321 } 1322 1323 func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) { 1324 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_) 1325 var body io.Reader = nil 1326 body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel) 1327 if err != nil { 1328 return nil, err 1329 } 1330 c.urlParams_.Set("alt", alt) 1331 c.urlParams_.Set("prettyPrint", "false") 1332 urls := googleapi.ResolveRelative(c.s.BasePath, "admin/reports_v1/channels/stop") 1333 urls += "?" + c.urlParams_.Encode() 1334 req, err := http.NewRequest("POST", urls, body) 1335 if err != nil { 1336 return nil, err 1337 } 1338 req.Header = reqHeaders 1339 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1340 } 1341 1342 // Do executes the "admin.channels.stop" call. 1343 func (c *ChannelsStopCall) Do(opts ...googleapi.CallOption) error { 1344 gensupport.SetOptions(c.urlParams_, opts...) 1345 res, err := c.doRequest("json") 1346 if err != nil { 1347 return err 1348 } 1349 defer googleapi.CloseBody(res) 1350 if err := googleapi.CheckResponse(res); err != nil { 1351 return gensupport.WrapError(err) 1352 } 1353 return nil 1354 } 1355 1356 type CustomerUsageReportsGetCall struct { 1357 s *Service 1358 date string 1359 urlParams_ gensupport.URLParams 1360 ifNoneMatch_ string 1361 ctx_ context.Context 1362 header_ http.Header 1363 } 1364 1365 // Get: Retrieves a report which is a collection of properties and statistics 1366 // for a specific customer's account. For more information, see the Customers 1367 // Usage Report guide. For more information about the customer report's 1368 // parameters, see the Customers Usage parameters reference guides. 1369 // 1370 // - date: Represents the date the usage occurred, based on UTC-8:00 (Pacific 1371 // Standard Time). The timestamp is in the ISO 8601 format 1372 // (https://en.wikipedia.org/wiki/ISO_8601), `yyyy-mm-dd`. 1373 func (r *CustomerUsageReportsService) Get(date string) *CustomerUsageReportsGetCall { 1374 c := &CustomerUsageReportsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1375 c.date = date 1376 return c 1377 } 1378 1379 // CustomerId sets the optional parameter "customerId": The unique ID of the 1380 // customer to retrieve data for. 1381 func (c *CustomerUsageReportsGetCall) CustomerId(customerId string) *CustomerUsageReportsGetCall { 1382 c.urlParams_.Set("customerId", customerId) 1383 return c 1384 } 1385 1386 // PageToken sets the optional parameter "pageToken": Token to specify next 1387 // page. A report with multiple pages has a `nextPageToken` property in the 1388 // response. For your follow-on requests getting all of the report's pages, 1389 // enter the `nextPageToken` value in the `pageToken` query string. 1390 func (c *CustomerUsageReportsGetCall) PageToken(pageToken string) *CustomerUsageReportsGetCall { 1391 c.urlParams_.Set("pageToken", pageToken) 1392 return c 1393 } 1394 1395 // Parameters sets the optional parameter "parameters": The `parameters` query 1396 // string is a comma-separated list of event parameters that refine a report's 1397 // results. The parameter is associated with a specific application. The 1398 // application values for the Customers usage report include `accounts`, 1399 // `app_maker`, `apps_scripts`, `calendar`, `classroom`, `cros`, `docs`, 1400 // `gmail`, `gplus`, `device_management`, `meet`, and `sites`. A `parameters` 1401 // query string is in the CSV form of `app_name1:param_name1, 1402 // app_name2:param_name2`. *Note:* The API doesn't accept multiple values of a 1403 // parameter. If a particular parameter is supplied more than once in the API 1404 // request, the API only accepts the last value of that request parameter. In 1405 // addition, if an invalid request parameter is supplied in the API request, 1406 // the API ignores that request parameter and returns the response 1407 // corresponding to the remaining valid request parameters. An example of an 1408 // invalid request parameter is one that does not belong to the application. If 1409 // no parameters are requested, all parameters are returned. 1410 func (c *CustomerUsageReportsGetCall) Parameters(parameters string) *CustomerUsageReportsGetCall { 1411 c.urlParams_.Set("parameters", parameters) 1412 return c 1413 } 1414 1415 // Fields allows partial responses to be retrieved. See 1416 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1417 // details. 1418 func (c *CustomerUsageReportsGetCall) Fields(s ...googleapi.Field) *CustomerUsageReportsGetCall { 1419 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1420 return c 1421 } 1422 1423 // IfNoneMatch sets an optional parameter which makes the operation fail if the 1424 // object's ETag matches the given value. This is useful for getting updates 1425 // only after the object has changed since the last request. 1426 func (c *CustomerUsageReportsGetCall) IfNoneMatch(entityTag string) *CustomerUsageReportsGetCall { 1427 c.ifNoneMatch_ = entityTag 1428 return c 1429 } 1430 1431 // Context sets the context to be used in this call's Do method. 1432 func (c *CustomerUsageReportsGetCall) Context(ctx context.Context) *CustomerUsageReportsGetCall { 1433 c.ctx_ = ctx 1434 return c 1435 } 1436 1437 // Header returns a http.Header that can be modified by the caller to add 1438 // headers to the request. 1439 func (c *CustomerUsageReportsGetCall) Header() http.Header { 1440 if c.header_ == nil { 1441 c.header_ = make(http.Header) 1442 } 1443 return c.header_ 1444 } 1445 1446 func (c *CustomerUsageReportsGetCall) doRequest(alt string) (*http.Response, error) { 1447 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 1448 if c.ifNoneMatch_ != "" { 1449 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1450 } 1451 var body io.Reader = nil 1452 c.urlParams_.Set("alt", alt) 1453 c.urlParams_.Set("prettyPrint", "false") 1454 urls := googleapi.ResolveRelative(c.s.BasePath, "admin/reports/v1/usage/dates/{date}") 1455 urls += "?" + c.urlParams_.Encode() 1456 req, err := http.NewRequest("GET", urls, body) 1457 if err != nil { 1458 return nil, err 1459 } 1460 req.Header = reqHeaders 1461 googleapi.Expand(req.URL, map[string]string{ 1462 "date": c.date, 1463 }) 1464 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1465 } 1466 1467 // Do executes the "reports.customerUsageReports.get" call. 1468 // Any non-2xx status code is an error. Response headers are in either 1469 // *UsageReports.ServerResponse.Header or (if a response was returned at all) 1470 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1471 // whether the returned error was because http.StatusNotModified was returned. 1472 func (c *CustomerUsageReportsGetCall) Do(opts ...googleapi.CallOption) (*UsageReports, error) { 1473 gensupport.SetOptions(c.urlParams_, opts...) 1474 res, err := c.doRequest("json") 1475 if res != nil && res.StatusCode == http.StatusNotModified { 1476 if res.Body != nil { 1477 res.Body.Close() 1478 } 1479 return nil, gensupport.WrapError(&googleapi.Error{ 1480 Code: res.StatusCode, 1481 Header: res.Header, 1482 }) 1483 } 1484 if err != nil { 1485 return nil, err 1486 } 1487 defer googleapi.CloseBody(res) 1488 if err := googleapi.CheckResponse(res); err != nil { 1489 return nil, gensupport.WrapError(err) 1490 } 1491 ret := &UsageReports{ 1492 ServerResponse: googleapi.ServerResponse{ 1493 Header: res.Header, 1494 HTTPStatusCode: res.StatusCode, 1495 }, 1496 } 1497 target := &ret 1498 if err := gensupport.DecodeResponse(target, res); err != nil { 1499 return nil, err 1500 } 1501 return ret, nil 1502 } 1503 1504 // Pages invokes f for each page of results. 1505 // A non-nil error returned from f will halt the iteration. 1506 // The provided context supersedes any context provided to the Context method. 1507 func (c *CustomerUsageReportsGetCall) Pages(ctx context.Context, f func(*UsageReports) error) error { 1508 c.ctx_ = ctx 1509 defer c.PageToken(c.urlParams_.Get("pageToken")) 1510 for { 1511 x, err := c.Do() 1512 if err != nil { 1513 return err 1514 } 1515 if err := f(x); err != nil { 1516 return err 1517 } 1518 if x.NextPageToken == "" { 1519 return nil 1520 } 1521 c.PageToken(x.NextPageToken) 1522 } 1523 } 1524 1525 type EntityUsageReportsGetCall struct { 1526 s *Service 1527 entityType string 1528 entityKey string 1529 date string 1530 urlParams_ gensupport.URLParams 1531 ifNoneMatch_ string 1532 ctx_ context.Context 1533 header_ http.Header 1534 } 1535 1536 // Get: Retrieves a report which is a collection of properties and statistics 1537 // for entities used by users within the account. For more information, see the 1538 // Entities Usage Report guide. For more information about the entities 1539 // report's parameters, see the Entities Usage parameters reference guides. 1540 // 1541 // - date: Represents the date the usage occurred, based on UTC-8:00 (Pacific 1542 // Standard Time). The timestamp is in the ISO 8601 format 1543 // (https://en.wikipedia.org/wiki/ISO_8601), `yyyy-mm-dd`. 1544 // - entityKey: Represents the key of the object to filter the data with. It is 1545 // a string which can take the value `all` to get activity events for all 1546 // users, or any other value for an app-specific entity. For details on how 1547 // to obtain the `entityKey` for a particular `entityType`, see the Entities 1548 // Usage parameters reference guides. 1549 // - entityType: Represents the type of entity for the report. 1550 func (r *EntityUsageReportsService) Get(entityType string, entityKey string, date string) *EntityUsageReportsGetCall { 1551 c := &EntityUsageReportsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1552 c.entityType = entityType 1553 c.entityKey = entityKey 1554 c.date = date 1555 return c 1556 } 1557 1558 // CustomerId sets the optional parameter "customerId": The unique ID of the 1559 // customer to retrieve data for. 1560 func (c *EntityUsageReportsGetCall) CustomerId(customerId string) *EntityUsageReportsGetCall { 1561 c.urlParams_.Set("customerId", customerId) 1562 return c 1563 } 1564 1565 // Filters sets the optional parameter "filters": The `filters` query string is 1566 // a comma-separated list of an application's event parameters where the 1567 // parameter's value is manipulated by a relational operator. The `filters` 1568 // query string includes the name of the application whose usage is returned in 1569 // the report. The application values for the Entities usage report include 1570 // `accounts`, `docs`, and `gmail`. Filters are in the form `[application 1571 // name]:parameter name[parameter value],...`. In this example, the `<>` 'not 1572 // equal to' operator is URL-encoded in the request's query string (%3C%3E): 1573 // GET 1574 // https://www.googleapis.com/admin/reports/v1/usage/gplus_communities/all/dates/2017-12-01 1575 // ?parameters=gplus:community_name,gplus:num_total_members 1576 // &filters=gplus:num_total_members%3C%3E0 The relational operators include: - 1577 // `==` - 'equal to'. - `<>` - 'not equal to'. It is URL-encoded (%3C%3E). - 1578 // `<` - 'less than'. It is URL-encoded (%3C). - `<=` - 'less than or equal 1579 // to'. It is URL-encoded (%3C=). - `>` - 'greater than'. It is URL-encoded 1580 // (%3E). - `>=` - 'greater than or equal to'. It is URL-encoded (%3E=). 1581 // Filters can only be applied to numeric parameters. 1582 func (c *EntityUsageReportsGetCall) Filters(filters string) *EntityUsageReportsGetCall { 1583 c.urlParams_.Set("filters", filters) 1584 return c 1585 } 1586 1587 // MaxResults sets the optional parameter "maxResults": Determines how many 1588 // activity records are shown on each response page. For example, if the 1589 // request sets `maxResults=1` and the report has two activities, the report 1590 // has two pages. The response's `nextPageToken` property has the token to the 1591 // second page. 1592 func (c *EntityUsageReportsGetCall) MaxResults(maxResults int64) *EntityUsageReportsGetCall { 1593 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults)) 1594 return c 1595 } 1596 1597 // PageToken sets the optional parameter "pageToken": Token to specify next 1598 // page. A report with multiple pages has a `nextPageToken` property in the 1599 // response. In your follow-on request getting the next page of the report, 1600 // enter the `nextPageToken` value in the `pageToken` query string. 1601 func (c *EntityUsageReportsGetCall) PageToken(pageToken string) *EntityUsageReportsGetCall { 1602 c.urlParams_.Set("pageToken", pageToken) 1603 return c 1604 } 1605 1606 // Parameters sets the optional parameter "parameters": The `parameters` query 1607 // string is a comma-separated list of event parameters that refine a report's 1608 // results. The parameter is associated with a specific application. The 1609 // application values for the Entities usage report are only `gplus`. A 1610 // `parameter` query string is in the CSV form of `[app_name1:param_name1], 1611 // [app_name2:param_name2]...`. *Note:* The API doesn't accept multiple values 1612 // of a parameter. If a particular parameter is supplied more than once in the 1613 // API request, the API only accepts the last value of that request parameter. 1614 // In addition, if an invalid request parameter is supplied in the API request, 1615 // the API ignores that request parameter and returns the response 1616 // corresponding to the remaining valid request parameters. An example of an 1617 // invalid request parameter is one that does not belong to the application. If 1618 // no parameters are requested, all parameters are returned. 1619 func (c *EntityUsageReportsGetCall) Parameters(parameters string) *EntityUsageReportsGetCall { 1620 c.urlParams_.Set("parameters", parameters) 1621 return c 1622 } 1623 1624 // Fields allows partial responses to be retrieved. See 1625 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1626 // details. 1627 func (c *EntityUsageReportsGetCall) Fields(s ...googleapi.Field) *EntityUsageReportsGetCall { 1628 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1629 return c 1630 } 1631 1632 // IfNoneMatch sets an optional parameter which makes the operation fail if the 1633 // object's ETag matches the given value. This is useful for getting updates 1634 // only after the object has changed since the last request. 1635 func (c *EntityUsageReportsGetCall) IfNoneMatch(entityTag string) *EntityUsageReportsGetCall { 1636 c.ifNoneMatch_ = entityTag 1637 return c 1638 } 1639 1640 // Context sets the context to be used in this call's Do method. 1641 func (c *EntityUsageReportsGetCall) Context(ctx context.Context) *EntityUsageReportsGetCall { 1642 c.ctx_ = ctx 1643 return c 1644 } 1645 1646 // Header returns a http.Header that can be modified by the caller to add 1647 // headers to the request. 1648 func (c *EntityUsageReportsGetCall) Header() http.Header { 1649 if c.header_ == nil { 1650 c.header_ = make(http.Header) 1651 } 1652 return c.header_ 1653 } 1654 1655 func (c *EntityUsageReportsGetCall) doRequest(alt string) (*http.Response, error) { 1656 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 1657 if c.ifNoneMatch_ != "" { 1658 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1659 } 1660 var body io.Reader = nil 1661 c.urlParams_.Set("alt", alt) 1662 c.urlParams_.Set("prettyPrint", "false") 1663 urls := googleapi.ResolveRelative(c.s.BasePath, "admin/reports/v1/usage/{entityType}/{entityKey}/dates/{date}") 1664 urls += "?" + c.urlParams_.Encode() 1665 req, err := http.NewRequest("GET", urls, body) 1666 if err != nil { 1667 return nil, err 1668 } 1669 req.Header = reqHeaders 1670 googleapi.Expand(req.URL, map[string]string{ 1671 "entityType": c.entityType, 1672 "entityKey": c.entityKey, 1673 "date": c.date, 1674 }) 1675 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1676 } 1677 1678 // Do executes the "reports.entityUsageReports.get" call. 1679 // Any non-2xx status code is an error. Response headers are in either 1680 // *UsageReports.ServerResponse.Header or (if a response was returned at all) 1681 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1682 // whether the returned error was because http.StatusNotModified was returned. 1683 func (c *EntityUsageReportsGetCall) Do(opts ...googleapi.CallOption) (*UsageReports, error) { 1684 gensupport.SetOptions(c.urlParams_, opts...) 1685 res, err := c.doRequest("json") 1686 if res != nil && res.StatusCode == http.StatusNotModified { 1687 if res.Body != nil { 1688 res.Body.Close() 1689 } 1690 return nil, gensupport.WrapError(&googleapi.Error{ 1691 Code: res.StatusCode, 1692 Header: res.Header, 1693 }) 1694 } 1695 if err != nil { 1696 return nil, err 1697 } 1698 defer googleapi.CloseBody(res) 1699 if err := googleapi.CheckResponse(res); err != nil { 1700 return nil, gensupport.WrapError(err) 1701 } 1702 ret := &UsageReports{ 1703 ServerResponse: googleapi.ServerResponse{ 1704 Header: res.Header, 1705 HTTPStatusCode: res.StatusCode, 1706 }, 1707 } 1708 target := &ret 1709 if err := gensupport.DecodeResponse(target, res); err != nil { 1710 return nil, err 1711 } 1712 return ret, nil 1713 } 1714 1715 // Pages invokes f for each page of results. 1716 // A non-nil error returned from f will halt the iteration. 1717 // The provided context supersedes any context provided to the Context method. 1718 func (c *EntityUsageReportsGetCall) Pages(ctx context.Context, f func(*UsageReports) error) error { 1719 c.ctx_ = ctx 1720 defer c.PageToken(c.urlParams_.Get("pageToken")) 1721 for { 1722 x, err := c.Do() 1723 if err != nil { 1724 return err 1725 } 1726 if err := f(x); err != nil { 1727 return err 1728 } 1729 if x.NextPageToken == "" { 1730 return nil 1731 } 1732 c.PageToken(x.NextPageToken) 1733 } 1734 } 1735 1736 type UserUsageReportGetCall struct { 1737 s *Service 1738 userKey string 1739 date string 1740 urlParams_ gensupport.URLParams 1741 ifNoneMatch_ string 1742 ctx_ context.Context 1743 header_ http.Header 1744 } 1745 1746 // Get: Retrieves a report which is a collection of properties and statistics 1747 // for a set of users with the account. For more information, see the User 1748 // Usage Report guide. For more information about the user report's parameters, 1749 // see the Users Usage parameters reference guides. 1750 // 1751 // - date: Represents the date the usage occurred, based on UTC-8:00 (Pacific 1752 // Standard Time). The timestamp is in the ISO 8601 format 1753 // (https://en.wikipedia.org/wiki/ISO_8601), `yyyy-mm-dd`. 1754 // - userKey: Represents the profile ID or the user email for which the data 1755 // should be filtered. Can be `all` for all information, or `userKey` for a 1756 // user's unique Google Workspace profile ID or their primary email address. 1757 // Must not be a deleted user. For a deleted user, call `users.list` in 1758 // Directory API with `showDeleted=true`, then use the returned `ID` as the 1759 // `userKey`. 1760 func (r *UserUsageReportService) Get(userKey string, date string) *UserUsageReportGetCall { 1761 c := &UserUsageReportGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1762 c.userKey = userKey 1763 c.date = date 1764 return c 1765 } 1766 1767 // CustomerId sets the optional parameter "customerId": The unique ID of the 1768 // customer to retrieve data for. 1769 func (c *UserUsageReportGetCall) CustomerId(customerId string) *UserUsageReportGetCall { 1770 c.urlParams_.Set("customerId", customerId) 1771 return c 1772 } 1773 1774 // Filters sets the optional parameter "filters": The `filters` query string is 1775 // a comma-separated list of an application's event parameters where the 1776 // parameter's value is manipulated by a relational operator. The `filters` 1777 // query string includes the name of the application whose usage is returned in 1778 // the report. The application values for the Users Usage Report include 1779 // `accounts`, `docs`, and `gmail`. Filters are in the form `[application 1780 // name]:parameter name[parameter value],...`. In this example, the `<>` 'not 1781 // equal to' operator is URL-encoded in the request's query string (%3C%3E): 1782 // GET 1783 // https://www.googleapis.com/admin/reports/v1/usage/users/all/dates/2013-03-03 1784 // ?parameters=accounts:last_login_time 1785 // &filters=accounts:last_login_time%3C%3E2010-10-28T10:26:35.000Z The 1786 // relational operators include: - `==` - 'equal to'. - `<>` - 'not equal to'. 1787 // It is URL-encoded (%3C%3E). - `<` - 'less than'. It is URL-encoded (%3C). - 1788 // `<=` - 'less than or equal to'. It is URL-encoded (%3C=). - `>` - 'greater 1789 // than'. It is URL-encoded (%3E). - `>=` - 'greater than or equal to'. It is 1790 // URL-encoded (%3E=). 1791 func (c *UserUsageReportGetCall) Filters(filters string) *UserUsageReportGetCall { 1792 c.urlParams_.Set("filters", filters) 1793 return c 1794 } 1795 1796 // GroupIdFilter sets the optional parameter "groupIdFilter": Comma separated 1797 // group ids (obfuscated) on which user activities are filtered, i.e. the 1798 // response will contain activities for only those users that are a part of at 1799 // least one of the group ids mentioned here. Format: "id:abc123,id:xyz456" 1800 func (c *UserUsageReportGetCall) GroupIdFilter(groupIdFilter string) *UserUsageReportGetCall { 1801 c.urlParams_.Set("groupIdFilter", groupIdFilter) 1802 return c 1803 } 1804 1805 // MaxResults sets the optional parameter "maxResults": Determines how many 1806 // activity records are shown on each response page. For example, if the 1807 // request sets `maxResults=1` and the report has two activities, the report 1808 // has two pages. The response's `nextPageToken` property has the token to the 1809 // second page. The `maxResults` query string is optional. 1810 func (c *UserUsageReportGetCall) MaxResults(maxResults int64) *UserUsageReportGetCall { 1811 c.urlParams_.Set("maxResults", fmt.Sprint(maxResults)) 1812 return c 1813 } 1814 1815 // OrgUnitID sets the optional parameter "orgUnitID": ID of the organizational 1816 // unit to report on. User activity will be shown only for users who belong to 1817 // the specified organizational unit. Data before Dec 17, 2018 doesn't appear 1818 // in the filtered results. 1819 func (c *UserUsageReportGetCall) OrgUnitID(orgUnitID string) *UserUsageReportGetCall { 1820 c.urlParams_.Set("orgUnitID", orgUnitID) 1821 return c 1822 } 1823 1824 // PageToken sets the optional parameter "pageToken": Token to specify next 1825 // page. A report with multiple pages has a `nextPageToken` property in the 1826 // response. In your follow-on request getting the next page of the report, 1827 // enter the `nextPageToken` value in the `pageToken` query string. 1828 func (c *UserUsageReportGetCall) PageToken(pageToken string) *UserUsageReportGetCall { 1829 c.urlParams_.Set("pageToken", pageToken) 1830 return c 1831 } 1832 1833 // Parameters sets the optional parameter "parameters": The `parameters` query 1834 // string is a comma-separated list of event parameters that refine a report's 1835 // results. The parameter is associated with a specific application. The 1836 // application values for the Customers Usage report include `accounts`, 1837 // `app_maker`, `apps_scripts`, `calendar`, `classroom`, `cros`, `docs`, 1838 // `gmail`, `gplus`, `device_management`, `meet`, and `sites`. A `parameters` 1839 // query string is in the CSV form of `app_name1:param_name1, 1840 // app_name2:param_name2`. *Note:* The API doesn't accept multiple values of a 1841 // parameter. If a particular parameter is supplied more than once in the API 1842 // request, the API only accepts the last value of that request parameter. In 1843 // addition, if an invalid request parameter is supplied in the API request, 1844 // the API ignores that request parameter and returns the response 1845 // corresponding to the remaining valid request parameters. An example of an 1846 // invalid request parameter is one that does not belong to the application. If 1847 // no parameters are requested, all parameters are returned. 1848 func (c *UserUsageReportGetCall) Parameters(parameters string) *UserUsageReportGetCall { 1849 c.urlParams_.Set("parameters", parameters) 1850 return c 1851 } 1852 1853 // Fields allows partial responses to be retrieved. See 1854 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more 1855 // details. 1856 func (c *UserUsageReportGetCall) Fields(s ...googleapi.Field) *UserUsageReportGetCall { 1857 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1858 return c 1859 } 1860 1861 // IfNoneMatch sets an optional parameter which makes the operation fail if the 1862 // object's ETag matches the given value. This is useful for getting updates 1863 // only after the object has changed since the last request. 1864 func (c *UserUsageReportGetCall) IfNoneMatch(entityTag string) *UserUsageReportGetCall { 1865 c.ifNoneMatch_ = entityTag 1866 return c 1867 } 1868 1869 // Context sets the context to be used in this call's Do method. 1870 func (c *UserUsageReportGetCall) Context(ctx context.Context) *UserUsageReportGetCall { 1871 c.ctx_ = ctx 1872 return c 1873 } 1874 1875 // Header returns a http.Header that can be modified by the caller to add 1876 // headers to the request. 1877 func (c *UserUsageReportGetCall) Header() http.Header { 1878 if c.header_ == nil { 1879 c.header_ = make(http.Header) 1880 } 1881 return c.header_ 1882 } 1883 1884 func (c *UserUsageReportGetCall) doRequest(alt string) (*http.Response, error) { 1885 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "", c.header_) 1886 if c.ifNoneMatch_ != "" { 1887 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1888 } 1889 var body io.Reader = nil 1890 c.urlParams_.Set("alt", alt) 1891 c.urlParams_.Set("prettyPrint", "false") 1892 urls := googleapi.ResolveRelative(c.s.BasePath, "admin/reports/v1/usage/users/{userKey}/dates/{date}") 1893 urls += "?" + c.urlParams_.Encode() 1894 req, err := http.NewRequest("GET", urls, body) 1895 if err != nil { 1896 return nil, err 1897 } 1898 req.Header = reqHeaders 1899 googleapi.Expand(req.URL, map[string]string{ 1900 "userKey": c.userKey, 1901 "date": c.date, 1902 }) 1903 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1904 } 1905 1906 // Do executes the "reports.userUsageReport.get" call. 1907 // Any non-2xx status code is an error. Response headers are in either 1908 // *UsageReports.ServerResponse.Header or (if a response was returned at all) 1909 // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1910 // whether the returned error was because http.StatusNotModified was returned. 1911 func (c *UserUsageReportGetCall) Do(opts ...googleapi.CallOption) (*UsageReports, error) { 1912 gensupport.SetOptions(c.urlParams_, opts...) 1913 res, err := c.doRequest("json") 1914 if res != nil && res.StatusCode == http.StatusNotModified { 1915 if res.Body != nil { 1916 res.Body.Close() 1917 } 1918 return nil, gensupport.WrapError(&googleapi.Error{ 1919 Code: res.StatusCode, 1920 Header: res.Header, 1921 }) 1922 } 1923 if err != nil { 1924 return nil, err 1925 } 1926 defer googleapi.CloseBody(res) 1927 if err := googleapi.CheckResponse(res); err != nil { 1928 return nil, gensupport.WrapError(err) 1929 } 1930 ret := &UsageReports{ 1931 ServerResponse: googleapi.ServerResponse{ 1932 Header: res.Header, 1933 HTTPStatusCode: res.StatusCode, 1934 }, 1935 } 1936 target := &ret 1937 if err := gensupport.DecodeResponse(target, res); err != nil { 1938 return nil, err 1939 } 1940 return ret, nil 1941 } 1942 1943 // Pages invokes f for each page of results. 1944 // A non-nil error returned from f will halt the iteration. 1945 // The provided context supersedes any context provided to the Context method. 1946 func (c *UserUsageReportGetCall) Pages(ctx context.Context, f func(*UsageReports) error) error { 1947 c.ctx_ = ctx 1948 defer c.PageToken(c.urlParams_.Get("pageToken")) 1949 for { 1950 x, err := c.Do() 1951 if err != nil { 1952 return err 1953 } 1954 if err := f(x); err != nil { 1955 return err 1956 } 1957 if x.NextPageToken == "" { 1958 return nil 1959 } 1960 c.PageToken(x.NextPageToken) 1961 } 1962 } 1963