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.
 
 
 

1068 lines
35 KiB

  1. // Package analytics provides access to the Google Analytics API.
  2. //
  3. // See https://developers.google.com/analytics/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/analytics/v2.4"
  8. // ...
  9. // analyticsService, err := analytics.New(oauthHttpClient)
  10. package analytics // import "google.golang.org/api/analytics/v2.4"
  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 = "analytics:v2.4"
  41. const apiName = "analytics"
  42. const apiVersion = "v2.4"
  43. const basePath = "https://www.googleapis.com/analytics/v2.4/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your Google Analytics data
  47. AnalyticsScope = "https://www.googleapis.com/auth/analytics"
  48. // View your Google Analytics data
  49. AnalyticsReadonlyScope = "https://www.googleapis.com/auth/analytics.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.Data = NewDataService(s)
  57. s.Management = NewManagementService(s)
  58. return s, nil
  59. }
  60. type Service struct {
  61. client *http.Client
  62. BasePath string // API endpoint base URL
  63. UserAgent string // optional additional User-Agent fragment
  64. Data *DataService
  65. Management *ManagementService
  66. }
  67. func (s *Service) userAgent() string {
  68. if s.UserAgent == "" {
  69. return googleapi.UserAgent
  70. }
  71. return googleapi.UserAgent + " " + s.UserAgent
  72. }
  73. func NewDataService(s *Service) *DataService {
  74. rs := &DataService{s: s}
  75. return rs
  76. }
  77. type DataService struct {
  78. s *Service
  79. }
  80. func NewManagementService(s *Service) *ManagementService {
  81. rs := &ManagementService{s: s}
  82. rs.Accounts = NewManagementAccountsService(s)
  83. rs.Goals = NewManagementGoalsService(s)
  84. rs.Profiles = NewManagementProfilesService(s)
  85. rs.Segments = NewManagementSegmentsService(s)
  86. rs.Webproperties = NewManagementWebpropertiesService(s)
  87. return rs
  88. }
  89. type ManagementService struct {
  90. s *Service
  91. Accounts *ManagementAccountsService
  92. Goals *ManagementGoalsService
  93. Profiles *ManagementProfilesService
  94. Segments *ManagementSegmentsService
  95. Webproperties *ManagementWebpropertiesService
  96. }
  97. func NewManagementAccountsService(s *Service) *ManagementAccountsService {
  98. rs := &ManagementAccountsService{s: s}
  99. return rs
  100. }
  101. type ManagementAccountsService struct {
  102. s *Service
  103. }
  104. func NewManagementGoalsService(s *Service) *ManagementGoalsService {
  105. rs := &ManagementGoalsService{s: s}
  106. return rs
  107. }
  108. type ManagementGoalsService struct {
  109. s *Service
  110. }
  111. func NewManagementProfilesService(s *Service) *ManagementProfilesService {
  112. rs := &ManagementProfilesService{s: s}
  113. return rs
  114. }
  115. type ManagementProfilesService struct {
  116. s *Service
  117. }
  118. func NewManagementSegmentsService(s *Service) *ManagementSegmentsService {
  119. rs := &ManagementSegmentsService{s: s}
  120. return rs
  121. }
  122. type ManagementSegmentsService struct {
  123. s *Service
  124. }
  125. func NewManagementWebpropertiesService(s *Service) *ManagementWebpropertiesService {
  126. rs := &ManagementWebpropertiesService{s: s}
  127. return rs
  128. }
  129. type ManagementWebpropertiesService struct {
  130. s *Service
  131. }
  132. // method id "analytics.data.get":
  133. type DataGetCall struct {
  134. s *Service
  135. urlParams_ gensupport.URLParams
  136. ifNoneMatch_ string
  137. ctx_ context.Context
  138. header_ http.Header
  139. }
  140. // Get: Returns Analytics report data for a view (profile).
  141. func (r *DataService) Get(ids string, startDate string, endDate string, metrics string) *DataGetCall {
  142. c := &DataGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  143. c.urlParams_.Set("ids", ids)
  144. c.urlParams_.Set("start-date", startDate)
  145. c.urlParams_.Set("end-date", endDate)
  146. c.urlParams_.Set("metrics", metrics)
  147. return c
  148. }
  149. // Dimensions sets the optional parameter "dimensions": A
  150. // comma-separated list of Analytics dimensions. E.g.,
  151. // 'ga:browser,ga:city'.
  152. func (c *DataGetCall) Dimensions(dimensions string) *DataGetCall {
  153. c.urlParams_.Set("dimensions", dimensions)
  154. return c
  155. }
  156. // Filters sets the optional parameter "filters": A comma-separated list
  157. // of dimension or metric filters to be applied to the report data.
  158. func (c *DataGetCall) Filters(filters string) *DataGetCall {
  159. c.urlParams_.Set("filters", filters)
  160. return c
  161. }
  162. // MaxResults sets the optional parameter "max-results": The maximum
  163. // number of entries to include in this feed.
  164. func (c *DataGetCall) MaxResults(maxResults int64) *DataGetCall {
  165. c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  166. return c
  167. }
  168. // Segment sets the optional parameter "segment": An Analytics advanced
  169. // segment to be applied to the report data.
  170. func (c *DataGetCall) Segment(segment string) *DataGetCall {
  171. c.urlParams_.Set("segment", segment)
  172. return c
  173. }
  174. // Sort sets the optional parameter "sort": A comma-separated list of
  175. // dimensions or metrics that determine the sort order for the report
  176. // data.
  177. func (c *DataGetCall) Sort(sort string) *DataGetCall {
  178. c.urlParams_.Set("sort", sort)
  179. return c
  180. }
  181. // StartIndex sets the optional parameter "start-index": An index of the
  182. // first entity to retrieve. Use this parameter as a pagination
  183. // mechanism along with the max-results parameter.
  184. func (c *DataGetCall) StartIndex(startIndex int64) *DataGetCall {
  185. c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  186. return c
  187. }
  188. // Fields allows partial responses to be retrieved. See
  189. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  190. // for more information.
  191. func (c *DataGetCall) Fields(s ...googleapi.Field) *DataGetCall {
  192. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  193. return c
  194. }
  195. // IfNoneMatch sets the optional parameter which makes the operation
  196. // fail if the object's ETag matches the given value. This is useful for
  197. // getting updates only after the object has changed since the last
  198. // request. Use googleapi.IsNotModified to check whether the response
  199. // error from Do is the result of In-None-Match.
  200. func (c *DataGetCall) IfNoneMatch(entityTag string) *DataGetCall {
  201. c.ifNoneMatch_ = entityTag
  202. return c
  203. }
  204. // Context sets the context to be used in this call's Do method. Any
  205. // pending HTTP request will be aborted if the provided context is
  206. // canceled.
  207. func (c *DataGetCall) Context(ctx context.Context) *DataGetCall {
  208. c.ctx_ = ctx
  209. return c
  210. }
  211. // Header returns an http.Header that can be modified by the caller to
  212. // add HTTP headers to the request.
  213. func (c *DataGetCall) Header() http.Header {
  214. if c.header_ == nil {
  215. c.header_ = make(http.Header)
  216. }
  217. return c.header_
  218. }
  219. func (c *DataGetCall) doRequest(alt string) (*http.Response, error) {
  220. reqHeaders := make(http.Header)
  221. for k, v := range c.header_ {
  222. reqHeaders[k] = v
  223. }
  224. reqHeaders.Set("User-Agent", c.s.userAgent())
  225. if c.ifNoneMatch_ != "" {
  226. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  227. }
  228. var body io.Reader = nil
  229. c.urlParams_.Set("alt", alt)
  230. urls := googleapi.ResolveRelative(c.s.BasePath, "data")
  231. urls += "?" + c.urlParams_.Encode()
  232. req, _ := http.NewRequest("GET", urls, body)
  233. req.Header = reqHeaders
  234. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  235. }
  236. // Do executes the "analytics.data.get" call.
  237. func (c *DataGetCall) Do(opts ...googleapi.CallOption) error {
  238. gensupport.SetOptions(c.urlParams_, opts...)
  239. res, err := c.doRequest("json")
  240. if err != nil {
  241. return err
  242. }
  243. defer googleapi.CloseBody(res)
  244. if err := googleapi.CheckResponse(res); err != nil {
  245. return err
  246. }
  247. return nil
  248. // {
  249. // "description": "Returns Analytics report data for a view (profile).",
  250. // "httpMethod": "GET",
  251. // "id": "analytics.data.get",
  252. // "parameterOrder": [
  253. // "ids",
  254. // "start-date",
  255. // "end-date",
  256. // "metrics"
  257. // ],
  258. // "parameters": {
  259. // "dimensions": {
  260. // "description": "A comma-separated list of Analytics dimensions. E.g., 'ga:browser,ga:city'.",
  261. // "location": "query",
  262. // "pattern": "(ga:.+)?",
  263. // "type": "string"
  264. // },
  265. // "end-date": {
  266. // "description": "End date for fetching report data. All requests should specify an end date formatted as YYYY-MM-DD.",
  267. // "location": "query",
  268. // "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
  269. // "required": true,
  270. // "type": "string"
  271. // },
  272. // "filters": {
  273. // "description": "A comma-separated list of dimension or metric filters to be applied to the report data.",
  274. // "location": "query",
  275. // "pattern": "ga:.+",
  276. // "type": "string"
  277. // },
  278. // "ids": {
  279. // "description": "Unique table ID for retrieving report data. Table ID is of the form ga:XXXX, where XXXX is the Analytics view (profile) ID.",
  280. // "location": "query",
  281. // "pattern": "ga:[0-9]+",
  282. // "required": true,
  283. // "type": "string"
  284. // },
  285. // "max-results": {
  286. // "description": "The maximum number of entries to include in this feed.",
  287. // "format": "int32",
  288. // "location": "query",
  289. // "type": "integer"
  290. // },
  291. // "metrics": {
  292. // "description": "A comma-separated list of Analytics metrics. E.g., 'ga:sessions,ga:pageviews'. At least one metric must be specified to retrieve a valid Analytics report.",
  293. // "location": "query",
  294. // "pattern": "ga:.+",
  295. // "required": true,
  296. // "type": "string"
  297. // },
  298. // "segment": {
  299. // "description": "An Analytics advanced segment to be applied to the report data.",
  300. // "location": "query",
  301. // "type": "string"
  302. // },
  303. // "sort": {
  304. // "description": "A comma-separated list of dimensions or metrics that determine the sort order for the report data.",
  305. // "location": "query",
  306. // "pattern": "(-)?ga:.+",
  307. // "type": "string"
  308. // },
  309. // "start-date": {
  310. // "description": "Start date for fetching report data. All requests should specify a start date formatted as YYYY-MM-DD.",
  311. // "location": "query",
  312. // "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
  313. // "required": true,
  314. // "type": "string"
  315. // },
  316. // "start-index": {
  317. // "description": "An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  318. // "format": "int32",
  319. // "location": "query",
  320. // "minimum": "1",
  321. // "type": "integer"
  322. // }
  323. // },
  324. // "path": "data",
  325. // "scopes": [
  326. // "https://www.googleapis.com/auth/analytics",
  327. // "https://www.googleapis.com/auth/analytics.readonly"
  328. // ]
  329. // }
  330. }
  331. // method id "analytics.management.accounts.list":
  332. type ManagementAccountsListCall struct {
  333. s *Service
  334. urlParams_ gensupport.URLParams
  335. ifNoneMatch_ string
  336. ctx_ context.Context
  337. header_ http.Header
  338. }
  339. // List: Lists all accounts to which the user has access.
  340. func (r *ManagementAccountsService) List() *ManagementAccountsListCall {
  341. c := &ManagementAccountsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  342. return c
  343. }
  344. // MaxResults sets the optional parameter "max-results": The maximum
  345. // number of accounts to include in this response.
  346. func (c *ManagementAccountsListCall) MaxResults(maxResults int64) *ManagementAccountsListCall {
  347. c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  348. return c
  349. }
  350. // StartIndex sets the optional parameter "start-index": An index of the
  351. // first account to retrieve. Use this parameter as a pagination
  352. // mechanism along with the max-results parameter.
  353. func (c *ManagementAccountsListCall) StartIndex(startIndex int64) *ManagementAccountsListCall {
  354. c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  355. return c
  356. }
  357. // Fields allows partial responses to be retrieved. See
  358. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  359. // for more information.
  360. func (c *ManagementAccountsListCall) Fields(s ...googleapi.Field) *ManagementAccountsListCall {
  361. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  362. return c
  363. }
  364. // IfNoneMatch sets the optional parameter which makes the operation
  365. // fail if the object's ETag matches the given value. This is useful for
  366. // getting updates only after the object has changed since the last
  367. // request. Use googleapi.IsNotModified to check whether the response
  368. // error from Do is the result of In-None-Match.
  369. func (c *ManagementAccountsListCall) IfNoneMatch(entityTag string) *ManagementAccountsListCall {
  370. c.ifNoneMatch_ = entityTag
  371. return c
  372. }
  373. // Context sets the context to be used in this call's Do method. Any
  374. // pending HTTP request will be aborted if the provided context is
  375. // canceled.
  376. func (c *ManagementAccountsListCall) Context(ctx context.Context) *ManagementAccountsListCall {
  377. c.ctx_ = ctx
  378. return c
  379. }
  380. // Header returns an http.Header that can be modified by the caller to
  381. // add HTTP headers to the request.
  382. func (c *ManagementAccountsListCall) Header() http.Header {
  383. if c.header_ == nil {
  384. c.header_ = make(http.Header)
  385. }
  386. return c.header_
  387. }
  388. func (c *ManagementAccountsListCall) doRequest(alt string) (*http.Response, error) {
  389. reqHeaders := make(http.Header)
  390. for k, v := range c.header_ {
  391. reqHeaders[k] = v
  392. }
  393. reqHeaders.Set("User-Agent", c.s.userAgent())
  394. if c.ifNoneMatch_ != "" {
  395. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  396. }
  397. var body io.Reader = nil
  398. c.urlParams_.Set("alt", alt)
  399. urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts")
  400. urls += "?" + c.urlParams_.Encode()
  401. req, _ := http.NewRequest("GET", urls, body)
  402. req.Header = reqHeaders
  403. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  404. }
  405. // Do executes the "analytics.management.accounts.list" call.
  406. func (c *ManagementAccountsListCall) Do(opts ...googleapi.CallOption) error {
  407. gensupport.SetOptions(c.urlParams_, opts...)
  408. res, err := c.doRequest("json")
  409. if err != nil {
  410. return err
  411. }
  412. defer googleapi.CloseBody(res)
  413. if err := googleapi.CheckResponse(res); err != nil {
  414. return err
  415. }
  416. return nil
  417. // {
  418. // "description": "Lists all accounts to which the user has access.",
  419. // "httpMethod": "GET",
  420. // "id": "analytics.management.accounts.list",
  421. // "parameters": {
  422. // "max-results": {
  423. // "description": "The maximum number of accounts to include in this response.",
  424. // "format": "int32",
  425. // "location": "query",
  426. // "type": "integer"
  427. // },
  428. // "start-index": {
  429. // "description": "An index of the first account to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  430. // "format": "int32",
  431. // "location": "query",
  432. // "minimum": "1",
  433. // "type": "integer"
  434. // }
  435. // },
  436. // "path": "management/accounts",
  437. // "scopes": [
  438. // "https://www.googleapis.com/auth/analytics",
  439. // "https://www.googleapis.com/auth/analytics.readonly"
  440. // ]
  441. // }
  442. }
  443. // method id "analytics.management.goals.list":
  444. type ManagementGoalsListCall struct {
  445. s *Service
  446. accountId string
  447. webPropertyId string
  448. profileId string
  449. urlParams_ gensupport.URLParams
  450. ifNoneMatch_ string
  451. ctx_ context.Context
  452. header_ http.Header
  453. }
  454. // List: Lists goals to which the user has access.
  455. func (r *ManagementGoalsService) List(accountId string, webPropertyId string, profileId string) *ManagementGoalsListCall {
  456. c := &ManagementGoalsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  457. c.accountId = accountId
  458. c.webPropertyId = webPropertyId
  459. c.profileId = profileId
  460. return c
  461. }
  462. // MaxResults sets the optional parameter "max-results": The maximum
  463. // number of goals to include in this response.
  464. func (c *ManagementGoalsListCall) MaxResults(maxResults int64) *ManagementGoalsListCall {
  465. c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  466. return c
  467. }
  468. // StartIndex sets the optional parameter "start-index": An index of the
  469. // first goal to retrieve. Use this parameter as a pagination mechanism
  470. // along with the max-results parameter.
  471. func (c *ManagementGoalsListCall) StartIndex(startIndex int64) *ManagementGoalsListCall {
  472. c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  473. return c
  474. }
  475. // Fields allows partial responses to be retrieved. See
  476. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  477. // for more information.
  478. func (c *ManagementGoalsListCall) Fields(s ...googleapi.Field) *ManagementGoalsListCall {
  479. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  480. return c
  481. }
  482. // IfNoneMatch sets the optional parameter which makes the operation
  483. // fail if the object's ETag matches the given value. This is useful for
  484. // getting updates only after the object has changed since the last
  485. // request. Use googleapi.IsNotModified to check whether the response
  486. // error from Do is the result of In-None-Match.
  487. func (c *ManagementGoalsListCall) IfNoneMatch(entityTag string) *ManagementGoalsListCall {
  488. c.ifNoneMatch_ = entityTag
  489. return c
  490. }
  491. // Context sets the context to be used in this call's Do method. Any
  492. // pending HTTP request will be aborted if the provided context is
  493. // canceled.
  494. func (c *ManagementGoalsListCall) Context(ctx context.Context) *ManagementGoalsListCall {
  495. c.ctx_ = ctx
  496. return c
  497. }
  498. // Header returns an http.Header that can be modified by the caller to
  499. // add HTTP headers to the request.
  500. func (c *ManagementGoalsListCall) Header() http.Header {
  501. if c.header_ == nil {
  502. c.header_ = make(http.Header)
  503. }
  504. return c.header_
  505. }
  506. func (c *ManagementGoalsListCall) doRequest(alt string) (*http.Response, error) {
  507. reqHeaders := make(http.Header)
  508. for k, v := range c.header_ {
  509. reqHeaders[k] = v
  510. }
  511. reqHeaders.Set("User-Agent", c.s.userAgent())
  512. if c.ifNoneMatch_ != "" {
  513. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  514. }
  515. var body io.Reader = nil
  516. c.urlParams_.Set("alt", alt)
  517. urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals")
  518. urls += "?" + c.urlParams_.Encode()
  519. req, _ := http.NewRequest("GET", urls, body)
  520. req.Header = reqHeaders
  521. googleapi.Expand(req.URL, map[string]string{
  522. "accountId": c.accountId,
  523. "webPropertyId": c.webPropertyId,
  524. "profileId": c.profileId,
  525. })
  526. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  527. }
  528. // Do executes the "analytics.management.goals.list" call.
  529. func (c *ManagementGoalsListCall) Do(opts ...googleapi.CallOption) error {
  530. gensupport.SetOptions(c.urlParams_, opts...)
  531. res, err := c.doRequest("json")
  532. if err != nil {
  533. return err
  534. }
  535. defer googleapi.CloseBody(res)
  536. if err := googleapi.CheckResponse(res); err != nil {
  537. return err
  538. }
  539. return nil
  540. // {
  541. // "description": "Lists goals to which the user has access.",
  542. // "httpMethod": "GET",
  543. // "id": "analytics.management.goals.list",
  544. // "parameterOrder": [
  545. // "accountId",
  546. // "webPropertyId",
  547. // "profileId"
  548. // ],
  549. // "parameters": {
  550. // "accountId": {
  551. // "description": "Account ID to retrieve goals for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.",
  552. // "location": "path",
  553. // "required": true,
  554. // "type": "string"
  555. // },
  556. // "max-results": {
  557. // "description": "The maximum number of goals to include in this response.",
  558. // "format": "int32",
  559. // "location": "query",
  560. // "type": "integer"
  561. // },
  562. // "profileId": {
  563. // "description": "View (Profile) ID to retrieve goals for. Can either be a specific view (profile) ID or '~all', which refers to all the views (profiles) that user has access to.",
  564. // "location": "path",
  565. // "required": true,
  566. // "type": "string"
  567. // },
  568. // "start-index": {
  569. // "description": "An index of the first goal to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  570. // "format": "int32",
  571. // "location": "query",
  572. // "minimum": "1",
  573. // "type": "integer"
  574. // },
  575. // "webPropertyId": {
  576. // "description": "Web property ID to retrieve goals for. Can either be a specific web property ID or '~all', which refers to all the web properties that user has access to.",
  577. // "location": "path",
  578. // "required": true,
  579. // "type": "string"
  580. // }
  581. // },
  582. // "path": "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles/{profileId}/goals",
  583. // "scopes": [
  584. // "https://www.googleapis.com/auth/analytics",
  585. // "https://www.googleapis.com/auth/analytics.readonly"
  586. // ]
  587. // }
  588. }
  589. // method id "analytics.management.profiles.list":
  590. type ManagementProfilesListCall struct {
  591. s *Service
  592. accountId string
  593. webPropertyId string
  594. urlParams_ gensupport.URLParams
  595. ifNoneMatch_ string
  596. ctx_ context.Context
  597. header_ http.Header
  598. }
  599. // List: Lists views (profiles) to which the user has access.
  600. func (r *ManagementProfilesService) List(accountId string, webPropertyId string) *ManagementProfilesListCall {
  601. c := &ManagementProfilesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  602. c.accountId = accountId
  603. c.webPropertyId = webPropertyId
  604. return c
  605. }
  606. // MaxResults sets the optional parameter "max-results": The maximum
  607. // number of views (profiles) to include in this response.
  608. func (c *ManagementProfilesListCall) MaxResults(maxResults int64) *ManagementProfilesListCall {
  609. c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  610. return c
  611. }
  612. // StartIndex sets the optional parameter "start-index": An index of the
  613. // first entity to retrieve. Use this parameter as a pagination
  614. // mechanism along with the max-results parameter.
  615. func (c *ManagementProfilesListCall) StartIndex(startIndex int64) *ManagementProfilesListCall {
  616. c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  617. return c
  618. }
  619. // Fields allows partial responses to be retrieved. See
  620. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  621. // for more information.
  622. func (c *ManagementProfilesListCall) Fields(s ...googleapi.Field) *ManagementProfilesListCall {
  623. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  624. return c
  625. }
  626. // IfNoneMatch sets the optional parameter which makes the operation
  627. // fail if the object's ETag matches the given value. This is useful for
  628. // getting updates only after the object has changed since the last
  629. // request. Use googleapi.IsNotModified to check whether the response
  630. // error from Do is the result of In-None-Match.
  631. func (c *ManagementProfilesListCall) IfNoneMatch(entityTag string) *ManagementProfilesListCall {
  632. c.ifNoneMatch_ = entityTag
  633. return c
  634. }
  635. // Context sets the context to be used in this call's Do method. Any
  636. // pending HTTP request will be aborted if the provided context is
  637. // canceled.
  638. func (c *ManagementProfilesListCall) Context(ctx context.Context) *ManagementProfilesListCall {
  639. c.ctx_ = ctx
  640. return c
  641. }
  642. // Header returns an http.Header that can be modified by the caller to
  643. // add HTTP headers to the request.
  644. func (c *ManagementProfilesListCall) Header() http.Header {
  645. if c.header_ == nil {
  646. c.header_ = make(http.Header)
  647. }
  648. return c.header_
  649. }
  650. func (c *ManagementProfilesListCall) doRequest(alt string) (*http.Response, error) {
  651. reqHeaders := make(http.Header)
  652. for k, v := range c.header_ {
  653. reqHeaders[k] = v
  654. }
  655. reqHeaders.Set("User-Agent", c.s.userAgent())
  656. if c.ifNoneMatch_ != "" {
  657. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  658. }
  659. var body io.Reader = nil
  660. c.urlParams_.Set("alt", alt)
  661. urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles")
  662. urls += "?" + c.urlParams_.Encode()
  663. req, _ := http.NewRequest("GET", urls, body)
  664. req.Header = reqHeaders
  665. googleapi.Expand(req.URL, map[string]string{
  666. "accountId": c.accountId,
  667. "webPropertyId": c.webPropertyId,
  668. })
  669. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  670. }
  671. // Do executes the "analytics.management.profiles.list" call.
  672. func (c *ManagementProfilesListCall) Do(opts ...googleapi.CallOption) error {
  673. gensupport.SetOptions(c.urlParams_, opts...)
  674. res, err := c.doRequest("json")
  675. if err != nil {
  676. return err
  677. }
  678. defer googleapi.CloseBody(res)
  679. if err := googleapi.CheckResponse(res); err != nil {
  680. return err
  681. }
  682. return nil
  683. // {
  684. // "description": "Lists views (profiles) to which the user has access.",
  685. // "httpMethod": "GET",
  686. // "id": "analytics.management.profiles.list",
  687. // "parameterOrder": [
  688. // "accountId",
  689. // "webPropertyId"
  690. // ],
  691. // "parameters": {
  692. // "accountId": {
  693. // "description": "Account ID for the views (profiles) to retrieve. Can either be a specific account ID or '~all', which refers to all the accounts to which the user has access.",
  694. // "location": "path",
  695. // "required": true,
  696. // "type": "string"
  697. // },
  698. // "max-results": {
  699. // "description": "The maximum number of views (profiles) to include in this response.",
  700. // "format": "int32",
  701. // "location": "query",
  702. // "type": "integer"
  703. // },
  704. // "start-index": {
  705. // "description": "An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  706. // "format": "int32",
  707. // "location": "query",
  708. // "minimum": "1",
  709. // "type": "integer"
  710. // },
  711. // "webPropertyId": {
  712. // "description": "Web property ID for the views (profiles) to retrieve. Can either be a specific web property ID or '~all', which refers to all the web properties to which the user has access.",
  713. // "location": "path",
  714. // "required": true,
  715. // "type": "string"
  716. // }
  717. // },
  718. // "path": "management/accounts/{accountId}/webproperties/{webPropertyId}/profiles",
  719. // "scopes": [
  720. // "https://www.googleapis.com/auth/analytics",
  721. // "https://www.googleapis.com/auth/analytics.readonly"
  722. // ]
  723. // }
  724. }
  725. // method id "analytics.management.segments.list":
  726. type ManagementSegmentsListCall struct {
  727. s *Service
  728. urlParams_ gensupport.URLParams
  729. ifNoneMatch_ string
  730. ctx_ context.Context
  731. header_ http.Header
  732. }
  733. // List: Lists advanced segments to which the user has access.
  734. func (r *ManagementSegmentsService) List() *ManagementSegmentsListCall {
  735. c := &ManagementSegmentsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  736. return c
  737. }
  738. // MaxResults sets the optional parameter "max-results": The maximum
  739. // number of advanced segments to include in this response.
  740. func (c *ManagementSegmentsListCall) MaxResults(maxResults int64) *ManagementSegmentsListCall {
  741. c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  742. return c
  743. }
  744. // StartIndex sets the optional parameter "start-index": An index of the
  745. // first advanced segment to retrieve. Use this parameter as a
  746. // pagination mechanism along with the max-results parameter.
  747. func (c *ManagementSegmentsListCall) StartIndex(startIndex int64) *ManagementSegmentsListCall {
  748. c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  749. return c
  750. }
  751. // Fields allows partial responses to be retrieved. See
  752. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  753. // for more information.
  754. func (c *ManagementSegmentsListCall) Fields(s ...googleapi.Field) *ManagementSegmentsListCall {
  755. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  756. return c
  757. }
  758. // IfNoneMatch sets the optional parameter which makes the operation
  759. // fail if the object's ETag matches the given value. This is useful for
  760. // getting updates only after the object has changed since the last
  761. // request. Use googleapi.IsNotModified to check whether the response
  762. // error from Do is the result of In-None-Match.
  763. func (c *ManagementSegmentsListCall) IfNoneMatch(entityTag string) *ManagementSegmentsListCall {
  764. c.ifNoneMatch_ = entityTag
  765. return c
  766. }
  767. // Context sets the context to be used in this call's Do method. Any
  768. // pending HTTP request will be aborted if the provided context is
  769. // canceled.
  770. func (c *ManagementSegmentsListCall) Context(ctx context.Context) *ManagementSegmentsListCall {
  771. c.ctx_ = ctx
  772. return c
  773. }
  774. // Header returns an http.Header that can be modified by the caller to
  775. // add HTTP headers to the request.
  776. func (c *ManagementSegmentsListCall) Header() http.Header {
  777. if c.header_ == nil {
  778. c.header_ = make(http.Header)
  779. }
  780. return c.header_
  781. }
  782. func (c *ManagementSegmentsListCall) doRequest(alt string) (*http.Response, error) {
  783. reqHeaders := make(http.Header)
  784. for k, v := range c.header_ {
  785. reqHeaders[k] = v
  786. }
  787. reqHeaders.Set("User-Agent", c.s.userAgent())
  788. if c.ifNoneMatch_ != "" {
  789. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  790. }
  791. var body io.Reader = nil
  792. c.urlParams_.Set("alt", alt)
  793. urls := googleapi.ResolveRelative(c.s.BasePath, "management/segments")
  794. urls += "?" + c.urlParams_.Encode()
  795. req, _ := http.NewRequest("GET", urls, body)
  796. req.Header = reqHeaders
  797. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  798. }
  799. // Do executes the "analytics.management.segments.list" call.
  800. func (c *ManagementSegmentsListCall) Do(opts ...googleapi.CallOption) error {
  801. gensupport.SetOptions(c.urlParams_, opts...)
  802. res, err := c.doRequest("json")
  803. if err != nil {
  804. return err
  805. }
  806. defer googleapi.CloseBody(res)
  807. if err := googleapi.CheckResponse(res); err != nil {
  808. return err
  809. }
  810. return nil
  811. // {
  812. // "description": "Lists advanced segments to which the user has access.",
  813. // "httpMethod": "GET",
  814. // "id": "analytics.management.segments.list",
  815. // "parameters": {
  816. // "max-results": {
  817. // "description": "The maximum number of advanced segments to include in this response.",
  818. // "format": "int32",
  819. // "location": "query",
  820. // "type": "integer"
  821. // },
  822. // "start-index": {
  823. // "description": "An index of the first advanced segment to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  824. // "format": "int32",
  825. // "location": "query",
  826. // "minimum": "1",
  827. // "type": "integer"
  828. // }
  829. // },
  830. // "path": "management/segments",
  831. // "scopes": [
  832. // "https://www.googleapis.com/auth/analytics",
  833. // "https://www.googleapis.com/auth/analytics.readonly"
  834. // ]
  835. // }
  836. }
  837. // method id "analytics.management.webproperties.list":
  838. type ManagementWebpropertiesListCall struct {
  839. s *Service
  840. accountId string
  841. urlParams_ gensupport.URLParams
  842. ifNoneMatch_ string
  843. ctx_ context.Context
  844. header_ http.Header
  845. }
  846. // List: Lists web properties to which the user has access.
  847. func (r *ManagementWebpropertiesService) List(accountId string) *ManagementWebpropertiesListCall {
  848. c := &ManagementWebpropertiesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  849. c.accountId = accountId
  850. return c
  851. }
  852. // MaxResults sets the optional parameter "max-results": The maximum
  853. // number of web properties to include in this response.
  854. func (c *ManagementWebpropertiesListCall) MaxResults(maxResults int64) *ManagementWebpropertiesListCall {
  855. c.urlParams_.Set("max-results", fmt.Sprint(maxResults))
  856. return c
  857. }
  858. // StartIndex sets the optional parameter "start-index": An index of the
  859. // first entity to retrieve. Use this parameter as a pagination
  860. // mechanism along with the max-results parameter.
  861. func (c *ManagementWebpropertiesListCall) StartIndex(startIndex int64) *ManagementWebpropertiesListCall {
  862. c.urlParams_.Set("start-index", fmt.Sprint(startIndex))
  863. return c
  864. }
  865. // Fields allows partial responses to be retrieved. See
  866. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  867. // for more information.
  868. func (c *ManagementWebpropertiesListCall) Fields(s ...googleapi.Field) *ManagementWebpropertiesListCall {
  869. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  870. return c
  871. }
  872. // IfNoneMatch sets the optional parameter which makes the operation
  873. // fail if the object's ETag matches the given value. This is useful for
  874. // getting updates only after the object has changed since the last
  875. // request. Use googleapi.IsNotModified to check whether the response
  876. // error from Do is the result of In-None-Match.
  877. func (c *ManagementWebpropertiesListCall) IfNoneMatch(entityTag string) *ManagementWebpropertiesListCall {
  878. c.ifNoneMatch_ = entityTag
  879. return c
  880. }
  881. // Context sets the context to be used in this call's Do method. Any
  882. // pending HTTP request will be aborted if the provided context is
  883. // canceled.
  884. func (c *ManagementWebpropertiesListCall) Context(ctx context.Context) *ManagementWebpropertiesListCall {
  885. c.ctx_ = ctx
  886. return c
  887. }
  888. // Header returns an http.Header that can be modified by the caller to
  889. // add HTTP headers to the request.
  890. func (c *ManagementWebpropertiesListCall) Header() http.Header {
  891. if c.header_ == nil {
  892. c.header_ = make(http.Header)
  893. }
  894. return c.header_
  895. }
  896. func (c *ManagementWebpropertiesListCall) doRequest(alt string) (*http.Response, error) {
  897. reqHeaders := make(http.Header)
  898. for k, v := range c.header_ {
  899. reqHeaders[k] = v
  900. }
  901. reqHeaders.Set("User-Agent", c.s.userAgent())
  902. if c.ifNoneMatch_ != "" {
  903. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  904. }
  905. var body io.Reader = nil
  906. c.urlParams_.Set("alt", alt)
  907. urls := googleapi.ResolveRelative(c.s.BasePath, "management/accounts/{accountId}/webproperties")
  908. urls += "?" + c.urlParams_.Encode()
  909. req, _ := http.NewRequest("GET", urls, body)
  910. req.Header = reqHeaders
  911. googleapi.Expand(req.URL, map[string]string{
  912. "accountId": c.accountId,
  913. })
  914. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  915. }
  916. // Do executes the "analytics.management.webproperties.list" call.
  917. func (c *ManagementWebpropertiesListCall) Do(opts ...googleapi.CallOption) error {
  918. gensupport.SetOptions(c.urlParams_, opts...)
  919. res, err := c.doRequest("json")
  920. if err != nil {
  921. return err
  922. }
  923. defer googleapi.CloseBody(res)
  924. if err := googleapi.CheckResponse(res); err != nil {
  925. return err
  926. }
  927. return nil
  928. // {
  929. // "description": "Lists web properties to which the user has access.",
  930. // "httpMethod": "GET",
  931. // "id": "analytics.management.webproperties.list",
  932. // "parameterOrder": [
  933. // "accountId"
  934. // ],
  935. // "parameters": {
  936. // "accountId": {
  937. // "description": "Account ID to retrieve web properties for. Can either be a specific account ID or '~all', which refers to all the accounts that user has access to.",
  938. // "location": "path",
  939. // "required": true,
  940. // "type": "string"
  941. // },
  942. // "max-results": {
  943. // "description": "The maximum number of web properties to include in this response.",
  944. // "format": "int32",
  945. // "location": "query",
  946. // "type": "integer"
  947. // },
  948. // "start-index": {
  949. // "description": "An index of the first entity to retrieve. Use this parameter as a pagination mechanism along with the max-results parameter.",
  950. // "format": "int32",
  951. // "location": "query",
  952. // "minimum": "1",
  953. // "type": "integer"
  954. // }
  955. // },
  956. // "path": "management/accounts/{accountId}/webproperties",
  957. // "scopes": [
  958. // "https://www.googleapis.com/auth/analytics",
  959. // "https://www.googleapis.com/auth/analytics.readonly"
  960. // ]
  961. // }
  962. }