You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1973 lines
68 KiB

  1. // Package admin provides access to the Admin Reports API.
  2. //
  3. // See https://developers.google.com/admin-sdk/reports/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/admin/reports/v1"
  8. // ...
  9. // adminService, err := admin.New(oauthHttpClient)
  10. package admin // import "google.golang.org/api/admin/reports/v1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "admin:reports_v1"
  41. const apiName = "admin"
  42. const apiVersion = "reports_v1"
  43. const basePath = "https://www.googleapis.com/admin/reports/v1/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View audit reports for your G Suite domain
  47. AdminReportsAuditReadonlyScope = "https://www.googleapis.com/auth/admin.reports.audit.readonly"
  48. // View usage reports for your G Suite domain
  49. AdminReportsUsageReadonlyScope = "https://www.googleapis.com/auth/admin.reports.usage.readonly"
  50. )
  51. func New(client *http.Client) (*Service, error) {
  52. if client == nil {
  53. return nil, errors.New("client is nil")
  54. }
  55. s := &Service{client: client, BasePath: basePath}
  56. s.Activities = NewActivitiesService(s)
  57. s.Channels = NewChannelsService(s)
  58. s.CustomerUsageReports = NewCustomerUsageReportsService(s)
  59. s.EntityUsageReports = NewEntityUsageReportsService(s)
  60. s.UserUsageReport = NewUserUsageReportService(s)
  61. return s, nil
  62. }
  63. type Service struct {
  64. client *http.Client
  65. BasePath string // API endpoint base URL
  66. UserAgent string // optional additional User-Agent fragment
  67. Activities *ActivitiesService
  68. Channels *ChannelsService
  69. CustomerUsageReports *CustomerUsageReportsService
  70. EntityUsageReports *EntityUsageReportsService
  71. UserUsageReport *UserUsageReportService
  72. }
  73. func (s *Service) userAgent() string {
  74. if s.UserAgent == "" {
  75. return googleapi.UserAgent
  76. }
  77. return googleapi.UserAgent + " " + s.UserAgent
  78. }
  79. func NewActivitiesService(s *Service) *ActivitiesService {
  80. rs := &ActivitiesService{s: s}
  81. return rs
  82. }
  83. type ActivitiesService struct {
  84. s *Service
  85. }
  86. func NewChannelsService(s *Service) *ChannelsService {
  87. rs := &ChannelsService{s: s}
  88. return rs
  89. }
  90. type ChannelsService struct {
  91. s *Service
  92. }
  93. func NewCustomerUsageReportsService(s *Service) *CustomerUsageReportsService {
  94. rs := &CustomerUsageReportsService{s: s}
  95. return rs
  96. }
  97. type CustomerUsageReportsService struct {
  98. s *Service
  99. }
  100. func NewEntityUsageReportsService(s *Service) *EntityUsageReportsService {
  101. rs := &EntityUsageReportsService{s: s}
  102. return rs
  103. }
  104. type EntityUsageReportsService struct {
  105. s *Service
  106. }
  107. func NewUserUsageReportService(s *Service) *UserUsageReportService {
  108. rs := &UserUsageReportService{s: s}
  109. return rs
  110. }
  111. type UserUsageReportService struct {
  112. s *Service
  113. }
  114. // Activities: JSON template for a collection of activites.
  115. type Activities struct {
  116. // Etag: ETag of the resource.
  117. Etag string `json:"etag,omitempty"`
  118. // Items: Each record in read response.
  119. Items []*Activity `json:"items,omitempty"`
  120. // Kind: Kind of list response this is.
  121. Kind string `json:"kind,omitempty"`
  122. // NextPageToken: Token for retrieving the next page
  123. NextPageToken string `json:"nextPageToken,omitempty"`
  124. // ServerResponse contains the HTTP response code and headers from the
  125. // server.
  126. googleapi.ServerResponse `json:"-"`
  127. // ForceSendFields is a list of field names (e.g. "Etag") to
  128. // unconditionally include in API requests. By default, fields with
  129. // empty values are omitted from API requests. However, any non-pointer,
  130. // non-interface field appearing in ForceSendFields will be sent to the
  131. // server regardless of whether the field is empty or not. This may be
  132. // used to include empty fields in Patch requests.
  133. ForceSendFields []string `json:"-"`
  134. // NullFields is a list of field names (e.g. "Etag") to include in API
  135. // requests with the JSON null value. By default, fields with empty
  136. // values are omitted from API requests. However, any field with an
  137. // empty value appearing in NullFields will be sent to the server as
  138. // null. It is an error if a field in this list has a non-empty value.
  139. // This may be used to include null fields in Patch requests.
  140. NullFields []string `json:"-"`
  141. }
  142. func (s *Activities) MarshalJSON() ([]byte, error) {
  143. type NoMethod Activities
  144. raw := NoMethod(*s)
  145. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  146. }
  147. // Activity: JSON template for the activity resource.
  148. type Activity struct {
  149. // Actor: User doing the action.
  150. Actor *ActivityActor `json:"actor,omitempty"`
  151. // Etag: ETag of the entry.
  152. Etag string `json:"etag,omitempty"`
  153. // Events: Activity events.
  154. Events []*ActivityEvents `json:"events,omitempty"`
  155. // Id: Unique identifier for each activity record.
  156. Id *ActivityId `json:"id,omitempty"`
  157. // IpAddress: IP Address of the user doing the action.
  158. IpAddress string `json:"ipAddress,omitempty"`
  159. // Kind: Kind of resource this is.
  160. Kind string `json:"kind,omitempty"`
  161. // OwnerDomain: Domain of source customer.
  162. OwnerDomain string `json:"ownerDomain,omitempty"`
  163. // ForceSendFields is a list of field names (e.g. "Actor") to
  164. // unconditionally include in API requests. By default, fields with
  165. // empty values are omitted from API requests. However, any non-pointer,
  166. // non-interface field appearing in ForceSendFields will be sent to the
  167. // server regardless of whether the field is empty or not. This may be
  168. // used to include empty fields in Patch requests.
  169. ForceSendFields []string `json:"-"`
  170. // NullFields is a list of field names (e.g. "Actor") to include in API
  171. // requests with the JSON null value. By default, fields with empty
  172. // values are omitted from API requests. However, any field with an
  173. // empty value appearing in NullFields will be sent to the server as
  174. // null. It is an error if a field in this list has a non-empty value.
  175. // This may be used to include null fields in Patch requests.
  176. NullFields []string `json:"-"`
  177. }
  178. func (s *Activity) MarshalJSON() ([]byte, error) {
  179. type NoMethod Activity
  180. raw := NoMethod(*s)
  181. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  182. }
  183. // ActivityActor: User doing the action.
  184. type ActivityActor struct {
  185. // CallerType: User or OAuth 2LO request.
  186. CallerType string `json:"callerType,omitempty"`
  187. // Email: Email address of the user.
  188. Email string `json:"email,omitempty"`
  189. // Key: For OAuth 2LO API requests, consumer_key of the requestor.
  190. Key string `json:"key,omitempty"`
  191. // ProfileId: Obfuscated user id of the user.
  192. ProfileId string `json:"profileId,omitempty"`
  193. // ForceSendFields is a list of field names (e.g. "CallerType") to
  194. // unconditionally include in API requests. By default, fields with
  195. // empty values are omitted from API requests. However, any non-pointer,
  196. // non-interface field appearing in ForceSendFields will be sent to the
  197. // server regardless of whether the field is empty or not. This may be
  198. // used to include empty fields in Patch requests.
  199. ForceSendFields []string `json:"-"`
  200. // NullFields is a list of field names (e.g. "CallerType") to include in
  201. // API requests with the JSON null value. By default, fields with empty
  202. // values are omitted from API requests. However, any field with an
  203. // empty value appearing in NullFields will be sent to the server as
  204. // null. It is an error if a field in this list has a non-empty value.
  205. // This may be used to include null fields in Patch requests.
  206. NullFields []string `json:"-"`
  207. }
  208. func (s *ActivityActor) MarshalJSON() ([]byte, error) {
  209. type NoMethod ActivityActor
  210. raw := NoMethod(*s)
  211. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  212. }
  213. type ActivityEvents struct {
  214. // Name: Name of event.
  215. Name string `json:"name,omitempty"`
  216. // Parameters: Parameter value pairs for various applications.
  217. Parameters []*ActivityEventsParameters `json:"parameters,omitempty"`
  218. // Type: Type of event.
  219. Type string `json:"type,omitempty"`
  220. // ForceSendFields is a list of field names (e.g. "Name") to
  221. // unconditionally include in API requests. By default, fields with
  222. // empty values are omitted from API requests. However, any non-pointer,
  223. // non-interface field appearing in ForceSendFields will be sent to the
  224. // server regardless of whether the field is empty or not. This may be
  225. // used to include empty fields in Patch requests.
  226. ForceSendFields []string `json:"-"`
  227. // NullFields is a list of field names (e.g. "Name") to include in API
  228. // requests with the JSON null value. By default, fields with empty
  229. // values are omitted from API requests. However, any field with an
  230. // empty value appearing in NullFields will be sent to the server as
  231. // null. It is an error if a field in this list has a non-empty value.
  232. // This may be used to include null fields in Patch requests.
  233. NullFields []string `json:"-"`
  234. }
  235. func (s *ActivityEvents) MarshalJSON() ([]byte, error) {
  236. type NoMethod ActivityEvents
  237. raw := NoMethod(*s)
  238. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  239. }
  240. type ActivityEventsParameters struct {
  241. // BoolValue: Boolean value of the parameter.
  242. BoolValue bool `json:"boolValue,omitempty"`
  243. // IntValue: Integral value of the parameter.
  244. IntValue int64 `json:"intValue,omitempty,string"`
  245. // MultiIntValue: Multi-int value of the parameter.
  246. MultiIntValue googleapi.Int64s `json:"multiIntValue,omitempty"`
  247. // MultiValue: Multi-string value of the parameter.
  248. MultiValue []string `json:"multiValue,omitempty"`
  249. // Name: The name of the parameter.
  250. Name string `json:"name,omitempty"`
  251. // Value: String value of the parameter.
  252. Value string `json:"value,omitempty"`
  253. // ForceSendFields is a list of field names (e.g. "BoolValue") to
  254. // unconditionally include in API requests. By default, fields with
  255. // empty values are omitted from API requests. However, any non-pointer,
  256. // non-interface field appearing in ForceSendFields will be sent to the
  257. // server regardless of whether the field is empty or not. This may be
  258. // used to include empty fields in Patch requests.
  259. ForceSendFields []string `json:"-"`
  260. // NullFields is a list of field names (e.g. "BoolValue") to include in
  261. // API requests with the JSON null value. By default, fields with empty
  262. // values are omitted from API requests. However, any field with an
  263. // empty value appearing in NullFields will be sent to the server as
  264. // null. It is an error if a field in this list has a non-empty value.
  265. // This may be used to include null fields in Patch requests.
  266. NullFields []string `json:"-"`
  267. }
  268. func (s *ActivityEventsParameters) MarshalJSON() ([]byte, error) {
  269. type NoMethod ActivityEventsParameters
  270. raw := NoMethod(*s)
  271. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  272. }
  273. // ActivityId: Unique identifier for each activity record.
  274. type ActivityId struct {
  275. // ApplicationName: Application name to which the event belongs.
  276. ApplicationName string `json:"applicationName,omitempty"`
  277. // CustomerId: Obfuscated customer ID of the source customer.
  278. CustomerId string `json:"customerId,omitempty"`
  279. // Time: Time of occurrence of the activity.
  280. Time string `json:"time,omitempty"`
  281. // UniqueQualifier: Unique qualifier if multiple events have the same
  282. // time.
  283. UniqueQualifier int64 `json:"uniqueQualifier,omitempty,string"`
  284. // ForceSendFields is a list of field names (e.g. "ApplicationName") to
  285. // unconditionally include in API requests. By default, fields with
  286. // empty values are omitted from API requests. However, any non-pointer,
  287. // non-interface field appearing in ForceSendFields will be sent to the
  288. // server regardless of whether the field is empty or not. This may be
  289. // used to include empty fields in Patch requests.
  290. ForceSendFields []string `json:"-"`
  291. // NullFields is a list of field names (e.g. "ApplicationName") to
  292. // include in API requests with the JSON null value. By default, fields
  293. // with empty values are omitted from API requests. However, any field
  294. // with an empty value appearing in NullFields will be sent to the
  295. // server as null. It is an error if a field in this list has a
  296. // non-empty value. This may be used to include null fields in Patch
  297. // requests.
  298. NullFields []string `json:"-"`
  299. }
  300. func (s *ActivityId) MarshalJSON() ([]byte, error) {
  301. type NoMethod ActivityId
  302. raw := NoMethod(*s)
  303. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  304. }
  305. // Channel: An notification channel used to watch for resource changes.
  306. type Channel struct {
  307. // Address: The address where notifications are delivered for this
  308. // channel.
  309. Address string `json:"address,omitempty"`
  310. // Expiration: Date and time of notification channel expiration,
  311. // expressed as a Unix timestamp, in milliseconds. Optional.
  312. Expiration int64 `json:"expiration,omitempty,string"`
  313. // Id: A UUID or similar unique string that identifies this channel.
  314. Id string `json:"id,omitempty"`
  315. // Kind: Identifies this as a notification channel used to watch for
  316. // changes to a resource. Value: the fixed string "api#channel".
  317. Kind string `json:"kind,omitempty"`
  318. // Params: Additional parameters controlling delivery channel behavior.
  319. // Optional.
  320. Params map[string]string `json:"params,omitempty"`
  321. // Payload: A Boolean value to indicate whether payload is wanted.
  322. // Optional.
  323. Payload bool `json:"payload,omitempty"`
  324. // ResourceId: An opaque ID that identifies the resource being watched
  325. // on this channel. Stable across different API versions.
  326. ResourceId string `json:"resourceId,omitempty"`
  327. // ResourceUri: A version-specific identifier for the watched resource.
  328. ResourceUri string `json:"resourceUri,omitempty"`
  329. // Token: An arbitrary string delivered to the target address with each
  330. // notification delivered over this channel. Optional.
  331. Token string `json:"token,omitempty"`
  332. // Type: The type of delivery mechanism used for this channel.
  333. Type string `json:"type,omitempty"`
  334. // ServerResponse contains the HTTP response code and headers from the
  335. // server.
  336. googleapi.ServerResponse `json:"-"`
  337. // ForceSendFields is a list of field names (e.g. "Address") to
  338. // unconditionally include in API requests. By default, fields with
  339. // empty values are omitted from API requests. However, any non-pointer,
  340. // non-interface field appearing in ForceSendFields will be sent to the
  341. // server regardless of whether the field is empty or not. This may be
  342. // used to include empty fields in Patch requests.
  343. ForceSendFields []string `json:"-"`
  344. // NullFields is a list of field names (e.g. "Address") to include in
  345. // API requests with the JSON null value. By default, fields with empty
  346. // values are omitted from API requests. However, any field with an
  347. // empty value appearing in NullFields will be sent to the server as
  348. // null. It is an error if a field in this list has a non-empty value.
  349. // This may be used to include null fields in Patch requests.
  350. NullFields []string `json:"-"`
  351. }
  352. func (s *Channel) MarshalJSON() ([]byte, error) {
  353. type NoMethod Channel
  354. raw := NoMethod(*s)
  355. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  356. }
  357. // UsageReport: JSON template for a usage report.
  358. type UsageReport struct {
  359. // Date: The date to which the record belongs.
  360. Date string `json:"date,omitempty"`
  361. // Entity: Information about the type of the item.
  362. Entity *UsageReportEntity `json:"entity,omitempty"`
  363. // Etag: ETag of the resource.
  364. Etag string `json:"etag,omitempty"`
  365. // Kind: The kind of object.
  366. Kind string `json:"kind,omitempty"`
  367. // Parameters: Parameter value pairs for various applications.
  368. Parameters []*UsageReportParameters `json:"parameters,omitempty"`
  369. // ForceSendFields is a list of field names (e.g. "Date") to
  370. // unconditionally include in API requests. By default, fields with
  371. // empty values are omitted from API requests. However, any non-pointer,
  372. // non-interface field appearing in ForceSendFields will be sent to the
  373. // server regardless of whether the field is empty or not. This may be
  374. // used to include empty fields in Patch requests.
  375. ForceSendFields []string `json:"-"`
  376. // NullFields is a list of field names (e.g. "Date") to include in API
  377. // requests with the JSON null value. By default, fields with empty
  378. // values are omitted from API requests. However, any field with an
  379. // empty value appearing in NullFields will be sent to the server as
  380. // null. It is an error if a field in this list has a non-empty value.
  381. // This may be used to include null fields in Patch requests.
  382. NullFields []string `json:"-"`
  383. }
  384. func (s *UsageReport) MarshalJSON() ([]byte, error) {
  385. type NoMethod UsageReport
  386. raw := NoMethod(*s)
  387. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  388. }
  389. // UsageReportEntity: Information about the type of the item.
  390. type UsageReportEntity struct {
  391. // CustomerId: Obfuscated customer id for the record.
  392. CustomerId string `json:"customerId,omitempty"`
  393. // EntityId: Object key. Only relevant if entity.type = "OBJECT" Note:
  394. // external-facing name of report is "Entities" rather than "Objects".
  395. EntityId string `json:"entityId,omitempty"`
  396. // ProfileId: Obfuscated user id for the record.
  397. ProfileId string `json:"profileId,omitempty"`
  398. // Type: The type of item, can be customer, user, or entity (aka.
  399. // object).
  400. Type string `json:"type,omitempty"`
  401. // UserEmail: user's email. Only relevant if entity.type = "USER"
  402. UserEmail string `json:"userEmail,omitempty"`
  403. // ForceSendFields is a list of field names (e.g. "CustomerId") to
  404. // unconditionally include in API requests. By default, fields with
  405. // empty values are omitted from API requests. However, any non-pointer,
  406. // non-interface field appearing in ForceSendFields will be sent to the
  407. // server regardless of whether the field is empty or not. This may be
  408. // used to include empty fields in Patch requests.
  409. ForceSendFields []string `json:"-"`
  410. // NullFields is a list of field names (e.g. "CustomerId") to include in
  411. // API requests with the JSON null value. By default, fields with empty
  412. // values are omitted from API requests. However, any field with an
  413. // empty value appearing in NullFields will be sent to the server as
  414. // null. It is an error if a field in this list has a non-empty value.
  415. // This may be used to include null fields in Patch requests.
  416. NullFields []string `json:"-"`
  417. }
  418. func (s *UsageReportEntity) MarshalJSON() ([]byte, error) {
  419. type NoMethod UsageReportEntity
  420. raw := NoMethod(*s)
  421. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  422. }
  423. type UsageReportParameters struct {
  424. // BoolValue: Boolean value of the parameter.
  425. BoolValue bool `json:"boolValue,omitempty"`
  426. // DatetimeValue: RFC 3339 formatted value of the parameter.
  427. DatetimeValue string `json:"datetimeValue,omitempty"`
  428. // IntValue: Integral value of the parameter.
  429. IntValue int64 `json:"intValue,omitempty,string"`
  430. // MsgValue: Nested message value of the parameter.
  431. MsgValue []googleapi.RawMessage `json:"msgValue,omitempty"`
  432. // Name: The name of the parameter.
  433. Name string `json:"name,omitempty"`
  434. // StringValue: String value of the parameter.
  435. StringValue string `json:"stringValue,omitempty"`
  436. // ForceSendFields is a list of field names (e.g. "BoolValue") to
  437. // unconditionally include in API requests. By default, fields with
  438. // empty values are omitted from API requests. However, any non-pointer,
  439. // non-interface field appearing in ForceSendFields will be sent to the
  440. // server regardless of whether the field is empty or not. This may be
  441. // used to include empty fields in Patch requests.
  442. ForceSendFields []string `json:"-"`
  443. // NullFields is a list of field names (e.g. "BoolValue") to include in
  444. // API requests with the JSON null value. By default, fields with empty
  445. // values are omitted from API requests. However, any field with an
  446. // empty value appearing in NullFields will be sent to the server as
  447. // null. It is an error if a field in this list has a non-empty value.
  448. // This may be used to include null fields in Patch requests.
  449. NullFields []string `json:"-"`
  450. }
  451. func (s *UsageReportParameters) MarshalJSON() ([]byte, error) {
  452. type NoMethod UsageReportParameters
  453. raw := NoMethod(*s)
  454. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  455. }
  456. // UsageReports: JSON template for a collection of usage reports.
  457. type UsageReports struct {
  458. // Etag: ETag of the resource.
  459. Etag string `json:"etag,omitempty"`
  460. // Kind: The kind of object.
  461. Kind string `json:"kind,omitempty"`
  462. // NextPageToken: Token for retrieving the next page
  463. NextPageToken string `json:"nextPageToken,omitempty"`
  464. // UsageReports: Various application parameter records.
  465. UsageReports []*UsageReport `json:"usageReports,omitempty"`
  466. // Warnings: Warnings if any.
  467. Warnings []*UsageReportsWarnings `json:"warnings,omitempty"`
  468. // ServerResponse contains the HTTP response code and headers from the
  469. // server.
  470. googleapi.ServerResponse `json:"-"`
  471. // ForceSendFields is a list of field names (e.g. "Etag") to
  472. // unconditionally include in API requests. By default, fields with
  473. // empty values are omitted from API requests. However, any non-pointer,
  474. // non-interface field appearing in ForceSendFields will be sent to the
  475. // server regardless of whether the field is empty or not. This may be
  476. // used to include empty fields in Patch requests.
  477. ForceSendFields []string `json:"-"`
  478. // NullFields is a list of field names (e.g. "Etag") to include in API
  479. // requests with the JSON null value. By default, fields with empty
  480. // values are omitted from API requests. However, any field with an
  481. // empty value appearing in NullFields will be sent to the server as
  482. // null. It is an error if a field in this list has a non-empty value.
  483. // This may be used to include null fields in Patch requests.
  484. NullFields []string `json:"-"`
  485. }
  486. func (s *UsageReports) MarshalJSON() ([]byte, error) {
  487. type NoMethod UsageReports
  488. raw := NoMethod(*s)
  489. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  490. }
  491. type UsageReportsWarnings struct {
  492. // Code: Machine readable code / warning type.
  493. Code string `json:"code,omitempty"`
  494. // Data: Key-Value pairs to give detailed information on the warning.
  495. Data []*UsageReportsWarningsData `json:"data,omitempty"`
  496. // Message: Human readable message for the warning.
  497. Message string `json:"message,omitempty"`
  498. // ForceSendFields is a list of field names (e.g. "Code") to
  499. // unconditionally include in API requests. By default, fields with
  500. // empty values are omitted from API requests. However, any non-pointer,
  501. // non-interface field appearing in ForceSendFields will be sent to the
  502. // server regardless of whether the field is empty or not. This may be
  503. // used to include empty fields in Patch requests.
  504. ForceSendFields []string `json:"-"`
  505. // NullFields is a list of field names (e.g. "Code") to include in API
  506. // requests with the JSON null value. By default, fields with empty
  507. // values are omitted from API requests. However, any field with an
  508. // empty value appearing in NullFields will be sent to the server as
  509. // null. It is an error if a field in this list has a non-empty value.
  510. // This may be used to include null fields in Patch requests.
  511. NullFields []string `json:"-"`
  512. }
  513. func (s *UsageReportsWarnings) MarshalJSON() ([]byte, error) {
  514. type NoMethod UsageReportsWarnings
  515. raw := NoMethod(*s)
  516. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  517. }
  518. type UsageReportsWarningsData struct {
  519. // Key: Key associated with a key-value pair to give detailed
  520. // information on the warning.
  521. Key string `json:"key,omitempty"`
  522. // Value: Value associated with a key-value pair to give detailed
  523. // information on the warning.
  524. Value string `json:"value,omitempty"`
  525. // ForceSendFields is a list of field names (e.g. "Key") to
  526. // unconditionally include in API requests. By default, fields with
  527. // empty values are omitted from API requests. However, any non-pointer,
  528. // non-interface field appearing in ForceSendFields will be sent to the
  529. // server regardless of whether the field is empty or not. This may be
  530. // used to include empty fields in Patch requests.
  531. ForceSendFields []string `json:"-"`
  532. // NullFields is a list of field names (e.g. "Key") to include in API
  533. // requests with the JSON null value. By default, fields with empty
  534. // values are omitted from API requests. However, any field with an
  535. // empty value appearing in NullFields will be sent to the server as
  536. // null. It is an error if a field in this list has a non-empty value.
  537. // This may be used to include null fields in Patch requests.
  538. NullFields []string `json:"-"`
  539. }
  540. func (s *UsageReportsWarningsData) MarshalJSON() ([]byte, error) {
  541. type NoMethod UsageReportsWarningsData
  542. raw := NoMethod(*s)
  543. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  544. }
  545. // method id "reports.activities.list":
  546. type ActivitiesListCall struct {
  547. s *Service
  548. userKey string
  549. applicationName string
  550. urlParams_ gensupport.URLParams
  551. ifNoneMatch_ string
  552. ctx_ context.Context
  553. header_ http.Header
  554. }
  555. // List: Retrieves a list of activities for a specific customer and
  556. // application.
  557. func (r *ActivitiesService) List(userKey string, applicationName string) *ActivitiesListCall {
  558. c := &ActivitiesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  559. c.userKey = userKey
  560. c.applicationName = applicationName
  561. return c
  562. }
  563. // ActorIpAddress sets the optional parameter "actorIpAddress": IP
  564. // Address of host where the event was performed. Supports both IPv4 and
  565. // IPv6 addresses.
  566. func (c *ActivitiesListCall) ActorIpAddress(actorIpAddress string) *ActivitiesListCall {
  567. c.urlParams_.Set("actorIpAddress", actorIpAddress)
  568. return c
  569. }
  570. // CustomerId sets the optional parameter "customerId": Represents the
  571. // customer for which the data is to be fetched.
  572. func (c *ActivitiesListCall) CustomerId(customerId string) *ActivitiesListCall {
  573. c.urlParams_.Set("customerId", customerId)
  574. return c
  575. }
  576. // EndTime sets the optional parameter "endTime": Return events which
  577. // occurred at or before this time.
  578. func (c *ActivitiesListCall) EndTime(endTime string) *ActivitiesListCall {
  579. c.urlParams_.Set("endTime", endTime)
  580. return c
  581. }
  582. // EventName sets the optional parameter "eventName": Name of the event
  583. // being queried.
  584. func (c *ActivitiesListCall) EventName(eventName string) *ActivitiesListCall {
  585. c.urlParams_.Set("eventName", eventName)
  586. return c
  587. }
  588. // Filters sets the optional parameter "filters": Event parameters in
  589. // the form [parameter1 name][operator][parameter1 value],[parameter2
  590. // name][operator][parameter2 value],...
  591. func (c *ActivitiesListCall) Filters(filters string) *ActivitiesListCall {
  592. c.urlParams_.Set("filters", filters)
  593. return c
  594. }
  595. // MaxResults sets the optional parameter "maxResults": Number of
  596. // activity records to be shown in each page.
  597. func (c *ActivitiesListCall) MaxResults(maxResults int64) *ActivitiesListCall {
  598. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  599. return c
  600. }
  601. // PageToken sets the optional parameter "pageToken": Token to specify
  602. // next page.
  603. func (c *ActivitiesListCall) PageToken(pageToken string) *ActivitiesListCall {
  604. c.urlParams_.Set("pageToken", pageToken)
  605. return c
  606. }
  607. // StartTime sets the optional parameter "startTime": Return events
  608. // which occurred at or after this time.
  609. func (c *ActivitiesListCall) StartTime(startTime string) *ActivitiesListCall {
  610. c.urlParams_.Set("startTime", startTime)
  611. return c
  612. }
  613. // Fields allows partial responses to be retrieved. See
  614. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  615. // for more information.
  616. func (c *ActivitiesListCall) Fields(s ...googleapi.Field) *ActivitiesListCall {
  617. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  618. return c
  619. }
  620. // IfNoneMatch sets the optional parameter which makes the operation
  621. // fail if the object's ETag matches the given value. This is useful for
  622. // getting updates only after the object has changed since the last
  623. // request. Use googleapi.IsNotModified to check whether the response
  624. // error from Do is the result of In-None-Match.
  625. func (c *ActivitiesListCall) IfNoneMatch(entityTag string) *ActivitiesListCall {
  626. c.ifNoneMatch_ = entityTag
  627. return c
  628. }
  629. // Context sets the context to be used in this call's Do method. Any
  630. // pending HTTP request will be aborted if the provided context is
  631. // canceled.
  632. func (c *ActivitiesListCall) Context(ctx context.Context) *ActivitiesListCall {
  633. c.ctx_ = ctx
  634. return c
  635. }
  636. // Header returns an http.Header that can be modified by the caller to
  637. // add HTTP headers to the request.
  638. func (c *ActivitiesListCall) Header() http.Header {
  639. if c.header_ == nil {
  640. c.header_ = make(http.Header)
  641. }
  642. return c.header_
  643. }
  644. func (c *ActivitiesListCall) doRequest(alt string) (*http.Response, error) {
  645. reqHeaders := make(http.Header)
  646. for k, v := range c.header_ {
  647. reqHeaders[k] = v
  648. }
  649. reqHeaders.Set("User-Agent", c.s.userAgent())
  650. if c.ifNoneMatch_ != "" {
  651. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  652. }
  653. var body io.Reader = nil
  654. c.urlParams_.Set("alt", alt)
  655. urls := googleapi.ResolveRelative(c.s.BasePath, "activity/users/{userKey}/applications/{applicationName}")
  656. urls += "?" + c.urlParams_.Encode()
  657. req, _ := http.NewRequest("GET", urls, body)
  658. req.Header = reqHeaders
  659. googleapi.Expand(req.URL, map[string]string{
  660. "userKey": c.userKey,
  661. "applicationName": c.applicationName,
  662. })
  663. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  664. }
  665. // Do executes the "reports.activities.list" call.
  666. // Exactly one of *Activities or error will be non-nil. Any non-2xx
  667. // status code is an error. Response headers are in either
  668. // *Activities.ServerResponse.Header or (if a response was returned at
  669. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  670. // to check whether the returned error was because
  671. // http.StatusNotModified was returned.
  672. func (c *ActivitiesListCall) Do(opts ...googleapi.CallOption) (*Activities, error) {
  673. gensupport.SetOptions(c.urlParams_, opts...)
  674. res, err := c.doRequest("json")
  675. if res != nil && res.StatusCode == http.StatusNotModified {
  676. if res.Body != nil {
  677. res.Body.Close()
  678. }
  679. return nil, &googleapi.Error{
  680. Code: res.StatusCode,
  681. Header: res.Header,
  682. }
  683. }
  684. if err != nil {
  685. return nil, err
  686. }
  687. defer googleapi.CloseBody(res)
  688. if err := googleapi.CheckResponse(res); err != nil {
  689. return nil, err
  690. }
  691. ret := &Activities{
  692. ServerResponse: googleapi.ServerResponse{
  693. Header: res.Header,
  694. HTTPStatusCode: res.StatusCode,
  695. },
  696. }
  697. target := &ret
  698. if err := gensupport.DecodeResponse(target, res); err != nil {
  699. return nil, err
  700. }
  701. return ret, nil
  702. // {
  703. // "description": "Retrieves a list of activities for a specific customer and application.",
  704. // "httpMethod": "GET",
  705. // "id": "reports.activities.list",
  706. // "parameterOrder": [
  707. // "userKey",
  708. // "applicationName"
  709. // ],
  710. // "parameters": {
  711. // "actorIpAddress": {
  712. // "description": "IP Address of host where the event was performed. Supports both IPv4 and IPv6 addresses.",
  713. // "location": "query",
  714. // "type": "string"
  715. // },
  716. // "applicationName": {
  717. // "description": "Application name for which the events are to be retrieved.",
  718. // "location": "path",
  719. // "pattern": "(admin)|(calendar)|(drive)|(login)|(mobile)|(token)|(groups)|(saml)|(chat)|(gplus)|(rules)|(jamboard)|(meet)",
  720. // "required": true,
  721. // "type": "string"
  722. // },
  723. // "customerId": {
  724. // "description": "Represents the customer for which the data is to be fetched.",
  725. // "location": "query",
  726. // "pattern": "C.+",
  727. // "type": "string"
  728. // },
  729. // "endTime": {
  730. // "description": "Return events which occurred at or before this time.",
  731. // "location": "query",
  732. // "pattern": "(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.(\\d+))?(?:(Z)|([-+])(\\d\\d):(\\d\\d))",
  733. // "type": "string"
  734. // },
  735. // "eventName": {
  736. // "description": "Name of the event being queried.",
  737. // "location": "query",
  738. // "type": "string"
  739. // },
  740. // "filters": {
  741. // "description": "Event parameters in the form [parameter1 name][operator][parameter1 value],[parameter2 name][operator][parameter2 value],...",
  742. // "location": "query",
  743. // "pattern": "(.+[\u003c,\u003c=,==,\u003e=,\u003e,\u003c\u003e].+,)*(.+[\u003c,\u003c=,==,\u003e=,\u003e,\u003c\u003e].+)",
  744. // "type": "string"
  745. // },
  746. // "maxResults": {
  747. // "description": "Number of activity records to be shown in each page.",
  748. // "format": "int32",
  749. // "location": "query",
  750. // "maximum": "1000",
  751. // "minimum": "1",
  752. // "type": "integer"
  753. // },
  754. // "pageToken": {
  755. // "description": "Token to specify next page.",
  756. // "location": "query",
  757. // "type": "string"
  758. // },
  759. // "startTime": {
  760. // "description": "Return events which occurred at or after this time.",
  761. // "location": "query",
  762. // "pattern": "(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.(\\d+))?(?:(Z)|([-+])(\\d\\d):(\\d\\d))",
  763. // "type": "string"
  764. // },
  765. // "userKey": {
  766. // "description": "Represents the profile id or the user email for which the data should be filtered. When 'all' is specified as the userKey, it returns usageReports for all users.",
  767. // "location": "path",
  768. // "required": true,
  769. // "type": "string"
  770. // }
  771. // },
  772. // "path": "activity/users/{userKey}/applications/{applicationName}",
  773. // "response": {
  774. // "$ref": "Activities"
  775. // },
  776. // "scopes": [
  777. // "https://www.googleapis.com/auth/admin.reports.audit.readonly"
  778. // ],
  779. // "supportsSubscription": true
  780. // }
  781. }
  782. // Pages invokes f for each page of results.
  783. // A non-nil error returned from f will halt the iteration.
  784. // The provided context supersedes any context provided to the Context method.
  785. func (c *ActivitiesListCall) Pages(ctx context.Context, f func(*Activities) error) error {
  786. c.ctx_ = ctx
  787. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  788. for {
  789. x, err := c.Do()
  790. if err != nil {
  791. return err
  792. }
  793. if err := f(x); err != nil {
  794. return err
  795. }
  796. if x.NextPageToken == "" {
  797. return nil
  798. }
  799. c.PageToken(x.NextPageToken)
  800. }
  801. }
  802. // method id "reports.activities.watch":
  803. type ActivitiesWatchCall struct {
  804. s *Service
  805. userKey string
  806. applicationName string
  807. channel *Channel
  808. urlParams_ gensupport.URLParams
  809. ctx_ context.Context
  810. header_ http.Header
  811. }
  812. // Watch: Push changes to activities
  813. func (r *ActivitiesService) Watch(userKey string, applicationName string, channel *Channel) *ActivitiesWatchCall {
  814. c := &ActivitiesWatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  815. c.userKey = userKey
  816. c.applicationName = applicationName
  817. c.channel = channel
  818. return c
  819. }
  820. // ActorIpAddress sets the optional parameter "actorIpAddress": IP
  821. // Address of host where the event was performed. Supports both IPv4 and
  822. // IPv6 addresses.
  823. func (c *ActivitiesWatchCall) ActorIpAddress(actorIpAddress string) *ActivitiesWatchCall {
  824. c.urlParams_.Set("actorIpAddress", actorIpAddress)
  825. return c
  826. }
  827. // CustomerId sets the optional parameter "customerId": Represents the
  828. // customer for which the data is to be fetched.
  829. func (c *ActivitiesWatchCall) CustomerId(customerId string) *ActivitiesWatchCall {
  830. c.urlParams_.Set("customerId", customerId)
  831. return c
  832. }
  833. // EndTime sets the optional parameter "endTime": Return events which
  834. // occurred at or before this time.
  835. func (c *ActivitiesWatchCall) EndTime(endTime string) *ActivitiesWatchCall {
  836. c.urlParams_.Set("endTime", endTime)
  837. return c
  838. }
  839. // EventName sets the optional parameter "eventName": Name of the event
  840. // being queried.
  841. func (c *ActivitiesWatchCall) EventName(eventName string) *ActivitiesWatchCall {
  842. c.urlParams_.Set("eventName", eventName)
  843. return c
  844. }
  845. // Filters sets the optional parameter "filters": Event parameters in
  846. // the form [parameter1 name][operator][parameter1 value],[parameter2
  847. // name][operator][parameter2 value],...
  848. func (c *ActivitiesWatchCall) Filters(filters string) *ActivitiesWatchCall {
  849. c.urlParams_.Set("filters", filters)
  850. return c
  851. }
  852. // MaxResults sets the optional parameter "maxResults": Number of
  853. // activity records to be shown in each page.
  854. func (c *ActivitiesWatchCall) MaxResults(maxResults int64) *ActivitiesWatchCall {
  855. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  856. return c
  857. }
  858. // PageToken sets the optional parameter "pageToken": Token to specify
  859. // next page.
  860. func (c *ActivitiesWatchCall) PageToken(pageToken string) *ActivitiesWatchCall {
  861. c.urlParams_.Set("pageToken", pageToken)
  862. return c
  863. }
  864. // StartTime sets the optional parameter "startTime": Return events
  865. // which occurred at or after this time.
  866. func (c *ActivitiesWatchCall) StartTime(startTime string) *ActivitiesWatchCall {
  867. c.urlParams_.Set("startTime", startTime)
  868. return c
  869. }
  870. // Fields allows partial responses to be retrieved. See
  871. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  872. // for more information.
  873. func (c *ActivitiesWatchCall) Fields(s ...googleapi.Field) *ActivitiesWatchCall {
  874. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  875. return c
  876. }
  877. // Context sets the context to be used in this call's Do method. Any
  878. // pending HTTP request will be aborted if the provided context is
  879. // canceled.
  880. func (c *ActivitiesWatchCall) Context(ctx context.Context) *ActivitiesWatchCall {
  881. c.ctx_ = ctx
  882. return c
  883. }
  884. // Header returns an http.Header that can be modified by the caller to
  885. // add HTTP headers to the request.
  886. func (c *ActivitiesWatchCall) Header() http.Header {
  887. if c.header_ == nil {
  888. c.header_ = make(http.Header)
  889. }
  890. return c.header_
  891. }
  892. func (c *ActivitiesWatchCall) doRequest(alt string) (*http.Response, error) {
  893. reqHeaders := make(http.Header)
  894. for k, v := range c.header_ {
  895. reqHeaders[k] = v
  896. }
  897. reqHeaders.Set("User-Agent", c.s.userAgent())
  898. var body io.Reader = nil
  899. body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
  900. if err != nil {
  901. return nil, err
  902. }
  903. reqHeaders.Set("Content-Type", "application/json")
  904. c.urlParams_.Set("alt", alt)
  905. urls := googleapi.ResolveRelative(c.s.BasePath, "activity/users/{userKey}/applications/{applicationName}/watch")
  906. urls += "?" + c.urlParams_.Encode()
  907. req, _ := http.NewRequest("POST", urls, body)
  908. req.Header = reqHeaders
  909. googleapi.Expand(req.URL, map[string]string{
  910. "userKey": c.userKey,
  911. "applicationName": c.applicationName,
  912. })
  913. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  914. }
  915. // Do executes the "reports.activities.watch" call.
  916. // Exactly one of *Channel or error will be non-nil. Any non-2xx status
  917. // code is an error. Response headers are in either
  918. // *Channel.ServerResponse.Header or (if a response was returned at all)
  919. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  920. // check whether the returned error was because http.StatusNotModified
  921. // was returned.
  922. func (c *ActivitiesWatchCall) Do(opts ...googleapi.CallOption) (*Channel, error) {
  923. gensupport.SetOptions(c.urlParams_, opts...)
  924. res, err := c.doRequest("json")
  925. if res != nil && res.StatusCode == http.StatusNotModified {
  926. if res.Body != nil {
  927. res.Body.Close()
  928. }
  929. return nil, &googleapi.Error{
  930. Code: res.StatusCode,
  931. Header: res.Header,
  932. }
  933. }
  934. if err != nil {
  935. return nil, err
  936. }
  937. defer googleapi.CloseBody(res)
  938. if err := googleapi.CheckResponse(res); err != nil {
  939. return nil, err
  940. }
  941. ret := &Channel{
  942. ServerResponse: googleapi.ServerResponse{
  943. Header: res.Header,
  944. HTTPStatusCode: res.StatusCode,
  945. },
  946. }
  947. target := &ret
  948. if err := gensupport.DecodeResponse(target, res); err != nil {
  949. return nil, err
  950. }
  951. return ret, nil
  952. // {
  953. // "description": "Push changes to activities",
  954. // "httpMethod": "POST",
  955. // "id": "reports.activities.watch",
  956. // "parameterOrder": [
  957. // "userKey",
  958. // "applicationName"
  959. // ],
  960. // "parameters": {
  961. // "actorIpAddress": {
  962. // "description": "IP Address of host where the event was performed. Supports both IPv4 and IPv6 addresses.",
  963. // "location": "query",
  964. // "type": "string"
  965. // },
  966. // "applicationName": {
  967. // "description": "Application name for which the events are to be retrieved.",
  968. // "location": "path",
  969. // "pattern": "(admin)|(calendar)|(drive)|(login)|(mobile)|(token)|(groups)|(saml)|(chat)|(gplus)|(rules)|(jamboard)|(meet)",
  970. // "required": true,
  971. // "type": "string"
  972. // },
  973. // "customerId": {
  974. // "description": "Represents the customer for which the data is to be fetched.",
  975. // "location": "query",
  976. // "pattern": "C.+",
  977. // "type": "string"
  978. // },
  979. // "endTime": {
  980. // "description": "Return events which occurred at or before this time.",
  981. // "location": "query",
  982. // "pattern": "(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.(\\d+))?(?:(Z)|([-+])(\\d\\d):(\\d\\d))",
  983. // "type": "string"
  984. // },
  985. // "eventName": {
  986. // "description": "Name of the event being queried.",
  987. // "location": "query",
  988. // "type": "string"
  989. // },
  990. // "filters": {
  991. // "description": "Event parameters in the form [parameter1 name][operator][parameter1 value],[parameter2 name][operator][parameter2 value],...",
  992. // "location": "query",
  993. // "pattern": "(.+[\u003c,\u003c=,==,\u003e=,\u003e,\u003c\u003e].+,)*(.+[\u003c,\u003c=,==,\u003e=,\u003e,\u003c\u003e].+)",
  994. // "type": "string"
  995. // },
  996. // "maxResults": {
  997. // "description": "Number of activity records to be shown in each page.",
  998. // "format": "int32",
  999. // "location": "query",
  1000. // "maximum": "1000",
  1001. // "minimum": "1",
  1002. // "type": "integer"
  1003. // },
  1004. // "pageToken": {
  1005. // "description": "Token to specify next page.",
  1006. // "location": "query",
  1007. // "type": "string"
  1008. // },
  1009. // "startTime": {
  1010. // "description": "Return events which occurred at or after this time.",
  1011. // "location": "query",
  1012. // "pattern": "(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.(\\d+))?(?:(Z)|([-+])(\\d\\d):(\\d\\d))",
  1013. // "type": "string"
  1014. // },
  1015. // "userKey": {
  1016. // "description": "Represents the profile id or the user email for which the data should be filtered. When 'all' is specified as the userKey, it returns usageReports for all users.",
  1017. // "location": "path",
  1018. // "required": true,
  1019. // "type": "string"
  1020. // }
  1021. // },
  1022. // "path": "activity/users/{userKey}/applications/{applicationName}/watch",
  1023. // "request": {
  1024. // "$ref": "Channel",
  1025. // "parameterName": "resource"
  1026. // },
  1027. // "response": {
  1028. // "$ref": "Channel"
  1029. // },
  1030. // "scopes": [
  1031. // "https://www.googleapis.com/auth/admin.reports.audit.readonly"
  1032. // ],
  1033. // "supportsSubscription": true
  1034. // }
  1035. }
  1036. // method id "admin.channels.stop":
  1037. type ChannelsStopCall struct {
  1038. s *Service
  1039. channel *Channel
  1040. urlParams_ gensupport.URLParams
  1041. ctx_ context.Context
  1042. header_ http.Header
  1043. }
  1044. // Stop: Stop watching resources through this channel
  1045. func (r *ChannelsService) Stop(channel *Channel) *ChannelsStopCall {
  1046. c := &ChannelsStopCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1047. c.channel = channel
  1048. return c
  1049. }
  1050. // Fields allows partial responses to be retrieved. See
  1051. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1052. // for more information.
  1053. func (c *ChannelsStopCall) Fields(s ...googleapi.Field) *ChannelsStopCall {
  1054. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1055. return c
  1056. }
  1057. // Context sets the context to be used in this call's Do method. Any
  1058. // pending HTTP request will be aborted if the provided context is
  1059. // canceled.
  1060. func (c *ChannelsStopCall) Context(ctx context.Context) *ChannelsStopCall {
  1061. c.ctx_ = ctx
  1062. return c
  1063. }
  1064. // Header returns an http.Header that can be modified by the caller to
  1065. // add HTTP headers to the request.
  1066. func (c *ChannelsStopCall) Header() http.Header {
  1067. if c.header_ == nil {
  1068. c.header_ = make(http.Header)
  1069. }
  1070. return c.header_
  1071. }
  1072. func (c *ChannelsStopCall) doRequest(alt string) (*http.Response, error) {
  1073. reqHeaders := make(http.Header)
  1074. for k, v := range c.header_ {
  1075. reqHeaders[k] = v
  1076. }
  1077. reqHeaders.Set("User-Agent", c.s.userAgent())
  1078. var body io.Reader = nil
  1079. body, err := googleapi.WithoutDataWrapper.JSONReader(c.channel)
  1080. if err != nil {
  1081. return nil, err
  1082. }
  1083. reqHeaders.Set("Content-Type", "application/json")
  1084. c.urlParams_.Set("alt", alt)
  1085. urls := googleapi.ResolveRelative(c.s.BasePath, "/admin/reports_v1/channels/stop")
  1086. urls += "?" + c.urlParams_.Encode()
  1087. req, _ := http.NewRequest("POST", urls, body)
  1088. req.Header = reqHeaders
  1089. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1090. }
  1091. // Do executes the "admin.channels.stop" call.
  1092. func (c *ChannelsStopCall) Do(opts ...googleapi.CallOption) error {
  1093. gensupport.SetOptions(c.urlParams_, opts...)
  1094. res, err := c.doRequest("json")
  1095. if err != nil {
  1096. return err
  1097. }
  1098. defer googleapi.CloseBody(res)
  1099. if err := googleapi.CheckResponse(res); err != nil {
  1100. return err
  1101. }
  1102. return nil
  1103. // {
  1104. // "description": "Stop watching resources through this channel",
  1105. // "httpMethod": "POST",
  1106. // "id": "admin.channels.stop",
  1107. // "path": "/admin/reports_v1/channels/stop",
  1108. // "request": {
  1109. // "$ref": "Channel",
  1110. // "parameterName": "resource"
  1111. // },
  1112. // "scopes": [
  1113. // "https://www.googleapis.com/auth/admin.reports.audit.readonly"
  1114. // ]
  1115. // }
  1116. }
  1117. // method id "reports.customerUsageReports.get":
  1118. type CustomerUsageReportsGetCall struct {
  1119. s *Service
  1120. date string
  1121. urlParams_ gensupport.URLParams
  1122. ifNoneMatch_ string
  1123. ctx_ context.Context
  1124. header_ http.Header
  1125. }
  1126. // Get: Retrieves a report which is a collection of properties /
  1127. // statistics for a specific customer.
  1128. func (r *CustomerUsageReportsService) Get(date string) *CustomerUsageReportsGetCall {
  1129. c := &CustomerUsageReportsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1130. c.date = date
  1131. return c
  1132. }
  1133. // CustomerId sets the optional parameter "customerId": Represents the
  1134. // customer for which the data is to be fetched.
  1135. func (c *CustomerUsageReportsGetCall) CustomerId(customerId string) *CustomerUsageReportsGetCall {
  1136. c.urlParams_.Set("customerId", customerId)
  1137. return c
  1138. }
  1139. // PageToken sets the optional parameter "pageToken": Token to specify
  1140. // next page.
  1141. func (c *CustomerUsageReportsGetCall) PageToken(pageToken string) *CustomerUsageReportsGetCall {
  1142. c.urlParams_.Set("pageToken", pageToken)
  1143. return c
  1144. }
  1145. // Parameters sets the optional parameter "parameters": Represents the
  1146. // application name, parameter name pairs to fetch in csv as
  1147. // app_name1:param_name1, app_name2:param_name2.
  1148. func (c *CustomerUsageReportsGetCall) Parameters(parameters string) *CustomerUsageReportsGetCall {
  1149. c.urlParams_.Set("parameters", parameters)
  1150. return c
  1151. }
  1152. // Fields allows partial responses to be retrieved. See
  1153. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1154. // for more information.
  1155. func (c *CustomerUsageReportsGetCall) Fields(s ...googleapi.Field) *CustomerUsageReportsGetCall {
  1156. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1157. return c
  1158. }
  1159. // IfNoneMatch sets the optional parameter which makes the operation
  1160. // fail if the object's ETag matches the given value. This is useful for
  1161. // getting updates only after the object has changed since the last
  1162. // request. Use googleapi.IsNotModified to check whether the response
  1163. // error from Do is the result of In-None-Match.
  1164. func (c *CustomerUsageReportsGetCall) IfNoneMatch(entityTag string) *CustomerUsageReportsGetCall {
  1165. c.ifNoneMatch_ = entityTag
  1166. return c
  1167. }
  1168. // Context sets the context to be used in this call's Do method. Any
  1169. // pending HTTP request will be aborted if the provided context is
  1170. // canceled.
  1171. func (c *CustomerUsageReportsGetCall) Context(ctx context.Context) *CustomerUsageReportsGetCall {
  1172. c.ctx_ = ctx
  1173. return c
  1174. }
  1175. // Header returns an http.Header that can be modified by the caller to
  1176. // add HTTP headers to the request.
  1177. func (c *CustomerUsageReportsGetCall) Header() http.Header {
  1178. if c.header_ == nil {
  1179. c.header_ = make(http.Header)
  1180. }
  1181. return c.header_
  1182. }
  1183. func (c *CustomerUsageReportsGetCall) doRequest(alt string) (*http.Response, error) {
  1184. reqHeaders := make(http.Header)
  1185. for k, v := range c.header_ {
  1186. reqHeaders[k] = v
  1187. }
  1188. reqHeaders.Set("User-Agent", c.s.userAgent())
  1189. if c.ifNoneMatch_ != "" {
  1190. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1191. }
  1192. var body io.Reader = nil
  1193. c.urlParams_.Set("alt", alt)
  1194. urls := googleapi.ResolveRelative(c.s.BasePath, "usage/dates/{date}")
  1195. urls += "?" + c.urlParams_.Encode()
  1196. req, _ := http.NewRequest("GET", urls, body)
  1197. req.Header = reqHeaders
  1198. googleapi.Expand(req.URL, map[string]string{
  1199. "date": c.date,
  1200. })
  1201. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1202. }
  1203. // Do executes the "reports.customerUsageReports.get" call.
  1204. // Exactly one of *UsageReports or error will be non-nil. Any non-2xx
  1205. // status code is an error. Response headers are in either
  1206. // *UsageReports.ServerResponse.Header or (if a response was returned at
  1207. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1208. // to check whether the returned error was because
  1209. // http.StatusNotModified was returned.
  1210. func (c *CustomerUsageReportsGetCall) Do(opts ...googleapi.CallOption) (*UsageReports, error) {
  1211. gensupport.SetOptions(c.urlParams_, opts...)
  1212. res, err := c.doRequest("json")
  1213. if res != nil && res.StatusCode == http.StatusNotModified {
  1214. if res.Body != nil {
  1215. res.Body.Close()
  1216. }
  1217. return nil, &googleapi.Error{
  1218. Code: res.StatusCode,
  1219. Header: res.Header,
  1220. }
  1221. }
  1222. if err != nil {
  1223. return nil, err
  1224. }
  1225. defer googleapi.CloseBody(res)
  1226. if err := googleapi.CheckResponse(res); err != nil {
  1227. return nil, err
  1228. }
  1229. ret := &UsageReports{
  1230. ServerResponse: googleapi.ServerResponse{
  1231. Header: res.Header,
  1232. HTTPStatusCode: res.StatusCode,
  1233. },
  1234. }
  1235. target := &ret
  1236. if err := gensupport.DecodeResponse(target, res); err != nil {
  1237. return nil, err
  1238. }
  1239. return ret, nil
  1240. // {
  1241. // "description": "Retrieves a report which is a collection of properties / statistics for a specific customer.",
  1242. // "httpMethod": "GET",
  1243. // "id": "reports.customerUsageReports.get",
  1244. // "parameterOrder": [
  1245. // "date"
  1246. // ],
  1247. // "parameters": {
  1248. // "customerId": {
  1249. // "description": "Represents the customer for which the data is to be fetched.",
  1250. // "location": "query",
  1251. // "pattern": "C.+",
  1252. // "type": "string"
  1253. // },
  1254. // "date": {
  1255. // "description": "Represents the date in yyyy-mm-dd format for which the data is to be fetched.",
  1256. // "location": "path",
  1257. // "pattern": "(\\d){4}-(\\d){2}-(\\d){2}",
  1258. // "required": true,
  1259. // "type": "string"
  1260. // },
  1261. // "pageToken": {
  1262. // "description": "Token to specify next page.",
  1263. // "location": "query",
  1264. // "type": "string"
  1265. // },
  1266. // "parameters": {
  1267. // "description": "Represents the application name, parameter name pairs to fetch in csv as app_name1:param_name1, app_name2:param_name2.",
  1268. // "location": "query",
  1269. // "pattern": "(((accounts)|(app_maker)|(apps_scripts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)|(meet)):[^,]+,)*(((accounts)|(app_maker)|(apps_scripts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)|(meet)):[^,]+)",
  1270. // "type": "string"
  1271. // }
  1272. // },
  1273. // "path": "usage/dates/{date}",
  1274. // "response": {
  1275. // "$ref": "UsageReports"
  1276. // },
  1277. // "scopes": [
  1278. // "https://www.googleapis.com/auth/admin.reports.usage.readonly"
  1279. // ]
  1280. // }
  1281. }
  1282. // Pages invokes f for each page of results.
  1283. // A non-nil error returned from f will halt the iteration.
  1284. // The provided context supersedes any context provided to the Context method.
  1285. func (c *CustomerUsageReportsGetCall) Pages(ctx context.Context, f func(*UsageReports) error) error {
  1286. c.ctx_ = ctx
  1287. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1288. for {
  1289. x, err := c.Do()
  1290. if err != nil {
  1291. return err
  1292. }
  1293. if err := f(x); err != nil {
  1294. return err
  1295. }
  1296. if x.NextPageToken == "" {
  1297. return nil
  1298. }
  1299. c.PageToken(x.NextPageToken)
  1300. }
  1301. }
  1302. // method id "reports.entityUsageReports.get":
  1303. type EntityUsageReportsGetCall struct {
  1304. s *Service
  1305. entityType string
  1306. entityKey string
  1307. date string
  1308. urlParams_ gensupport.URLParams
  1309. ifNoneMatch_ string
  1310. ctx_ context.Context
  1311. header_ http.Header
  1312. }
  1313. // Get: Retrieves a report which is a collection of properties /
  1314. // statistics for a set of objects.
  1315. func (r *EntityUsageReportsService) Get(entityType string, entityKey string, date string) *EntityUsageReportsGetCall {
  1316. c := &EntityUsageReportsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1317. c.entityType = entityType
  1318. c.entityKey = entityKey
  1319. c.date = date
  1320. return c
  1321. }
  1322. // CustomerId sets the optional parameter "customerId": Represents the
  1323. // customer for which the data is to be fetched.
  1324. func (c *EntityUsageReportsGetCall) CustomerId(customerId string) *EntityUsageReportsGetCall {
  1325. c.urlParams_.Set("customerId", customerId)
  1326. return c
  1327. }
  1328. // Filters sets the optional parameter "filters": Represents the set of
  1329. // filters including parameter operator value.
  1330. func (c *EntityUsageReportsGetCall) Filters(filters string) *EntityUsageReportsGetCall {
  1331. c.urlParams_.Set("filters", filters)
  1332. return c
  1333. }
  1334. // MaxResults sets the optional parameter "maxResults": Maximum number
  1335. // of results to return. Maximum allowed is 1000
  1336. func (c *EntityUsageReportsGetCall) MaxResults(maxResults int64) *EntityUsageReportsGetCall {
  1337. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1338. return c
  1339. }
  1340. // PageToken sets the optional parameter "pageToken": Token to specify
  1341. // next page.
  1342. func (c *EntityUsageReportsGetCall) PageToken(pageToken string) *EntityUsageReportsGetCall {
  1343. c.urlParams_.Set("pageToken", pageToken)
  1344. return c
  1345. }
  1346. // Parameters sets the optional parameter "parameters": Represents the
  1347. // application name, parameter name pairs to fetch in csv as
  1348. // app_name1:param_name1, app_name2:param_name2.
  1349. func (c *EntityUsageReportsGetCall) Parameters(parameters string) *EntityUsageReportsGetCall {
  1350. c.urlParams_.Set("parameters", parameters)
  1351. return c
  1352. }
  1353. // Fields allows partial responses to be retrieved. See
  1354. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1355. // for more information.
  1356. func (c *EntityUsageReportsGetCall) Fields(s ...googleapi.Field) *EntityUsageReportsGetCall {
  1357. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1358. return c
  1359. }
  1360. // IfNoneMatch sets the optional parameter which makes the operation
  1361. // fail if the object's ETag matches the given value. This is useful for
  1362. // getting updates only after the object has changed since the last
  1363. // request. Use googleapi.IsNotModified to check whether the response
  1364. // error from Do is the result of In-None-Match.
  1365. func (c *EntityUsageReportsGetCall) IfNoneMatch(entityTag string) *EntityUsageReportsGetCall {
  1366. c.ifNoneMatch_ = entityTag
  1367. return c
  1368. }
  1369. // Context sets the context to be used in this call's Do method. Any
  1370. // pending HTTP request will be aborted if the provided context is
  1371. // canceled.
  1372. func (c *EntityUsageReportsGetCall) Context(ctx context.Context) *EntityUsageReportsGetCall {
  1373. c.ctx_ = ctx
  1374. return c
  1375. }
  1376. // Header returns an http.Header that can be modified by the caller to
  1377. // add HTTP headers to the request.
  1378. func (c *EntityUsageReportsGetCall) Header() http.Header {
  1379. if c.header_ == nil {
  1380. c.header_ = make(http.Header)
  1381. }
  1382. return c.header_
  1383. }
  1384. func (c *EntityUsageReportsGetCall) doRequest(alt string) (*http.Response, error) {
  1385. reqHeaders := make(http.Header)
  1386. for k, v := range c.header_ {
  1387. reqHeaders[k] = v
  1388. }
  1389. reqHeaders.Set("User-Agent", c.s.userAgent())
  1390. if c.ifNoneMatch_ != "" {
  1391. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1392. }
  1393. var body io.Reader = nil
  1394. c.urlParams_.Set("alt", alt)
  1395. urls := googleapi.ResolveRelative(c.s.BasePath, "usage/{entityType}/{entityKey}/dates/{date}")
  1396. urls += "?" + c.urlParams_.Encode()
  1397. req, _ := http.NewRequest("GET", urls, body)
  1398. req.Header = reqHeaders
  1399. googleapi.Expand(req.URL, map[string]string{
  1400. "entityType": c.entityType,
  1401. "entityKey": c.entityKey,
  1402. "date": c.date,
  1403. })
  1404. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1405. }
  1406. // Do executes the "reports.entityUsageReports.get" call.
  1407. // Exactly one of *UsageReports or error will be non-nil. Any non-2xx
  1408. // status code is an error. Response headers are in either
  1409. // *UsageReports.ServerResponse.Header or (if a response was returned at
  1410. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1411. // to check whether the returned error was because
  1412. // http.StatusNotModified was returned.
  1413. func (c *EntityUsageReportsGetCall) Do(opts ...googleapi.CallOption) (*UsageReports, error) {
  1414. gensupport.SetOptions(c.urlParams_, opts...)
  1415. res, err := c.doRequest("json")
  1416. if res != nil && res.StatusCode == http.StatusNotModified {
  1417. if res.Body != nil {
  1418. res.Body.Close()
  1419. }
  1420. return nil, &googleapi.Error{
  1421. Code: res.StatusCode,
  1422. Header: res.Header,
  1423. }
  1424. }
  1425. if err != nil {
  1426. return nil, err
  1427. }
  1428. defer googleapi.CloseBody(res)
  1429. if err := googleapi.CheckResponse(res); err != nil {
  1430. return nil, err
  1431. }
  1432. ret := &UsageReports{
  1433. ServerResponse: googleapi.ServerResponse{
  1434. Header: res.Header,
  1435. HTTPStatusCode: res.StatusCode,
  1436. },
  1437. }
  1438. target := &ret
  1439. if err := gensupport.DecodeResponse(target, res); err != nil {
  1440. return nil, err
  1441. }
  1442. return ret, nil
  1443. // {
  1444. // "description": "Retrieves a report which is a collection of properties / statistics for a set of objects.",
  1445. // "httpMethod": "GET",
  1446. // "id": "reports.entityUsageReports.get",
  1447. // "parameterOrder": [
  1448. // "entityType",
  1449. // "entityKey",
  1450. // "date"
  1451. // ],
  1452. // "parameters": {
  1453. // "customerId": {
  1454. // "description": "Represents the customer for which the data is to be fetched.",
  1455. // "location": "query",
  1456. // "pattern": "C.+",
  1457. // "type": "string"
  1458. // },
  1459. // "date": {
  1460. // "description": "Represents the date in yyyy-mm-dd format for which the data is to be fetched.",
  1461. // "location": "path",
  1462. // "pattern": "(\\d){4}-(\\d){2}-(\\d){2}",
  1463. // "required": true,
  1464. // "type": "string"
  1465. // },
  1466. // "entityKey": {
  1467. // "description": "Represents the key of object for which the data should be filtered.",
  1468. // "location": "path",
  1469. // "required": true,
  1470. // "type": "string"
  1471. // },
  1472. // "entityType": {
  1473. // "description": "Type of object. Should be one of - gplus_communities.",
  1474. // "location": "path",
  1475. // "pattern": "(gplus_communities)",
  1476. // "required": true,
  1477. // "type": "string"
  1478. // },
  1479. // "filters": {
  1480. // "description": "Represents the set of filters including parameter operator value.",
  1481. // "location": "query",
  1482. // "pattern": "(((gplus)):[a-z0-9_]+[\u003c,\u003c=,==,\u003e=,\u003e,!=][^,]+,)*(((gplus)):[a-z0-9_]+[\u003c,\u003c=,==,\u003e=,\u003e,!=][^,]+)",
  1483. // "type": "string"
  1484. // },
  1485. // "maxResults": {
  1486. // "description": "Maximum number of results to return. Maximum allowed is 1000",
  1487. // "format": "uint32",
  1488. // "location": "query",
  1489. // "maximum": "1000",
  1490. // "type": "integer"
  1491. // },
  1492. // "pageToken": {
  1493. // "description": "Token to specify next page.",
  1494. // "location": "query",
  1495. // "type": "string"
  1496. // },
  1497. // "parameters": {
  1498. // "description": "Represents the application name, parameter name pairs to fetch in csv as app_name1:param_name1, app_name2:param_name2.",
  1499. // "location": "query",
  1500. // "pattern": "(((gplus)):[^,]+,)*(((gplus)):[^,]+)",
  1501. // "type": "string"
  1502. // }
  1503. // },
  1504. // "path": "usage/{entityType}/{entityKey}/dates/{date}",
  1505. // "response": {
  1506. // "$ref": "UsageReports"
  1507. // },
  1508. // "scopes": [
  1509. // "https://www.googleapis.com/auth/admin.reports.usage.readonly"
  1510. // ]
  1511. // }
  1512. }
  1513. // Pages invokes f for each page of results.
  1514. // A non-nil error returned from f will halt the iteration.
  1515. // The provided context supersedes any context provided to the Context method.
  1516. func (c *EntityUsageReportsGetCall) Pages(ctx context.Context, f func(*UsageReports) error) error {
  1517. c.ctx_ = ctx
  1518. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1519. for {
  1520. x, err := c.Do()
  1521. if err != nil {
  1522. return err
  1523. }
  1524. if err := f(x); err != nil {
  1525. return err
  1526. }
  1527. if x.NextPageToken == "" {
  1528. return nil
  1529. }
  1530. c.PageToken(x.NextPageToken)
  1531. }
  1532. }
  1533. // method id "reports.userUsageReport.get":
  1534. type UserUsageReportGetCall struct {
  1535. s *Service
  1536. userKey string
  1537. date string
  1538. urlParams_ gensupport.URLParams
  1539. ifNoneMatch_ string
  1540. ctx_ context.Context
  1541. header_ http.Header
  1542. }
  1543. // Get: Retrieves a report which is a collection of properties /
  1544. // statistics for a set of users.
  1545. func (r *UserUsageReportService) Get(userKey string, date string) *UserUsageReportGetCall {
  1546. c := &UserUsageReportGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1547. c.userKey = userKey
  1548. c.date = date
  1549. return c
  1550. }
  1551. // CustomerId sets the optional parameter "customerId": Represents the
  1552. // customer for which the data is to be fetched.
  1553. func (c *UserUsageReportGetCall) CustomerId(customerId string) *UserUsageReportGetCall {
  1554. c.urlParams_.Set("customerId", customerId)
  1555. return c
  1556. }
  1557. // Filters sets the optional parameter "filters": Represents the set of
  1558. // filters including parameter operator value.
  1559. func (c *UserUsageReportGetCall) Filters(filters string) *UserUsageReportGetCall {
  1560. c.urlParams_.Set("filters", filters)
  1561. return c
  1562. }
  1563. // MaxResults sets the optional parameter "maxResults": Maximum number
  1564. // of results to return. Maximum allowed is 1000
  1565. func (c *UserUsageReportGetCall) MaxResults(maxResults int64) *UserUsageReportGetCall {
  1566. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1567. return c
  1568. }
  1569. // PageToken sets the optional parameter "pageToken": Token to specify
  1570. // next page.
  1571. func (c *UserUsageReportGetCall) PageToken(pageToken string) *UserUsageReportGetCall {
  1572. c.urlParams_.Set("pageToken", pageToken)
  1573. return c
  1574. }
  1575. // Parameters sets the optional parameter "parameters": Represents the
  1576. // application name, parameter name pairs to fetch in csv as
  1577. // app_name1:param_name1, app_name2:param_name2.
  1578. func (c *UserUsageReportGetCall) Parameters(parameters string) *UserUsageReportGetCall {
  1579. c.urlParams_.Set("parameters", parameters)
  1580. return c
  1581. }
  1582. // Fields allows partial responses to be retrieved. See
  1583. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1584. // for more information.
  1585. func (c *UserUsageReportGetCall) Fields(s ...googleapi.Field) *UserUsageReportGetCall {
  1586. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1587. return c
  1588. }
  1589. // IfNoneMatch sets the optional parameter which makes the operation
  1590. // fail if the object's ETag matches the given value. This is useful for
  1591. // getting updates only after the object has changed since the last
  1592. // request. Use googleapi.IsNotModified to check whether the response
  1593. // error from Do is the result of In-None-Match.
  1594. func (c *UserUsageReportGetCall) IfNoneMatch(entityTag string) *UserUsageReportGetCall {
  1595. c.ifNoneMatch_ = entityTag
  1596. return c
  1597. }
  1598. // Context sets the context to be used in this call's Do method. Any
  1599. // pending HTTP request will be aborted if the provided context is
  1600. // canceled.
  1601. func (c *UserUsageReportGetCall) Context(ctx context.Context) *UserUsageReportGetCall {
  1602. c.ctx_ = ctx
  1603. return c
  1604. }
  1605. // Header returns an http.Header that can be modified by the caller to
  1606. // add HTTP headers to the request.
  1607. func (c *UserUsageReportGetCall) Header() http.Header {
  1608. if c.header_ == nil {
  1609. c.header_ = make(http.Header)
  1610. }
  1611. return c.header_
  1612. }
  1613. func (c *UserUsageReportGetCall) doRequest(alt string) (*http.Response, error) {
  1614. reqHeaders := make(http.Header)
  1615. for k, v := range c.header_ {
  1616. reqHeaders[k] = v
  1617. }
  1618. reqHeaders.Set("User-Agent", c.s.userAgent())
  1619. if c.ifNoneMatch_ != "" {
  1620. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1621. }
  1622. var body io.Reader = nil
  1623. c.urlParams_.Set("alt", alt)
  1624. urls := googleapi.ResolveRelative(c.s.BasePath, "usage/users/{userKey}/dates/{date}")
  1625. urls += "?" + c.urlParams_.Encode()
  1626. req, _ := http.NewRequest("GET", urls, body)
  1627. req.Header = reqHeaders
  1628. googleapi.Expand(req.URL, map[string]string{
  1629. "userKey": c.userKey,
  1630. "date": c.date,
  1631. })
  1632. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1633. }
  1634. // Do executes the "reports.userUsageReport.get" call.
  1635. // Exactly one of *UsageReports or error will be non-nil. Any non-2xx
  1636. // status code is an error. Response headers are in either
  1637. // *UsageReports.ServerResponse.Header or (if a response was returned at
  1638. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1639. // to check whether the returned error was because
  1640. // http.StatusNotModified was returned.
  1641. func (c *UserUsageReportGetCall) Do(opts ...googleapi.CallOption) (*UsageReports, error) {
  1642. gensupport.SetOptions(c.urlParams_, opts...)
  1643. res, err := c.doRequest("json")
  1644. if res != nil && res.StatusCode == http.StatusNotModified {
  1645. if res.Body != nil {
  1646. res.Body.Close()
  1647. }
  1648. return nil, &googleapi.Error{
  1649. Code: res.StatusCode,
  1650. Header: res.Header,
  1651. }
  1652. }
  1653. if err != nil {
  1654. return nil, err
  1655. }
  1656. defer googleapi.CloseBody(res)
  1657. if err := googleapi.CheckResponse(res); err != nil {
  1658. return nil, err
  1659. }
  1660. ret := &UsageReports{
  1661. ServerResponse: googleapi.ServerResponse{
  1662. Header: res.Header,
  1663. HTTPStatusCode: res.StatusCode,
  1664. },
  1665. }
  1666. target := &ret
  1667. if err := gensupport.DecodeResponse(target, res); err != nil {
  1668. return nil, err
  1669. }
  1670. return ret, nil
  1671. // {
  1672. // "description": "Retrieves a report which is a collection of properties / statistics for a set of users.",
  1673. // "httpMethod": "GET",
  1674. // "id": "reports.userUsageReport.get",
  1675. // "parameterOrder": [
  1676. // "userKey",
  1677. // "date"
  1678. // ],
  1679. // "parameters": {
  1680. // "customerId": {
  1681. // "description": "Represents the customer for which the data is to be fetched.",
  1682. // "location": "query",
  1683. // "pattern": "C.+",
  1684. // "type": "string"
  1685. // },
  1686. // "date": {
  1687. // "description": "Represents the date in yyyy-mm-dd format for which the data is to be fetched.",
  1688. // "location": "path",
  1689. // "pattern": "(\\d){4}-(\\d){2}-(\\d){2}",
  1690. // "required": true,
  1691. // "type": "string"
  1692. // },
  1693. // "filters": {
  1694. // "description": "Represents the set of filters including parameter operator value.",
  1695. // "location": "query",
  1696. // "pattern": "(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):[a-z0-9_]+[\u003c,\u003c=,==,\u003e=,\u003e,!=][^,]+,)*(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):[a-z0-9_]+[\u003c,\u003c=,==,\u003e=,\u003e,!=][^,]+)",
  1697. // "type": "string"
  1698. // },
  1699. // "maxResults": {
  1700. // "description": "Maximum number of results to return. Maximum allowed is 1000",
  1701. // "format": "uint32",
  1702. // "location": "query",
  1703. // "maximum": "1000",
  1704. // "type": "integer"
  1705. // },
  1706. // "pageToken": {
  1707. // "description": "Token to specify next page.",
  1708. // "location": "query",
  1709. // "type": "string"
  1710. // },
  1711. // "parameters": {
  1712. // "description": "Represents the application name, parameter name pairs to fetch in csv as app_name1:param_name1, app_name2:param_name2.",
  1713. // "location": "query",
  1714. // "pattern": "(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):[^,]+,)*(((accounts)|(classroom)|(cros)|(gmail)|(calendar)|(docs)|(gplus)|(sites)|(device_management)|(drive)):[^,]+)",
  1715. // "type": "string"
  1716. // },
  1717. // "userKey": {
  1718. // "description": "Represents the profile id or the user email for which the data should be filtered.",
  1719. // "location": "path",
  1720. // "required": true,
  1721. // "type": "string"
  1722. // }
  1723. // },
  1724. // "path": "usage/users/{userKey}/dates/{date}",
  1725. // "response": {
  1726. // "$ref": "UsageReports"
  1727. // },
  1728. // "scopes": [
  1729. // "https://www.googleapis.com/auth/admin.reports.usage.readonly"
  1730. // ]
  1731. // }
  1732. }
  1733. // Pages invokes f for each page of results.
  1734. // A non-nil error returned from f will halt the iteration.
  1735. // The provided context supersedes any context provided to the Context method.
  1736. func (c *UserUsageReportGetCall) Pages(ctx context.Context, f func(*UsageReports) error) error {
  1737. c.ctx_ = ctx
  1738. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1739. for {
  1740. x, err := c.Do()
  1741. if err != nil {
  1742. return err
  1743. }
  1744. if err := f(x); err != nil {
  1745. return err
  1746. }
  1747. if x.NextPageToken == "" {
  1748. return nil
  1749. }
  1750. c.PageToken(x.NextPageToken)
  1751. }
  1752. }