25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

1165 satır
38 KiB

  1. // Package admin provides access to the Admin Data Transfer API.
  2. //
  3. // See https://developers.google.com/admin-sdk/data-transfer/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/admin/datatransfer/v1"
  8. // ...
  9. // adminService, err := admin.New(oauthHttpClient)
  10. package admin // import "google.golang.org/api/admin/datatransfer/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:datatransfer_v1"
  41. const apiName = "admin"
  42. const apiVersion = "datatransfer_v1"
  43. const basePath = "https://www.googleapis.com/admin/datatransfer/v1/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage data transfers between users in your organization
  47. AdminDatatransferScope = "https://www.googleapis.com/auth/admin.datatransfer"
  48. // View data transfers between users in your organization
  49. AdminDatatransferReadonlyScope = "https://www.googleapis.com/auth/admin.datatransfer.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.Applications = NewApplicationsService(s)
  57. s.Transfers = NewTransfersService(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. Applications *ApplicationsService
  65. Transfers *TransfersService
  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 NewApplicationsService(s *Service) *ApplicationsService {
  74. rs := &ApplicationsService{s: s}
  75. return rs
  76. }
  77. type ApplicationsService struct {
  78. s *Service
  79. }
  80. func NewTransfersService(s *Service) *TransfersService {
  81. rs := &TransfersService{s: s}
  82. return rs
  83. }
  84. type TransfersService struct {
  85. s *Service
  86. }
  87. // Application: The JSON template for an Application resource.
  88. type Application struct {
  89. // Etag: Etag of the resource.
  90. Etag string `json:"etag,omitempty"`
  91. // Id: The application's ID.
  92. Id int64 `json:"id,omitempty,string"`
  93. // Kind: Identifies the resource as a DataTransfer Application Resource.
  94. Kind string `json:"kind,omitempty"`
  95. // Name: The application's name.
  96. Name string `json:"name,omitempty"`
  97. // TransferParams: The list of all possible transfer parameters for this
  98. // application. These parameters can be used to select the data of the
  99. // user in this application to be transfered.
  100. TransferParams []*ApplicationTransferParam `json:"transferParams,omitempty"`
  101. // ServerResponse contains the HTTP response code and headers from the
  102. // server.
  103. googleapi.ServerResponse `json:"-"`
  104. // ForceSendFields is a list of field names (e.g. "Etag") to
  105. // unconditionally include in API requests. By default, fields with
  106. // empty values are omitted from API requests. However, any non-pointer,
  107. // non-interface field appearing in ForceSendFields will be sent to the
  108. // server regardless of whether the field is empty or not. This may be
  109. // used to include empty fields in Patch requests.
  110. ForceSendFields []string `json:"-"`
  111. // NullFields is a list of field names (e.g. "Etag") to include in API
  112. // requests with the JSON null value. By default, fields with empty
  113. // values are omitted from API requests. However, any field with an
  114. // empty value appearing in NullFields will be sent to the server as
  115. // null. It is an error if a field in this list has a non-empty value.
  116. // This may be used to include null fields in Patch requests.
  117. NullFields []string `json:"-"`
  118. }
  119. func (s *Application) MarshalJSON() ([]byte, error) {
  120. type NoMethod Application
  121. raw := NoMethod(*s)
  122. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  123. }
  124. // ApplicationDataTransfer: Template to map fields of
  125. // ApplicationDataTransfer resource.
  126. type ApplicationDataTransfer struct {
  127. // ApplicationId: The application's ID.
  128. ApplicationId int64 `json:"applicationId,omitempty,string"`
  129. // ApplicationTransferParams: The transfer parameters for the
  130. // application. These parameters are used to select the data which will
  131. // get transfered in context of this application.
  132. ApplicationTransferParams []*ApplicationTransferParam `json:"applicationTransferParams,omitempty"`
  133. // ApplicationTransferStatus: Current status of transfer for this
  134. // application. (Read-only)
  135. ApplicationTransferStatus string `json:"applicationTransferStatus,omitempty"`
  136. // ForceSendFields is a list of field names (e.g. "ApplicationId") to
  137. // unconditionally include in API requests. By default, fields with
  138. // empty values are omitted from API requests. However, any non-pointer,
  139. // non-interface field appearing in ForceSendFields will be sent to the
  140. // server regardless of whether the field is empty or not. This may be
  141. // used to include empty fields in Patch requests.
  142. ForceSendFields []string `json:"-"`
  143. // NullFields is a list of field names (e.g. "ApplicationId") to include
  144. // in API requests with the JSON null value. By default, fields with
  145. // empty values are omitted from API requests. However, any field with
  146. // an empty value appearing in NullFields will be sent to the server as
  147. // null. It is an error if a field in this list has a non-empty value.
  148. // This may be used to include null fields in Patch requests.
  149. NullFields []string `json:"-"`
  150. }
  151. func (s *ApplicationDataTransfer) MarshalJSON() ([]byte, error) {
  152. type NoMethod ApplicationDataTransfer
  153. raw := NoMethod(*s)
  154. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  155. }
  156. // ApplicationTransferParam: Template for application transfer
  157. // parameters.
  158. type ApplicationTransferParam struct {
  159. // Key: The type of the transfer parameter. eg: 'PRIVACY_LEVEL'
  160. Key string `json:"key,omitempty"`
  161. // Value: The value of the coressponding transfer parameter. eg:
  162. // 'PRIVATE' or 'SHARED'
  163. Value []string `json:"value,omitempty"`
  164. // ForceSendFields is a list of field names (e.g. "Key") to
  165. // unconditionally include in API requests. By default, fields with
  166. // empty values are omitted from API requests. However, any non-pointer,
  167. // non-interface field appearing in ForceSendFields will be sent to the
  168. // server regardless of whether the field is empty or not. This may be
  169. // used to include empty fields in Patch requests.
  170. ForceSendFields []string `json:"-"`
  171. // NullFields is a list of field names (e.g. "Key") to include in API
  172. // requests with the JSON null value. By default, fields with empty
  173. // values are omitted from API requests. However, any field with an
  174. // empty value appearing in NullFields will be sent to the server as
  175. // null. It is an error if a field in this list has a non-empty value.
  176. // This may be used to include null fields in Patch requests.
  177. NullFields []string `json:"-"`
  178. }
  179. func (s *ApplicationTransferParam) MarshalJSON() ([]byte, error) {
  180. type NoMethod ApplicationTransferParam
  181. raw := NoMethod(*s)
  182. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  183. }
  184. // ApplicationsListResponse: Template for a collection of Applications.
  185. type ApplicationsListResponse struct {
  186. // Applications: List of applications that support data transfer and are
  187. // also installed for the customer.
  188. Applications []*Application `json:"applications,omitempty"`
  189. // Etag: ETag of the resource.
  190. Etag string `json:"etag,omitempty"`
  191. // Kind: Identifies the resource as a collection of Applications.
  192. Kind string `json:"kind,omitempty"`
  193. // NextPageToken: Continuation token which will be used to specify next
  194. // page in list API.
  195. NextPageToken string `json:"nextPageToken,omitempty"`
  196. // ServerResponse contains the HTTP response code and headers from the
  197. // server.
  198. googleapi.ServerResponse `json:"-"`
  199. // ForceSendFields is a list of field names (e.g. "Applications") to
  200. // unconditionally include in API requests. By default, fields with
  201. // empty values are omitted from API requests. However, any non-pointer,
  202. // non-interface field appearing in ForceSendFields will be sent to the
  203. // server regardless of whether the field is empty or not. This may be
  204. // used to include empty fields in Patch requests.
  205. ForceSendFields []string `json:"-"`
  206. // NullFields is a list of field names (e.g. "Applications") to include
  207. // in API requests with the JSON null value. By default, fields with
  208. // empty values are omitted from API requests. However, any field with
  209. // an empty value appearing in NullFields will be sent to the server as
  210. // null. It is an error if a field in this list has a non-empty value.
  211. // This may be used to include null fields in Patch requests.
  212. NullFields []string `json:"-"`
  213. }
  214. func (s *ApplicationsListResponse) MarshalJSON() ([]byte, error) {
  215. type NoMethod ApplicationsListResponse
  216. raw := NoMethod(*s)
  217. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  218. }
  219. // DataTransfer: The JSON template for a DataTransfer resource.
  220. type DataTransfer struct {
  221. // ApplicationDataTransfers: List of per application data transfer
  222. // resources. It contains data transfer details of the applications
  223. // associated with this transfer resource. Note that this list is also
  224. // used to specify the applications for which data transfer has to be
  225. // done at the time of the transfer resource creation.
  226. ApplicationDataTransfers []*ApplicationDataTransfer `json:"applicationDataTransfers,omitempty"`
  227. // Etag: ETag of the resource.
  228. Etag string `json:"etag,omitempty"`
  229. // Id: The transfer's ID (Read-only).
  230. Id string `json:"id,omitempty"`
  231. // Kind: Identifies the resource as a DataTransfer request.
  232. Kind string `json:"kind,omitempty"`
  233. // NewOwnerUserId: ID of the user to whom the data is being transfered.
  234. NewOwnerUserId string `json:"newOwnerUserId,omitempty"`
  235. // OldOwnerUserId: ID of the user whose data is being transfered.
  236. OldOwnerUserId string `json:"oldOwnerUserId,omitempty"`
  237. // OverallTransferStatusCode: Overall transfer status (Read-only).
  238. OverallTransferStatusCode string `json:"overallTransferStatusCode,omitempty"`
  239. // RequestTime: The time at which the data transfer was requested
  240. // (Read-only).
  241. RequestTime string `json:"requestTime,omitempty"`
  242. // ServerResponse contains the HTTP response code and headers from the
  243. // server.
  244. googleapi.ServerResponse `json:"-"`
  245. // ForceSendFields is a list of field names (e.g.
  246. // "ApplicationDataTransfers") to unconditionally include in API
  247. // requests. By default, fields with empty values are omitted from API
  248. // requests. However, any non-pointer, non-interface field appearing in
  249. // ForceSendFields will be sent to the server regardless of whether the
  250. // field is empty or not. This may be used to include empty fields in
  251. // Patch requests.
  252. ForceSendFields []string `json:"-"`
  253. // NullFields is a list of field names (e.g. "ApplicationDataTransfers")
  254. // to include in API requests with the JSON null value. By default,
  255. // fields with empty values are omitted from API requests. However, any
  256. // field with an empty value appearing in NullFields will be sent to the
  257. // server as null. It is an error if a field in this list has a
  258. // non-empty value. This may be used to include null fields in Patch
  259. // requests.
  260. NullFields []string `json:"-"`
  261. }
  262. func (s *DataTransfer) MarshalJSON() ([]byte, error) {
  263. type NoMethod DataTransfer
  264. raw := NoMethod(*s)
  265. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  266. }
  267. // DataTransfersListResponse: Template for a collection of DataTransfer
  268. // resources.
  269. type DataTransfersListResponse struct {
  270. // DataTransfers: List of data transfer requests.
  271. DataTransfers []*DataTransfer `json:"dataTransfers,omitempty"`
  272. // Etag: ETag of the resource.
  273. Etag string `json:"etag,omitempty"`
  274. // Kind: Identifies the resource as a collection of data transfer
  275. // requests.
  276. Kind string `json:"kind,omitempty"`
  277. // NextPageToken: Continuation token which will be used to specify next
  278. // page in list API.
  279. NextPageToken string `json:"nextPageToken,omitempty"`
  280. // ServerResponse contains the HTTP response code and headers from the
  281. // server.
  282. googleapi.ServerResponse `json:"-"`
  283. // ForceSendFields is a list of field names (e.g. "DataTransfers") to
  284. // unconditionally include in API requests. By default, fields with
  285. // empty values are omitted from API requests. However, any non-pointer,
  286. // non-interface field appearing in ForceSendFields will be sent to the
  287. // server regardless of whether the field is empty or not. This may be
  288. // used to include empty fields in Patch requests.
  289. ForceSendFields []string `json:"-"`
  290. // NullFields is a list of field names (e.g. "DataTransfers") to include
  291. // in API requests with the JSON null value. By default, fields with
  292. // empty values are omitted from API requests. However, any field with
  293. // an empty value appearing in NullFields will be sent to the server as
  294. // null. It is an error if a field in this list has a non-empty value.
  295. // This may be used to include null fields in Patch requests.
  296. NullFields []string `json:"-"`
  297. }
  298. func (s *DataTransfersListResponse) MarshalJSON() ([]byte, error) {
  299. type NoMethod DataTransfersListResponse
  300. raw := NoMethod(*s)
  301. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  302. }
  303. // method id "datatransfer.applications.get":
  304. type ApplicationsGetCall struct {
  305. s *Service
  306. applicationId int64
  307. urlParams_ gensupport.URLParams
  308. ifNoneMatch_ string
  309. ctx_ context.Context
  310. header_ http.Header
  311. }
  312. // Get: Retrieves information about an application for the given
  313. // application ID.
  314. func (r *ApplicationsService) Get(applicationId int64) *ApplicationsGetCall {
  315. c := &ApplicationsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  316. c.applicationId = applicationId
  317. return c
  318. }
  319. // Fields allows partial responses to be retrieved. See
  320. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  321. // for more information.
  322. func (c *ApplicationsGetCall) Fields(s ...googleapi.Field) *ApplicationsGetCall {
  323. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  324. return c
  325. }
  326. // IfNoneMatch sets the optional parameter which makes the operation
  327. // fail if the object's ETag matches the given value. This is useful for
  328. // getting updates only after the object has changed since the last
  329. // request. Use googleapi.IsNotModified to check whether the response
  330. // error from Do is the result of In-None-Match.
  331. func (c *ApplicationsGetCall) IfNoneMatch(entityTag string) *ApplicationsGetCall {
  332. c.ifNoneMatch_ = entityTag
  333. return c
  334. }
  335. // Context sets the context to be used in this call's Do method. Any
  336. // pending HTTP request will be aborted if the provided context is
  337. // canceled.
  338. func (c *ApplicationsGetCall) Context(ctx context.Context) *ApplicationsGetCall {
  339. c.ctx_ = ctx
  340. return c
  341. }
  342. // Header returns an http.Header that can be modified by the caller to
  343. // add HTTP headers to the request.
  344. func (c *ApplicationsGetCall) Header() http.Header {
  345. if c.header_ == nil {
  346. c.header_ = make(http.Header)
  347. }
  348. return c.header_
  349. }
  350. func (c *ApplicationsGetCall) doRequest(alt string) (*http.Response, error) {
  351. reqHeaders := make(http.Header)
  352. for k, v := range c.header_ {
  353. reqHeaders[k] = v
  354. }
  355. reqHeaders.Set("User-Agent", c.s.userAgent())
  356. if c.ifNoneMatch_ != "" {
  357. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  358. }
  359. var body io.Reader = nil
  360. c.urlParams_.Set("alt", alt)
  361. urls := googleapi.ResolveRelative(c.s.BasePath, "applications/{applicationId}")
  362. urls += "?" + c.urlParams_.Encode()
  363. req, _ := http.NewRequest("GET", urls, body)
  364. req.Header = reqHeaders
  365. googleapi.Expand(req.URL, map[string]string{
  366. "applicationId": strconv.FormatInt(c.applicationId, 10),
  367. })
  368. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  369. }
  370. // Do executes the "datatransfer.applications.get" call.
  371. // Exactly one of *Application or error will be non-nil. Any non-2xx
  372. // status code is an error. Response headers are in either
  373. // *Application.ServerResponse.Header or (if a response was returned at
  374. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  375. // to check whether the returned error was because
  376. // http.StatusNotModified was returned.
  377. func (c *ApplicationsGetCall) Do(opts ...googleapi.CallOption) (*Application, error) {
  378. gensupport.SetOptions(c.urlParams_, opts...)
  379. res, err := c.doRequest("json")
  380. if res != nil && res.StatusCode == http.StatusNotModified {
  381. if res.Body != nil {
  382. res.Body.Close()
  383. }
  384. return nil, &googleapi.Error{
  385. Code: res.StatusCode,
  386. Header: res.Header,
  387. }
  388. }
  389. if err != nil {
  390. return nil, err
  391. }
  392. defer googleapi.CloseBody(res)
  393. if err := googleapi.CheckResponse(res); err != nil {
  394. return nil, err
  395. }
  396. ret := &Application{
  397. ServerResponse: googleapi.ServerResponse{
  398. Header: res.Header,
  399. HTTPStatusCode: res.StatusCode,
  400. },
  401. }
  402. target := &ret
  403. if err := gensupport.DecodeResponse(target, res); err != nil {
  404. return nil, err
  405. }
  406. return ret, nil
  407. // {
  408. // "description": "Retrieves information about an application for the given application ID.",
  409. // "httpMethod": "GET",
  410. // "id": "datatransfer.applications.get",
  411. // "parameterOrder": [
  412. // "applicationId"
  413. // ],
  414. // "parameters": {
  415. // "applicationId": {
  416. // "description": "ID of the application resource to be retrieved.",
  417. // "format": "int64",
  418. // "location": "path",
  419. // "required": true,
  420. // "type": "string"
  421. // }
  422. // },
  423. // "path": "applications/{applicationId}",
  424. // "response": {
  425. // "$ref": "Application"
  426. // },
  427. // "scopes": [
  428. // "https://www.googleapis.com/auth/admin.datatransfer",
  429. // "https://www.googleapis.com/auth/admin.datatransfer.readonly"
  430. // ]
  431. // }
  432. }
  433. // method id "datatransfer.applications.list":
  434. type ApplicationsListCall struct {
  435. s *Service
  436. urlParams_ gensupport.URLParams
  437. ifNoneMatch_ string
  438. ctx_ context.Context
  439. header_ http.Header
  440. }
  441. // List: Lists the applications available for data transfer for a
  442. // customer.
  443. func (r *ApplicationsService) List() *ApplicationsListCall {
  444. c := &ApplicationsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  445. return c
  446. }
  447. // CustomerId sets the optional parameter "customerId": Immutable ID of
  448. // the Google Apps account.
  449. func (c *ApplicationsListCall) CustomerId(customerId string) *ApplicationsListCall {
  450. c.urlParams_.Set("customerId", customerId)
  451. return c
  452. }
  453. // MaxResults sets the optional parameter "maxResults": Maximum number
  454. // of results to return. Default is 100.
  455. func (c *ApplicationsListCall) MaxResults(maxResults int64) *ApplicationsListCall {
  456. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  457. return c
  458. }
  459. // PageToken sets the optional parameter "pageToken": Token to specify
  460. // next page in the list.
  461. func (c *ApplicationsListCall) PageToken(pageToken string) *ApplicationsListCall {
  462. c.urlParams_.Set("pageToken", pageToken)
  463. return c
  464. }
  465. // Fields allows partial responses to be retrieved. See
  466. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  467. // for more information.
  468. func (c *ApplicationsListCall) Fields(s ...googleapi.Field) *ApplicationsListCall {
  469. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  470. return c
  471. }
  472. // IfNoneMatch sets the optional parameter which makes the operation
  473. // fail if the object's ETag matches the given value. This is useful for
  474. // getting updates only after the object has changed since the last
  475. // request. Use googleapi.IsNotModified to check whether the response
  476. // error from Do is the result of In-None-Match.
  477. func (c *ApplicationsListCall) IfNoneMatch(entityTag string) *ApplicationsListCall {
  478. c.ifNoneMatch_ = entityTag
  479. return c
  480. }
  481. // Context sets the context to be used in this call's Do method. Any
  482. // pending HTTP request will be aborted if the provided context is
  483. // canceled.
  484. func (c *ApplicationsListCall) Context(ctx context.Context) *ApplicationsListCall {
  485. c.ctx_ = ctx
  486. return c
  487. }
  488. // Header returns an http.Header that can be modified by the caller to
  489. // add HTTP headers to the request.
  490. func (c *ApplicationsListCall) Header() http.Header {
  491. if c.header_ == nil {
  492. c.header_ = make(http.Header)
  493. }
  494. return c.header_
  495. }
  496. func (c *ApplicationsListCall) doRequest(alt string) (*http.Response, error) {
  497. reqHeaders := make(http.Header)
  498. for k, v := range c.header_ {
  499. reqHeaders[k] = v
  500. }
  501. reqHeaders.Set("User-Agent", c.s.userAgent())
  502. if c.ifNoneMatch_ != "" {
  503. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  504. }
  505. var body io.Reader = nil
  506. c.urlParams_.Set("alt", alt)
  507. urls := googleapi.ResolveRelative(c.s.BasePath, "applications")
  508. urls += "?" + c.urlParams_.Encode()
  509. req, _ := http.NewRequest("GET", urls, body)
  510. req.Header = reqHeaders
  511. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  512. }
  513. // Do executes the "datatransfer.applications.list" call.
  514. // Exactly one of *ApplicationsListResponse or error will be non-nil.
  515. // Any non-2xx status code is an error. Response headers are in either
  516. // *ApplicationsListResponse.ServerResponse.Header or (if a response was
  517. // returned at all) in error.(*googleapi.Error).Header. Use
  518. // googleapi.IsNotModified to check whether the returned error was
  519. // because http.StatusNotModified was returned.
  520. func (c *ApplicationsListCall) Do(opts ...googleapi.CallOption) (*ApplicationsListResponse, error) {
  521. gensupport.SetOptions(c.urlParams_, opts...)
  522. res, err := c.doRequest("json")
  523. if res != nil && res.StatusCode == http.StatusNotModified {
  524. if res.Body != nil {
  525. res.Body.Close()
  526. }
  527. return nil, &googleapi.Error{
  528. Code: res.StatusCode,
  529. Header: res.Header,
  530. }
  531. }
  532. if err != nil {
  533. return nil, err
  534. }
  535. defer googleapi.CloseBody(res)
  536. if err := googleapi.CheckResponse(res); err != nil {
  537. return nil, err
  538. }
  539. ret := &ApplicationsListResponse{
  540. ServerResponse: googleapi.ServerResponse{
  541. Header: res.Header,
  542. HTTPStatusCode: res.StatusCode,
  543. },
  544. }
  545. target := &ret
  546. if err := gensupport.DecodeResponse(target, res); err != nil {
  547. return nil, err
  548. }
  549. return ret, nil
  550. // {
  551. // "description": "Lists the applications available for data transfer for a customer.",
  552. // "httpMethod": "GET",
  553. // "id": "datatransfer.applications.list",
  554. // "parameters": {
  555. // "customerId": {
  556. // "description": "Immutable ID of the Google Apps account.",
  557. // "location": "query",
  558. // "type": "string"
  559. // },
  560. // "maxResults": {
  561. // "description": "Maximum number of results to return. Default is 100.",
  562. // "format": "int32",
  563. // "location": "query",
  564. // "maximum": "500",
  565. // "minimum": "1",
  566. // "type": "integer"
  567. // },
  568. // "pageToken": {
  569. // "description": "Token to specify next page in the list.",
  570. // "location": "query",
  571. // "type": "string"
  572. // }
  573. // },
  574. // "path": "applications",
  575. // "response": {
  576. // "$ref": "ApplicationsListResponse"
  577. // },
  578. // "scopes": [
  579. // "https://www.googleapis.com/auth/admin.datatransfer",
  580. // "https://www.googleapis.com/auth/admin.datatransfer.readonly"
  581. // ]
  582. // }
  583. }
  584. // Pages invokes f for each page of results.
  585. // A non-nil error returned from f will halt the iteration.
  586. // The provided context supersedes any context provided to the Context method.
  587. func (c *ApplicationsListCall) Pages(ctx context.Context, f func(*ApplicationsListResponse) error) error {
  588. c.ctx_ = ctx
  589. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  590. for {
  591. x, err := c.Do()
  592. if err != nil {
  593. return err
  594. }
  595. if err := f(x); err != nil {
  596. return err
  597. }
  598. if x.NextPageToken == "" {
  599. return nil
  600. }
  601. c.PageToken(x.NextPageToken)
  602. }
  603. }
  604. // method id "datatransfer.transfers.get":
  605. type TransfersGetCall struct {
  606. s *Service
  607. dataTransferId string
  608. urlParams_ gensupport.URLParams
  609. ifNoneMatch_ string
  610. ctx_ context.Context
  611. header_ http.Header
  612. }
  613. // Get: Retrieves a data transfer request by its resource ID.
  614. func (r *TransfersService) Get(dataTransferId string) *TransfersGetCall {
  615. c := &TransfersGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  616. c.dataTransferId = dataTransferId
  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 *TransfersGetCall) Fields(s ...googleapi.Field) *TransfersGetCall {
  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 *TransfersGetCall) IfNoneMatch(entityTag string) *TransfersGetCall {
  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 *TransfersGetCall) Context(ctx context.Context) *TransfersGetCall {
  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 *TransfersGetCall) Header() http.Header {
  645. if c.header_ == nil {
  646. c.header_ = make(http.Header)
  647. }
  648. return c.header_
  649. }
  650. func (c *TransfersGetCall) 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, "transfers/{dataTransferId}")
  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. "dataTransferId": c.dataTransferId,
  667. })
  668. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  669. }
  670. // Do executes the "datatransfer.transfers.get" call.
  671. // Exactly one of *DataTransfer or error will be non-nil. Any non-2xx
  672. // status code is an error. Response headers are in either
  673. // *DataTransfer.ServerResponse.Header or (if a response was returned at
  674. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  675. // to check whether the returned error was because
  676. // http.StatusNotModified was returned.
  677. func (c *TransfersGetCall) Do(opts ...googleapi.CallOption) (*DataTransfer, error) {
  678. gensupport.SetOptions(c.urlParams_, opts...)
  679. res, err := c.doRequest("json")
  680. if res != nil && res.StatusCode == http.StatusNotModified {
  681. if res.Body != nil {
  682. res.Body.Close()
  683. }
  684. return nil, &googleapi.Error{
  685. Code: res.StatusCode,
  686. Header: res.Header,
  687. }
  688. }
  689. if err != nil {
  690. return nil, err
  691. }
  692. defer googleapi.CloseBody(res)
  693. if err := googleapi.CheckResponse(res); err != nil {
  694. return nil, err
  695. }
  696. ret := &DataTransfer{
  697. ServerResponse: googleapi.ServerResponse{
  698. Header: res.Header,
  699. HTTPStatusCode: res.StatusCode,
  700. },
  701. }
  702. target := &ret
  703. if err := gensupport.DecodeResponse(target, res); err != nil {
  704. return nil, err
  705. }
  706. return ret, nil
  707. // {
  708. // "description": "Retrieves a data transfer request by its resource ID.",
  709. // "httpMethod": "GET",
  710. // "id": "datatransfer.transfers.get",
  711. // "parameterOrder": [
  712. // "dataTransferId"
  713. // ],
  714. // "parameters": {
  715. // "dataTransferId": {
  716. // "description": "ID of the resource to be retrieved. This is returned in the response from the insert method.",
  717. // "location": "path",
  718. // "required": true,
  719. // "type": "string"
  720. // }
  721. // },
  722. // "path": "transfers/{dataTransferId}",
  723. // "response": {
  724. // "$ref": "DataTransfer"
  725. // },
  726. // "scopes": [
  727. // "https://www.googleapis.com/auth/admin.datatransfer",
  728. // "https://www.googleapis.com/auth/admin.datatransfer.readonly"
  729. // ]
  730. // }
  731. }
  732. // method id "datatransfer.transfers.insert":
  733. type TransfersInsertCall struct {
  734. s *Service
  735. datatransfer *DataTransfer
  736. urlParams_ gensupport.URLParams
  737. ctx_ context.Context
  738. header_ http.Header
  739. }
  740. // Insert: Inserts a data transfer request.
  741. func (r *TransfersService) Insert(datatransfer *DataTransfer) *TransfersInsertCall {
  742. c := &TransfersInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  743. c.datatransfer = datatransfer
  744. return c
  745. }
  746. // Fields allows partial responses to be retrieved. See
  747. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  748. // for more information.
  749. func (c *TransfersInsertCall) Fields(s ...googleapi.Field) *TransfersInsertCall {
  750. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  751. return c
  752. }
  753. // Context sets the context to be used in this call's Do method. Any
  754. // pending HTTP request will be aborted if the provided context is
  755. // canceled.
  756. func (c *TransfersInsertCall) Context(ctx context.Context) *TransfersInsertCall {
  757. c.ctx_ = ctx
  758. return c
  759. }
  760. // Header returns an http.Header that can be modified by the caller to
  761. // add HTTP headers to the request.
  762. func (c *TransfersInsertCall) Header() http.Header {
  763. if c.header_ == nil {
  764. c.header_ = make(http.Header)
  765. }
  766. return c.header_
  767. }
  768. func (c *TransfersInsertCall) doRequest(alt string) (*http.Response, error) {
  769. reqHeaders := make(http.Header)
  770. for k, v := range c.header_ {
  771. reqHeaders[k] = v
  772. }
  773. reqHeaders.Set("User-Agent", c.s.userAgent())
  774. var body io.Reader = nil
  775. body, err := googleapi.WithoutDataWrapper.JSONReader(c.datatransfer)
  776. if err != nil {
  777. return nil, err
  778. }
  779. reqHeaders.Set("Content-Type", "application/json")
  780. c.urlParams_.Set("alt", alt)
  781. urls := googleapi.ResolveRelative(c.s.BasePath, "transfers")
  782. urls += "?" + c.urlParams_.Encode()
  783. req, _ := http.NewRequest("POST", urls, body)
  784. req.Header = reqHeaders
  785. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  786. }
  787. // Do executes the "datatransfer.transfers.insert" call.
  788. // Exactly one of *DataTransfer or error will be non-nil. Any non-2xx
  789. // status code is an error. Response headers are in either
  790. // *DataTransfer.ServerResponse.Header or (if a response was returned at
  791. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  792. // to check whether the returned error was because
  793. // http.StatusNotModified was returned.
  794. func (c *TransfersInsertCall) Do(opts ...googleapi.CallOption) (*DataTransfer, error) {
  795. gensupport.SetOptions(c.urlParams_, opts...)
  796. res, err := c.doRequest("json")
  797. if res != nil && res.StatusCode == http.StatusNotModified {
  798. if res.Body != nil {
  799. res.Body.Close()
  800. }
  801. return nil, &googleapi.Error{
  802. Code: res.StatusCode,
  803. Header: res.Header,
  804. }
  805. }
  806. if err != nil {
  807. return nil, err
  808. }
  809. defer googleapi.CloseBody(res)
  810. if err := googleapi.CheckResponse(res); err != nil {
  811. return nil, err
  812. }
  813. ret := &DataTransfer{
  814. ServerResponse: googleapi.ServerResponse{
  815. Header: res.Header,
  816. HTTPStatusCode: res.StatusCode,
  817. },
  818. }
  819. target := &ret
  820. if err := gensupport.DecodeResponse(target, res); err != nil {
  821. return nil, err
  822. }
  823. return ret, nil
  824. // {
  825. // "description": "Inserts a data transfer request.",
  826. // "httpMethod": "POST",
  827. // "id": "datatransfer.transfers.insert",
  828. // "path": "transfers",
  829. // "request": {
  830. // "$ref": "DataTransfer"
  831. // },
  832. // "response": {
  833. // "$ref": "DataTransfer"
  834. // },
  835. // "scopes": [
  836. // "https://www.googleapis.com/auth/admin.datatransfer"
  837. // ]
  838. // }
  839. }
  840. // method id "datatransfer.transfers.list":
  841. type TransfersListCall struct {
  842. s *Service
  843. urlParams_ gensupport.URLParams
  844. ifNoneMatch_ string
  845. ctx_ context.Context
  846. header_ http.Header
  847. }
  848. // List: Lists the transfers for a customer by source user, destination
  849. // user, or status.
  850. func (r *TransfersService) List() *TransfersListCall {
  851. c := &TransfersListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  852. return c
  853. }
  854. // CustomerId sets the optional parameter "customerId": Immutable ID of
  855. // the Google Apps account.
  856. func (c *TransfersListCall) CustomerId(customerId string) *TransfersListCall {
  857. c.urlParams_.Set("customerId", customerId)
  858. return c
  859. }
  860. // MaxResults sets the optional parameter "maxResults": Maximum number
  861. // of results to return. Default is 100.
  862. func (c *TransfersListCall) MaxResults(maxResults int64) *TransfersListCall {
  863. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  864. return c
  865. }
  866. // NewOwnerUserId sets the optional parameter "newOwnerUserId":
  867. // Destination user's profile ID.
  868. func (c *TransfersListCall) NewOwnerUserId(newOwnerUserId string) *TransfersListCall {
  869. c.urlParams_.Set("newOwnerUserId", newOwnerUserId)
  870. return c
  871. }
  872. // OldOwnerUserId sets the optional parameter "oldOwnerUserId": Source
  873. // user's profile ID.
  874. func (c *TransfersListCall) OldOwnerUserId(oldOwnerUserId string) *TransfersListCall {
  875. c.urlParams_.Set("oldOwnerUserId", oldOwnerUserId)
  876. return c
  877. }
  878. // PageToken sets the optional parameter "pageToken": Token to specify
  879. // the next page in the list.
  880. func (c *TransfersListCall) PageToken(pageToken string) *TransfersListCall {
  881. c.urlParams_.Set("pageToken", pageToken)
  882. return c
  883. }
  884. // Status sets the optional parameter "status": Status of the transfer.
  885. func (c *TransfersListCall) Status(status string) *TransfersListCall {
  886. c.urlParams_.Set("status", status)
  887. return c
  888. }
  889. // Fields allows partial responses to be retrieved. See
  890. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  891. // for more information.
  892. func (c *TransfersListCall) Fields(s ...googleapi.Field) *TransfersListCall {
  893. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  894. return c
  895. }
  896. // IfNoneMatch sets the optional parameter which makes the operation
  897. // fail if the object's ETag matches the given value. This is useful for
  898. // getting updates only after the object has changed since the last
  899. // request. Use googleapi.IsNotModified to check whether the response
  900. // error from Do is the result of In-None-Match.
  901. func (c *TransfersListCall) IfNoneMatch(entityTag string) *TransfersListCall {
  902. c.ifNoneMatch_ = entityTag
  903. return c
  904. }
  905. // Context sets the context to be used in this call's Do method. Any
  906. // pending HTTP request will be aborted if the provided context is
  907. // canceled.
  908. func (c *TransfersListCall) Context(ctx context.Context) *TransfersListCall {
  909. c.ctx_ = ctx
  910. return c
  911. }
  912. // Header returns an http.Header that can be modified by the caller to
  913. // add HTTP headers to the request.
  914. func (c *TransfersListCall) Header() http.Header {
  915. if c.header_ == nil {
  916. c.header_ = make(http.Header)
  917. }
  918. return c.header_
  919. }
  920. func (c *TransfersListCall) doRequest(alt string) (*http.Response, error) {
  921. reqHeaders := make(http.Header)
  922. for k, v := range c.header_ {
  923. reqHeaders[k] = v
  924. }
  925. reqHeaders.Set("User-Agent", c.s.userAgent())
  926. if c.ifNoneMatch_ != "" {
  927. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  928. }
  929. var body io.Reader = nil
  930. c.urlParams_.Set("alt", alt)
  931. urls := googleapi.ResolveRelative(c.s.BasePath, "transfers")
  932. urls += "?" + c.urlParams_.Encode()
  933. req, _ := http.NewRequest("GET", urls, body)
  934. req.Header = reqHeaders
  935. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  936. }
  937. // Do executes the "datatransfer.transfers.list" call.
  938. // Exactly one of *DataTransfersListResponse or error will be non-nil.
  939. // Any non-2xx status code is an error. Response headers are in either
  940. // *DataTransfersListResponse.ServerResponse.Header or (if a response
  941. // was returned at all) in error.(*googleapi.Error).Header. Use
  942. // googleapi.IsNotModified to check whether the returned error was
  943. // because http.StatusNotModified was returned.
  944. func (c *TransfersListCall) Do(opts ...googleapi.CallOption) (*DataTransfersListResponse, error) {
  945. gensupport.SetOptions(c.urlParams_, opts...)
  946. res, err := c.doRequest("json")
  947. if res != nil && res.StatusCode == http.StatusNotModified {
  948. if res.Body != nil {
  949. res.Body.Close()
  950. }
  951. return nil, &googleapi.Error{
  952. Code: res.StatusCode,
  953. Header: res.Header,
  954. }
  955. }
  956. if err != nil {
  957. return nil, err
  958. }
  959. defer googleapi.CloseBody(res)
  960. if err := googleapi.CheckResponse(res); err != nil {
  961. return nil, err
  962. }
  963. ret := &DataTransfersListResponse{
  964. ServerResponse: googleapi.ServerResponse{
  965. Header: res.Header,
  966. HTTPStatusCode: res.StatusCode,
  967. },
  968. }
  969. target := &ret
  970. if err := gensupport.DecodeResponse(target, res); err != nil {
  971. return nil, err
  972. }
  973. return ret, nil
  974. // {
  975. // "description": "Lists the transfers for a customer by source user, destination user, or status.",
  976. // "httpMethod": "GET",
  977. // "id": "datatransfer.transfers.list",
  978. // "parameters": {
  979. // "customerId": {
  980. // "description": "Immutable ID of the Google Apps account.",
  981. // "location": "query",
  982. // "type": "string"
  983. // },
  984. // "maxResults": {
  985. // "description": "Maximum number of results to return. Default is 100.",
  986. // "format": "int32",
  987. // "location": "query",
  988. // "maximum": "500",
  989. // "minimum": "1",
  990. // "type": "integer"
  991. // },
  992. // "newOwnerUserId": {
  993. // "description": "Destination user's profile ID.",
  994. // "location": "query",
  995. // "type": "string"
  996. // },
  997. // "oldOwnerUserId": {
  998. // "description": "Source user's profile ID.",
  999. // "location": "query",
  1000. // "type": "string"
  1001. // },
  1002. // "pageToken": {
  1003. // "description": "Token to specify the next page in the list.",
  1004. // "location": "query",
  1005. // "type": "string"
  1006. // },
  1007. // "status": {
  1008. // "description": "Status of the transfer.",
  1009. // "location": "query",
  1010. // "type": "string"
  1011. // }
  1012. // },
  1013. // "path": "transfers",
  1014. // "response": {
  1015. // "$ref": "DataTransfersListResponse"
  1016. // },
  1017. // "scopes": [
  1018. // "https://www.googleapis.com/auth/admin.datatransfer",
  1019. // "https://www.googleapis.com/auth/admin.datatransfer.readonly"
  1020. // ]
  1021. // }
  1022. }
  1023. // Pages invokes f for each page of results.
  1024. // A non-nil error returned from f will halt the iteration.
  1025. // The provided context supersedes any context provided to the Context method.
  1026. func (c *TransfersListCall) Pages(ctx context.Context, f func(*DataTransfersListResponse) error) error {
  1027. c.ctx_ = ctx
  1028. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1029. for {
  1030. x, err := c.Do()
  1031. if err != nil {
  1032. return err
  1033. }
  1034. if err := f(x); err != nil {
  1035. return err
  1036. }
  1037. if x.NextPageToken == "" {
  1038. return nil
  1039. }
  1040. c.PageToken(x.NextPageToken)
  1041. }
  1042. }