Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 

1421 рядки
44 KiB

  1. // Copyright 2019 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package licensing provides access to the Enterprise License Manager API.
  6. //
  7. // For product documentation, see: https://developers.google.com/google-apps/licensing/
  8. //
  9. // Creating a client
  10. //
  11. // Usage example:
  12. //
  13. // import "google.golang.org/api/licensing/v1"
  14. // ...
  15. // ctx := context.Background()
  16. // licensingService, err := licensing.NewService(ctx)
  17. //
  18. // In this example, Google Application Default Credentials are used for authentication.
  19. //
  20. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  21. //
  22. // Other authentication options
  23. //
  24. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  25. //
  26. // licensingService, err := licensing.NewService(ctx, option.WithAPIKey("AIza..."))
  27. //
  28. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  29. //
  30. // config := &oauth2.Config{...}
  31. // // ...
  32. // token, err := config.Exchange(ctx, ...)
  33. // licensingService, err := licensing.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  34. //
  35. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  36. package licensing // import "google.golang.org/api/licensing/v1"
  37. import (
  38. "bytes"
  39. "context"
  40. "encoding/json"
  41. "errors"
  42. "fmt"
  43. "io"
  44. "net/http"
  45. "net/url"
  46. "strconv"
  47. "strings"
  48. gensupport "google.golang.org/api/gensupport"
  49. googleapi "google.golang.org/api/googleapi"
  50. option "google.golang.org/api/option"
  51. htransport "google.golang.org/api/transport/http"
  52. )
  53. // Always reference these packages, just in case the auto-generated code
  54. // below doesn't.
  55. var _ = bytes.NewBuffer
  56. var _ = strconv.Itoa
  57. var _ = fmt.Sprintf
  58. var _ = json.NewDecoder
  59. var _ = io.Copy
  60. var _ = url.Parse
  61. var _ = gensupport.MarshalJSON
  62. var _ = googleapi.Version
  63. var _ = errors.New
  64. var _ = strings.Replace
  65. var _ = context.Canceled
  66. const apiId = "licensing:v1"
  67. const apiName = "licensing"
  68. const apiVersion = "v1"
  69. const basePath = "https://www.googleapis.com/apps/licensing/v1/product/"
  70. // OAuth2 scopes used by this API.
  71. const (
  72. // View and manage G Suite licenses for your domain
  73. AppsLicensingScope = "https://www.googleapis.com/auth/apps.licensing"
  74. )
  75. // NewService creates a new Service.
  76. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  77. scopesOption := option.WithScopes(
  78. "https://www.googleapis.com/auth/apps.licensing",
  79. )
  80. // NOTE: prepend, so we don't override user-specified scopes.
  81. opts = append([]option.ClientOption{scopesOption}, opts...)
  82. client, endpoint, err := htransport.NewClient(ctx, opts...)
  83. if err != nil {
  84. return nil, err
  85. }
  86. s, err := New(client)
  87. if err != nil {
  88. return nil, err
  89. }
  90. if endpoint != "" {
  91. s.BasePath = endpoint
  92. }
  93. return s, nil
  94. }
  95. // New creates a new Service. It uses the provided http.Client for requests.
  96. //
  97. // Deprecated: please use NewService instead.
  98. // To provide a custom HTTP client, use option.WithHTTPClient.
  99. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  100. func New(client *http.Client) (*Service, error) {
  101. if client == nil {
  102. return nil, errors.New("client is nil")
  103. }
  104. s := &Service{client: client, BasePath: basePath}
  105. s.LicenseAssignments = NewLicenseAssignmentsService(s)
  106. return s, nil
  107. }
  108. type Service struct {
  109. client *http.Client
  110. BasePath string // API endpoint base URL
  111. UserAgent string // optional additional User-Agent fragment
  112. LicenseAssignments *LicenseAssignmentsService
  113. }
  114. func (s *Service) userAgent() string {
  115. if s.UserAgent == "" {
  116. return googleapi.UserAgent
  117. }
  118. return googleapi.UserAgent + " " + s.UserAgent
  119. }
  120. func NewLicenseAssignmentsService(s *Service) *LicenseAssignmentsService {
  121. rs := &LicenseAssignmentsService{s: s}
  122. return rs
  123. }
  124. type LicenseAssignmentsService struct {
  125. s *Service
  126. }
  127. // LicenseAssignment: Template for LiscenseAssignment Resource
  128. type LicenseAssignment struct {
  129. // Etags: ETag of the resource.
  130. Etags string `json:"etags,omitempty"`
  131. // Kind: Identifies the resource as a LicenseAssignment.
  132. Kind string `json:"kind,omitempty"`
  133. // ProductId: Id of the product.
  134. ProductId string `json:"productId,omitempty"`
  135. // ProductName: Display Name of the product.
  136. ProductName string `json:"productName,omitempty"`
  137. // SelfLink: Link to this page.
  138. SelfLink string `json:"selfLink,omitempty"`
  139. // SkuId: Id of the sku of the product.
  140. SkuId string `json:"skuId,omitempty"`
  141. // SkuName: Display Name of the sku of the product.
  142. SkuName string `json:"skuName,omitempty"`
  143. // UserId: Email id of the user.
  144. UserId string `json:"userId,omitempty"`
  145. // ServerResponse contains the HTTP response code and headers from the
  146. // server.
  147. googleapi.ServerResponse `json:"-"`
  148. // ForceSendFields is a list of field names (e.g. "Etags") to
  149. // unconditionally include in API requests. By default, fields with
  150. // empty values are omitted from API requests. However, any non-pointer,
  151. // non-interface field appearing in ForceSendFields will be sent to the
  152. // server regardless of whether the field is empty or not. This may be
  153. // used to include empty fields in Patch requests.
  154. ForceSendFields []string `json:"-"`
  155. // NullFields is a list of field names (e.g. "Etags") to include in API
  156. // requests with the JSON null value. By default, fields with empty
  157. // values are omitted from API requests. However, any field with an
  158. // empty value appearing in NullFields will be sent to the server as
  159. // null. It is an error if a field in this list has a non-empty value.
  160. // This may be used to include null fields in Patch requests.
  161. NullFields []string `json:"-"`
  162. }
  163. func (s *LicenseAssignment) MarshalJSON() ([]byte, error) {
  164. type NoMethod LicenseAssignment
  165. raw := NoMethod(*s)
  166. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  167. }
  168. // LicenseAssignmentInsert: Template for LicenseAssignment Insert
  169. // request
  170. type LicenseAssignmentInsert struct {
  171. // UserId: Email id of the user
  172. UserId string `json:"userId,omitempty"`
  173. // ForceSendFields is a list of field names (e.g. "UserId") to
  174. // unconditionally include in API requests. By default, fields with
  175. // empty values are omitted from API requests. However, any non-pointer,
  176. // non-interface field appearing in ForceSendFields will be sent to the
  177. // server regardless of whether the field is empty or not. This may be
  178. // used to include empty fields in Patch requests.
  179. ForceSendFields []string `json:"-"`
  180. // NullFields is a list of field names (e.g. "UserId") to include in API
  181. // requests with the JSON null value. By default, fields with empty
  182. // values are omitted from API requests. However, any field with an
  183. // empty value appearing in NullFields will be sent to the server as
  184. // null. It is an error if a field in this list has a non-empty value.
  185. // This may be used to include null fields in Patch requests.
  186. NullFields []string `json:"-"`
  187. }
  188. func (s *LicenseAssignmentInsert) MarshalJSON() ([]byte, error) {
  189. type NoMethod LicenseAssignmentInsert
  190. raw := NoMethod(*s)
  191. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  192. }
  193. // LicenseAssignmentList: LicesnseAssignment List for a given
  194. // product/sku for a customer.
  195. type LicenseAssignmentList struct {
  196. // Etag: ETag of the resource.
  197. Etag string `json:"etag,omitempty"`
  198. // Items: The LicenseAssignments in this page of results.
  199. Items []*LicenseAssignment `json:"items,omitempty"`
  200. // Kind: Identifies the resource as a collection of LicenseAssignments.
  201. Kind string `json:"kind,omitempty"`
  202. // NextPageToken: The continuation token, used to page through large
  203. // result sets. Provide this value in a subsequent request to return the
  204. // next page of results.
  205. NextPageToken string `json:"nextPageToken,omitempty"`
  206. // ServerResponse contains the HTTP response code and headers from the
  207. // server.
  208. googleapi.ServerResponse `json:"-"`
  209. // ForceSendFields is a list of field names (e.g. "Etag") to
  210. // unconditionally include in API requests. By default, fields with
  211. // empty values are omitted from API requests. However, any non-pointer,
  212. // non-interface field appearing in ForceSendFields will be sent to the
  213. // server regardless of whether the field is empty or not. This may be
  214. // used to include empty fields in Patch requests.
  215. ForceSendFields []string `json:"-"`
  216. // NullFields is a list of field names (e.g. "Etag") to include in API
  217. // requests with the JSON null value. By default, fields with empty
  218. // values are omitted from API requests. However, any field with an
  219. // empty value appearing in NullFields will be sent to the server as
  220. // null. It is an error if a field in this list has a non-empty value.
  221. // This may be used to include null fields in Patch requests.
  222. NullFields []string `json:"-"`
  223. }
  224. func (s *LicenseAssignmentList) MarshalJSON() ([]byte, error) {
  225. type NoMethod LicenseAssignmentList
  226. raw := NoMethod(*s)
  227. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  228. }
  229. // method id "licensing.licenseAssignments.delete":
  230. type LicenseAssignmentsDeleteCall struct {
  231. s *Service
  232. productId string
  233. skuId string
  234. userId string
  235. urlParams_ gensupport.URLParams
  236. ctx_ context.Context
  237. header_ http.Header
  238. }
  239. // Delete: Revoke License.
  240. func (r *LicenseAssignmentsService) Delete(productId string, skuId string, userId string) *LicenseAssignmentsDeleteCall {
  241. c := &LicenseAssignmentsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  242. c.productId = productId
  243. c.skuId = skuId
  244. c.userId = userId
  245. return c
  246. }
  247. // Fields allows partial responses to be retrieved. See
  248. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  249. // for more information.
  250. func (c *LicenseAssignmentsDeleteCall) Fields(s ...googleapi.Field) *LicenseAssignmentsDeleteCall {
  251. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  252. return c
  253. }
  254. // Context sets the context to be used in this call's Do method. Any
  255. // pending HTTP request will be aborted if the provided context is
  256. // canceled.
  257. func (c *LicenseAssignmentsDeleteCall) Context(ctx context.Context) *LicenseAssignmentsDeleteCall {
  258. c.ctx_ = ctx
  259. return c
  260. }
  261. // Header returns an http.Header that can be modified by the caller to
  262. // add HTTP headers to the request.
  263. func (c *LicenseAssignmentsDeleteCall) Header() http.Header {
  264. if c.header_ == nil {
  265. c.header_ = make(http.Header)
  266. }
  267. return c.header_
  268. }
  269. func (c *LicenseAssignmentsDeleteCall) doRequest(alt string) (*http.Response, error) {
  270. reqHeaders := make(http.Header)
  271. for k, v := range c.header_ {
  272. reqHeaders[k] = v
  273. }
  274. reqHeaders.Set("User-Agent", c.s.userAgent())
  275. var body io.Reader = nil
  276. c.urlParams_.Set("alt", alt)
  277. c.urlParams_.Set("prettyPrint", "false")
  278. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/sku/{skuId}/user/{userId}")
  279. urls += "?" + c.urlParams_.Encode()
  280. req, err := http.NewRequest("DELETE", urls, body)
  281. if err != nil {
  282. return nil, err
  283. }
  284. req.Header = reqHeaders
  285. googleapi.Expand(req.URL, map[string]string{
  286. "productId": c.productId,
  287. "skuId": c.skuId,
  288. "userId": c.userId,
  289. })
  290. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  291. }
  292. // Do executes the "licensing.licenseAssignments.delete" call.
  293. func (c *LicenseAssignmentsDeleteCall) Do(opts ...googleapi.CallOption) error {
  294. gensupport.SetOptions(c.urlParams_, opts...)
  295. res, err := c.doRequest("json")
  296. if err != nil {
  297. return err
  298. }
  299. defer googleapi.CloseBody(res)
  300. if err := googleapi.CheckResponse(res); err != nil {
  301. return err
  302. }
  303. return nil
  304. // {
  305. // "description": "Revoke License.",
  306. // "httpMethod": "DELETE",
  307. // "id": "licensing.licenseAssignments.delete",
  308. // "parameterOrder": [
  309. // "productId",
  310. // "skuId",
  311. // "userId"
  312. // ],
  313. // "parameters": {
  314. // "productId": {
  315. // "description": "Name for product",
  316. // "location": "path",
  317. // "required": true,
  318. // "type": "string"
  319. // },
  320. // "skuId": {
  321. // "description": "Name for sku",
  322. // "location": "path",
  323. // "required": true,
  324. // "type": "string"
  325. // },
  326. // "userId": {
  327. // "description": "email id or unique Id of the user",
  328. // "location": "path",
  329. // "required": true,
  330. // "type": "string"
  331. // }
  332. // },
  333. // "path": "{productId}/sku/{skuId}/user/{userId}",
  334. // "scopes": [
  335. // "https://www.googleapis.com/auth/apps.licensing"
  336. // ]
  337. // }
  338. }
  339. // method id "licensing.licenseAssignments.get":
  340. type LicenseAssignmentsGetCall struct {
  341. s *Service
  342. productId string
  343. skuId string
  344. userId string
  345. urlParams_ gensupport.URLParams
  346. ifNoneMatch_ string
  347. ctx_ context.Context
  348. header_ http.Header
  349. }
  350. // Get: Get license assignment of a particular product and sku for a
  351. // user
  352. func (r *LicenseAssignmentsService) Get(productId string, skuId string, userId string) *LicenseAssignmentsGetCall {
  353. c := &LicenseAssignmentsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  354. c.productId = productId
  355. c.skuId = skuId
  356. c.userId = userId
  357. return c
  358. }
  359. // Fields allows partial responses to be retrieved. See
  360. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  361. // for more information.
  362. func (c *LicenseAssignmentsGetCall) Fields(s ...googleapi.Field) *LicenseAssignmentsGetCall {
  363. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  364. return c
  365. }
  366. // IfNoneMatch sets the optional parameter which makes the operation
  367. // fail if the object's ETag matches the given value. This is useful for
  368. // getting updates only after the object has changed since the last
  369. // request. Use googleapi.IsNotModified to check whether the response
  370. // error from Do is the result of In-None-Match.
  371. func (c *LicenseAssignmentsGetCall) IfNoneMatch(entityTag string) *LicenseAssignmentsGetCall {
  372. c.ifNoneMatch_ = entityTag
  373. return c
  374. }
  375. // Context sets the context to be used in this call's Do method. Any
  376. // pending HTTP request will be aborted if the provided context is
  377. // canceled.
  378. func (c *LicenseAssignmentsGetCall) Context(ctx context.Context) *LicenseAssignmentsGetCall {
  379. c.ctx_ = ctx
  380. return c
  381. }
  382. // Header returns an http.Header that can be modified by the caller to
  383. // add HTTP headers to the request.
  384. func (c *LicenseAssignmentsGetCall) Header() http.Header {
  385. if c.header_ == nil {
  386. c.header_ = make(http.Header)
  387. }
  388. return c.header_
  389. }
  390. func (c *LicenseAssignmentsGetCall) doRequest(alt string) (*http.Response, error) {
  391. reqHeaders := make(http.Header)
  392. for k, v := range c.header_ {
  393. reqHeaders[k] = v
  394. }
  395. reqHeaders.Set("User-Agent", c.s.userAgent())
  396. if c.ifNoneMatch_ != "" {
  397. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  398. }
  399. var body io.Reader = nil
  400. c.urlParams_.Set("alt", alt)
  401. c.urlParams_.Set("prettyPrint", "false")
  402. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/sku/{skuId}/user/{userId}")
  403. urls += "?" + c.urlParams_.Encode()
  404. req, err := http.NewRequest("GET", urls, body)
  405. if err != nil {
  406. return nil, err
  407. }
  408. req.Header = reqHeaders
  409. googleapi.Expand(req.URL, map[string]string{
  410. "productId": c.productId,
  411. "skuId": c.skuId,
  412. "userId": c.userId,
  413. })
  414. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  415. }
  416. // Do executes the "licensing.licenseAssignments.get" call.
  417. // Exactly one of *LicenseAssignment or error will be non-nil. Any
  418. // non-2xx status code is an error. Response headers are in either
  419. // *LicenseAssignment.ServerResponse.Header or (if a response was
  420. // returned at all) in error.(*googleapi.Error).Header. Use
  421. // googleapi.IsNotModified to check whether the returned error was
  422. // because http.StatusNotModified was returned.
  423. func (c *LicenseAssignmentsGetCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
  424. gensupport.SetOptions(c.urlParams_, opts...)
  425. res, err := c.doRequest("json")
  426. if res != nil && res.StatusCode == http.StatusNotModified {
  427. if res.Body != nil {
  428. res.Body.Close()
  429. }
  430. return nil, &googleapi.Error{
  431. Code: res.StatusCode,
  432. Header: res.Header,
  433. }
  434. }
  435. if err != nil {
  436. return nil, err
  437. }
  438. defer googleapi.CloseBody(res)
  439. if err := googleapi.CheckResponse(res); err != nil {
  440. return nil, err
  441. }
  442. ret := &LicenseAssignment{
  443. ServerResponse: googleapi.ServerResponse{
  444. Header: res.Header,
  445. HTTPStatusCode: res.StatusCode,
  446. },
  447. }
  448. target := &ret
  449. if err := gensupport.DecodeResponse(target, res); err != nil {
  450. return nil, err
  451. }
  452. return ret, nil
  453. // {
  454. // "description": "Get license assignment of a particular product and sku for a user",
  455. // "httpMethod": "GET",
  456. // "id": "licensing.licenseAssignments.get",
  457. // "parameterOrder": [
  458. // "productId",
  459. // "skuId",
  460. // "userId"
  461. // ],
  462. // "parameters": {
  463. // "productId": {
  464. // "description": "Name for product",
  465. // "location": "path",
  466. // "required": true,
  467. // "type": "string"
  468. // },
  469. // "skuId": {
  470. // "description": "Name for sku",
  471. // "location": "path",
  472. // "required": true,
  473. // "type": "string"
  474. // },
  475. // "userId": {
  476. // "description": "email id or unique Id of the user",
  477. // "location": "path",
  478. // "required": true,
  479. // "type": "string"
  480. // }
  481. // },
  482. // "path": "{productId}/sku/{skuId}/user/{userId}",
  483. // "response": {
  484. // "$ref": "LicenseAssignment"
  485. // },
  486. // "scopes": [
  487. // "https://www.googleapis.com/auth/apps.licensing"
  488. // ]
  489. // }
  490. }
  491. // method id "licensing.licenseAssignments.insert":
  492. type LicenseAssignmentsInsertCall struct {
  493. s *Service
  494. productId string
  495. skuId string
  496. licenseassignmentinsert *LicenseAssignmentInsert
  497. urlParams_ gensupport.URLParams
  498. ctx_ context.Context
  499. header_ http.Header
  500. }
  501. // Insert: Assign License.
  502. func (r *LicenseAssignmentsService) Insert(productId string, skuId string, licenseassignmentinsert *LicenseAssignmentInsert) *LicenseAssignmentsInsertCall {
  503. c := &LicenseAssignmentsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  504. c.productId = productId
  505. c.skuId = skuId
  506. c.licenseassignmentinsert = licenseassignmentinsert
  507. return c
  508. }
  509. // Fields allows partial responses to be retrieved. See
  510. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  511. // for more information.
  512. func (c *LicenseAssignmentsInsertCall) Fields(s ...googleapi.Field) *LicenseAssignmentsInsertCall {
  513. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  514. return c
  515. }
  516. // Context sets the context to be used in this call's Do method. Any
  517. // pending HTTP request will be aborted if the provided context is
  518. // canceled.
  519. func (c *LicenseAssignmentsInsertCall) Context(ctx context.Context) *LicenseAssignmentsInsertCall {
  520. c.ctx_ = ctx
  521. return c
  522. }
  523. // Header returns an http.Header that can be modified by the caller to
  524. // add HTTP headers to the request.
  525. func (c *LicenseAssignmentsInsertCall) Header() http.Header {
  526. if c.header_ == nil {
  527. c.header_ = make(http.Header)
  528. }
  529. return c.header_
  530. }
  531. func (c *LicenseAssignmentsInsertCall) doRequest(alt string) (*http.Response, error) {
  532. reqHeaders := make(http.Header)
  533. for k, v := range c.header_ {
  534. reqHeaders[k] = v
  535. }
  536. reqHeaders.Set("User-Agent", c.s.userAgent())
  537. var body io.Reader = nil
  538. body, err := googleapi.WithoutDataWrapper.JSONReader(c.licenseassignmentinsert)
  539. if err != nil {
  540. return nil, err
  541. }
  542. reqHeaders.Set("Content-Type", "application/json")
  543. c.urlParams_.Set("alt", alt)
  544. c.urlParams_.Set("prettyPrint", "false")
  545. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/sku/{skuId}/user")
  546. urls += "?" + c.urlParams_.Encode()
  547. req, err := http.NewRequest("POST", urls, body)
  548. if err != nil {
  549. return nil, err
  550. }
  551. req.Header = reqHeaders
  552. googleapi.Expand(req.URL, map[string]string{
  553. "productId": c.productId,
  554. "skuId": c.skuId,
  555. })
  556. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  557. }
  558. // Do executes the "licensing.licenseAssignments.insert" call.
  559. // Exactly one of *LicenseAssignment or error will be non-nil. Any
  560. // non-2xx status code is an error. Response headers are in either
  561. // *LicenseAssignment.ServerResponse.Header or (if a response was
  562. // returned at all) in error.(*googleapi.Error).Header. Use
  563. // googleapi.IsNotModified to check whether the returned error was
  564. // because http.StatusNotModified was returned.
  565. func (c *LicenseAssignmentsInsertCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
  566. gensupport.SetOptions(c.urlParams_, opts...)
  567. res, err := c.doRequest("json")
  568. if res != nil && res.StatusCode == http.StatusNotModified {
  569. if res.Body != nil {
  570. res.Body.Close()
  571. }
  572. return nil, &googleapi.Error{
  573. Code: res.StatusCode,
  574. Header: res.Header,
  575. }
  576. }
  577. if err != nil {
  578. return nil, err
  579. }
  580. defer googleapi.CloseBody(res)
  581. if err := googleapi.CheckResponse(res); err != nil {
  582. return nil, err
  583. }
  584. ret := &LicenseAssignment{
  585. ServerResponse: googleapi.ServerResponse{
  586. Header: res.Header,
  587. HTTPStatusCode: res.StatusCode,
  588. },
  589. }
  590. target := &ret
  591. if err := gensupport.DecodeResponse(target, res); err != nil {
  592. return nil, err
  593. }
  594. return ret, nil
  595. // {
  596. // "description": "Assign License.",
  597. // "httpMethod": "POST",
  598. // "id": "licensing.licenseAssignments.insert",
  599. // "parameterOrder": [
  600. // "productId",
  601. // "skuId"
  602. // ],
  603. // "parameters": {
  604. // "productId": {
  605. // "description": "Name for product",
  606. // "location": "path",
  607. // "required": true,
  608. // "type": "string"
  609. // },
  610. // "skuId": {
  611. // "description": "Name for sku",
  612. // "location": "path",
  613. // "required": true,
  614. // "type": "string"
  615. // }
  616. // },
  617. // "path": "{productId}/sku/{skuId}/user",
  618. // "request": {
  619. // "$ref": "LicenseAssignmentInsert"
  620. // },
  621. // "response": {
  622. // "$ref": "LicenseAssignment"
  623. // },
  624. // "scopes": [
  625. // "https://www.googleapis.com/auth/apps.licensing"
  626. // ]
  627. // }
  628. }
  629. // method id "licensing.licenseAssignments.listForProduct":
  630. type LicenseAssignmentsListForProductCall struct {
  631. s *Service
  632. productId string
  633. urlParams_ gensupport.URLParams
  634. ifNoneMatch_ string
  635. ctx_ context.Context
  636. header_ http.Header
  637. }
  638. // ListForProduct: List license assignments for given product of the
  639. // customer.
  640. func (r *LicenseAssignmentsService) ListForProduct(productId string, customerId string) *LicenseAssignmentsListForProductCall {
  641. c := &LicenseAssignmentsListForProductCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  642. c.productId = productId
  643. c.urlParams_.Set("customerId", customerId)
  644. return c
  645. }
  646. // MaxResults sets the optional parameter "maxResults": Maximum number
  647. // of campaigns to return at one time. Must be positive. Default value
  648. // is 100.
  649. func (c *LicenseAssignmentsListForProductCall) MaxResults(maxResults int64) *LicenseAssignmentsListForProductCall {
  650. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  651. return c
  652. }
  653. // PageToken sets the optional parameter "pageToken": Token to fetch the
  654. // next page. By default server will return first page
  655. func (c *LicenseAssignmentsListForProductCall) PageToken(pageToken string) *LicenseAssignmentsListForProductCall {
  656. c.urlParams_.Set("pageToken", pageToken)
  657. return c
  658. }
  659. // Fields allows partial responses to be retrieved. See
  660. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  661. // for more information.
  662. func (c *LicenseAssignmentsListForProductCall) Fields(s ...googleapi.Field) *LicenseAssignmentsListForProductCall {
  663. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  664. return c
  665. }
  666. // IfNoneMatch sets the optional parameter which makes the operation
  667. // fail if the object's ETag matches the given value. This is useful for
  668. // getting updates only after the object has changed since the last
  669. // request. Use googleapi.IsNotModified to check whether the response
  670. // error from Do is the result of In-None-Match.
  671. func (c *LicenseAssignmentsListForProductCall) IfNoneMatch(entityTag string) *LicenseAssignmentsListForProductCall {
  672. c.ifNoneMatch_ = entityTag
  673. return c
  674. }
  675. // Context sets the context to be used in this call's Do method. Any
  676. // pending HTTP request will be aborted if the provided context is
  677. // canceled.
  678. func (c *LicenseAssignmentsListForProductCall) Context(ctx context.Context) *LicenseAssignmentsListForProductCall {
  679. c.ctx_ = ctx
  680. return c
  681. }
  682. // Header returns an http.Header that can be modified by the caller to
  683. // add HTTP headers to the request.
  684. func (c *LicenseAssignmentsListForProductCall) Header() http.Header {
  685. if c.header_ == nil {
  686. c.header_ = make(http.Header)
  687. }
  688. return c.header_
  689. }
  690. func (c *LicenseAssignmentsListForProductCall) doRequest(alt string) (*http.Response, error) {
  691. reqHeaders := make(http.Header)
  692. for k, v := range c.header_ {
  693. reqHeaders[k] = v
  694. }
  695. reqHeaders.Set("User-Agent", c.s.userAgent())
  696. if c.ifNoneMatch_ != "" {
  697. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  698. }
  699. var body io.Reader = nil
  700. c.urlParams_.Set("alt", alt)
  701. c.urlParams_.Set("prettyPrint", "false")
  702. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/users")
  703. urls += "?" + c.urlParams_.Encode()
  704. req, err := http.NewRequest("GET", urls, body)
  705. if err != nil {
  706. return nil, err
  707. }
  708. req.Header = reqHeaders
  709. googleapi.Expand(req.URL, map[string]string{
  710. "productId": c.productId,
  711. })
  712. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  713. }
  714. // Do executes the "licensing.licenseAssignments.listForProduct" call.
  715. // Exactly one of *LicenseAssignmentList or error will be non-nil. Any
  716. // non-2xx status code is an error. Response headers are in either
  717. // *LicenseAssignmentList.ServerResponse.Header or (if a response was
  718. // returned at all) in error.(*googleapi.Error).Header. Use
  719. // googleapi.IsNotModified to check whether the returned error was
  720. // because http.StatusNotModified was returned.
  721. func (c *LicenseAssignmentsListForProductCall) Do(opts ...googleapi.CallOption) (*LicenseAssignmentList, error) {
  722. gensupport.SetOptions(c.urlParams_, opts...)
  723. res, err := c.doRequest("json")
  724. if res != nil && res.StatusCode == http.StatusNotModified {
  725. if res.Body != nil {
  726. res.Body.Close()
  727. }
  728. return nil, &googleapi.Error{
  729. Code: res.StatusCode,
  730. Header: res.Header,
  731. }
  732. }
  733. if err != nil {
  734. return nil, err
  735. }
  736. defer googleapi.CloseBody(res)
  737. if err := googleapi.CheckResponse(res); err != nil {
  738. return nil, err
  739. }
  740. ret := &LicenseAssignmentList{
  741. ServerResponse: googleapi.ServerResponse{
  742. Header: res.Header,
  743. HTTPStatusCode: res.StatusCode,
  744. },
  745. }
  746. target := &ret
  747. if err := gensupport.DecodeResponse(target, res); err != nil {
  748. return nil, err
  749. }
  750. return ret, nil
  751. // {
  752. // "description": "List license assignments for given product of the customer.",
  753. // "httpMethod": "GET",
  754. // "id": "licensing.licenseAssignments.listForProduct",
  755. // "parameterOrder": [
  756. // "productId",
  757. // "customerId"
  758. // ],
  759. // "parameters": {
  760. // "customerId": {
  761. // "description": "CustomerId represents the customer for whom licenseassignments are queried",
  762. // "location": "query",
  763. // "required": true,
  764. // "type": "string"
  765. // },
  766. // "maxResults": {
  767. // "default": "100",
  768. // "description": "Maximum number of campaigns to return at one time. Must be positive. Optional. Default value is 100.",
  769. // "format": "uint32",
  770. // "location": "query",
  771. // "maximum": "1000",
  772. // "minimum": "1",
  773. // "type": "integer"
  774. // },
  775. // "pageToken": {
  776. // "default": "",
  777. // "description": "Token to fetch the next page.Optional. By default server will return first page",
  778. // "location": "query",
  779. // "type": "string"
  780. // },
  781. // "productId": {
  782. // "description": "Name for product",
  783. // "location": "path",
  784. // "required": true,
  785. // "type": "string"
  786. // }
  787. // },
  788. // "path": "{productId}/users",
  789. // "response": {
  790. // "$ref": "LicenseAssignmentList"
  791. // },
  792. // "scopes": [
  793. // "https://www.googleapis.com/auth/apps.licensing"
  794. // ]
  795. // }
  796. }
  797. // Pages invokes f for each page of results.
  798. // A non-nil error returned from f will halt the iteration.
  799. // The provided context supersedes any context provided to the Context method.
  800. func (c *LicenseAssignmentsListForProductCall) Pages(ctx context.Context, f func(*LicenseAssignmentList) error) error {
  801. c.ctx_ = ctx
  802. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  803. for {
  804. x, err := c.Do()
  805. if err != nil {
  806. return err
  807. }
  808. if err := f(x); err != nil {
  809. return err
  810. }
  811. if x.NextPageToken == "" {
  812. return nil
  813. }
  814. c.PageToken(x.NextPageToken)
  815. }
  816. }
  817. // method id "licensing.licenseAssignments.listForProductAndSku":
  818. type LicenseAssignmentsListForProductAndSkuCall struct {
  819. s *Service
  820. productId string
  821. skuId string
  822. urlParams_ gensupport.URLParams
  823. ifNoneMatch_ string
  824. ctx_ context.Context
  825. header_ http.Header
  826. }
  827. // ListForProductAndSku: List license assignments for given product and
  828. // sku of the customer.
  829. func (r *LicenseAssignmentsService) ListForProductAndSku(productId string, skuId string, customerId string) *LicenseAssignmentsListForProductAndSkuCall {
  830. c := &LicenseAssignmentsListForProductAndSkuCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  831. c.productId = productId
  832. c.skuId = skuId
  833. c.urlParams_.Set("customerId", customerId)
  834. return c
  835. }
  836. // MaxResults sets the optional parameter "maxResults": Maximum number
  837. // of campaigns to return at one time. Must be positive. Default value
  838. // is 100.
  839. func (c *LicenseAssignmentsListForProductAndSkuCall) MaxResults(maxResults int64) *LicenseAssignmentsListForProductAndSkuCall {
  840. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  841. return c
  842. }
  843. // PageToken sets the optional parameter "pageToken": Token to fetch the
  844. // next page. By default server will return first page
  845. func (c *LicenseAssignmentsListForProductAndSkuCall) PageToken(pageToken string) *LicenseAssignmentsListForProductAndSkuCall {
  846. c.urlParams_.Set("pageToken", pageToken)
  847. return c
  848. }
  849. // Fields allows partial responses to be retrieved. See
  850. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  851. // for more information.
  852. func (c *LicenseAssignmentsListForProductAndSkuCall) Fields(s ...googleapi.Field) *LicenseAssignmentsListForProductAndSkuCall {
  853. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  854. return c
  855. }
  856. // IfNoneMatch sets the optional parameter which makes the operation
  857. // fail if the object's ETag matches the given value. This is useful for
  858. // getting updates only after the object has changed since the last
  859. // request. Use googleapi.IsNotModified to check whether the response
  860. // error from Do is the result of In-None-Match.
  861. func (c *LicenseAssignmentsListForProductAndSkuCall) IfNoneMatch(entityTag string) *LicenseAssignmentsListForProductAndSkuCall {
  862. c.ifNoneMatch_ = entityTag
  863. return c
  864. }
  865. // Context sets the context to be used in this call's Do method. Any
  866. // pending HTTP request will be aborted if the provided context is
  867. // canceled.
  868. func (c *LicenseAssignmentsListForProductAndSkuCall) Context(ctx context.Context) *LicenseAssignmentsListForProductAndSkuCall {
  869. c.ctx_ = ctx
  870. return c
  871. }
  872. // Header returns an http.Header that can be modified by the caller to
  873. // add HTTP headers to the request.
  874. func (c *LicenseAssignmentsListForProductAndSkuCall) Header() http.Header {
  875. if c.header_ == nil {
  876. c.header_ = make(http.Header)
  877. }
  878. return c.header_
  879. }
  880. func (c *LicenseAssignmentsListForProductAndSkuCall) doRequest(alt string) (*http.Response, error) {
  881. reqHeaders := make(http.Header)
  882. for k, v := range c.header_ {
  883. reqHeaders[k] = v
  884. }
  885. reqHeaders.Set("User-Agent", c.s.userAgent())
  886. if c.ifNoneMatch_ != "" {
  887. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  888. }
  889. var body io.Reader = nil
  890. c.urlParams_.Set("alt", alt)
  891. c.urlParams_.Set("prettyPrint", "false")
  892. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/sku/{skuId}/users")
  893. urls += "?" + c.urlParams_.Encode()
  894. req, err := http.NewRequest("GET", urls, body)
  895. if err != nil {
  896. return nil, err
  897. }
  898. req.Header = reqHeaders
  899. googleapi.Expand(req.URL, map[string]string{
  900. "productId": c.productId,
  901. "skuId": c.skuId,
  902. })
  903. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  904. }
  905. // Do executes the "licensing.licenseAssignments.listForProductAndSku" call.
  906. // Exactly one of *LicenseAssignmentList or error will be non-nil. Any
  907. // non-2xx status code is an error. Response headers are in either
  908. // *LicenseAssignmentList.ServerResponse.Header or (if a response was
  909. // returned at all) in error.(*googleapi.Error).Header. Use
  910. // googleapi.IsNotModified to check whether the returned error was
  911. // because http.StatusNotModified was returned.
  912. func (c *LicenseAssignmentsListForProductAndSkuCall) Do(opts ...googleapi.CallOption) (*LicenseAssignmentList, error) {
  913. gensupport.SetOptions(c.urlParams_, opts...)
  914. res, err := c.doRequest("json")
  915. if res != nil && res.StatusCode == http.StatusNotModified {
  916. if res.Body != nil {
  917. res.Body.Close()
  918. }
  919. return nil, &googleapi.Error{
  920. Code: res.StatusCode,
  921. Header: res.Header,
  922. }
  923. }
  924. if err != nil {
  925. return nil, err
  926. }
  927. defer googleapi.CloseBody(res)
  928. if err := googleapi.CheckResponse(res); err != nil {
  929. return nil, err
  930. }
  931. ret := &LicenseAssignmentList{
  932. ServerResponse: googleapi.ServerResponse{
  933. Header: res.Header,
  934. HTTPStatusCode: res.StatusCode,
  935. },
  936. }
  937. target := &ret
  938. if err := gensupport.DecodeResponse(target, res); err != nil {
  939. return nil, err
  940. }
  941. return ret, nil
  942. // {
  943. // "description": "List license assignments for given product and sku of the customer.",
  944. // "httpMethod": "GET",
  945. // "id": "licensing.licenseAssignments.listForProductAndSku",
  946. // "parameterOrder": [
  947. // "productId",
  948. // "skuId",
  949. // "customerId"
  950. // ],
  951. // "parameters": {
  952. // "customerId": {
  953. // "description": "CustomerId represents the customer for whom licenseassignments are queried",
  954. // "location": "query",
  955. // "required": true,
  956. // "type": "string"
  957. // },
  958. // "maxResults": {
  959. // "default": "100",
  960. // "description": "Maximum number of campaigns to return at one time. Must be positive. Optional. Default value is 100.",
  961. // "format": "uint32",
  962. // "location": "query",
  963. // "maximum": "1000",
  964. // "minimum": "1",
  965. // "type": "integer"
  966. // },
  967. // "pageToken": {
  968. // "default": "",
  969. // "description": "Token to fetch the next page.Optional. By default server will return first page",
  970. // "location": "query",
  971. // "type": "string"
  972. // },
  973. // "productId": {
  974. // "description": "Name for product",
  975. // "location": "path",
  976. // "required": true,
  977. // "type": "string"
  978. // },
  979. // "skuId": {
  980. // "description": "Name for sku",
  981. // "location": "path",
  982. // "required": true,
  983. // "type": "string"
  984. // }
  985. // },
  986. // "path": "{productId}/sku/{skuId}/users",
  987. // "response": {
  988. // "$ref": "LicenseAssignmentList"
  989. // },
  990. // "scopes": [
  991. // "https://www.googleapis.com/auth/apps.licensing"
  992. // ]
  993. // }
  994. }
  995. // Pages invokes f for each page of results.
  996. // A non-nil error returned from f will halt the iteration.
  997. // The provided context supersedes any context provided to the Context method.
  998. func (c *LicenseAssignmentsListForProductAndSkuCall) Pages(ctx context.Context, f func(*LicenseAssignmentList) error) error {
  999. c.ctx_ = ctx
  1000. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1001. for {
  1002. x, err := c.Do()
  1003. if err != nil {
  1004. return err
  1005. }
  1006. if err := f(x); err != nil {
  1007. return err
  1008. }
  1009. if x.NextPageToken == "" {
  1010. return nil
  1011. }
  1012. c.PageToken(x.NextPageToken)
  1013. }
  1014. }
  1015. // method id "licensing.licenseAssignments.patch":
  1016. type LicenseAssignmentsPatchCall struct {
  1017. s *Service
  1018. productId string
  1019. skuId string
  1020. userId string
  1021. licenseassignment *LicenseAssignment
  1022. urlParams_ gensupport.URLParams
  1023. ctx_ context.Context
  1024. header_ http.Header
  1025. }
  1026. // Patch: Assign License. This method supports patch semantics.
  1027. func (r *LicenseAssignmentsService) Patch(productId string, skuId string, userId string, licenseassignment *LicenseAssignment) *LicenseAssignmentsPatchCall {
  1028. c := &LicenseAssignmentsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1029. c.productId = productId
  1030. c.skuId = skuId
  1031. c.userId = userId
  1032. c.licenseassignment = licenseassignment
  1033. return c
  1034. }
  1035. // Fields allows partial responses to be retrieved. See
  1036. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1037. // for more information.
  1038. func (c *LicenseAssignmentsPatchCall) Fields(s ...googleapi.Field) *LicenseAssignmentsPatchCall {
  1039. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1040. return c
  1041. }
  1042. // Context sets the context to be used in this call's Do method. Any
  1043. // pending HTTP request will be aborted if the provided context is
  1044. // canceled.
  1045. func (c *LicenseAssignmentsPatchCall) Context(ctx context.Context) *LicenseAssignmentsPatchCall {
  1046. c.ctx_ = ctx
  1047. return c
  1048. }
  1049. // Header returns an http.Header that can be modified by the caller to
  1050. // add HTTP headers to the request.
  1051. func (c *LicenseAssignmentsPatchCall) Header() http.Header {
  1052. if c.header_ == nil {
  1053. c.header_ = make(http.Header)
  1054. }
  1055. return c.header_
  1056. }
  1057. func (c *LicenseAssignmentsPatchCall) doRequest(alt string) (*http.Response, error) {
  1058. reqHeaders := make(http.Header)
  1059. for k, v := range c.header_ {
  1060. reqHeaders[k] = v
  1061. }
  1062. reqHeaders.Set("User-Agent", c.s.userAgent())
  1063. var body io.Reader = nil
  1064. body, err := googleapi.WithoutDataWrapper.JSONReader(c.licenseassignment)
  1065. if err != nil {
  1066. return nil, err
  1067. }
  1068. reqHeaders.Set("Content-Type", "application/json")
  1069. c.urlParams_.Set("alt", alt)
  1070. c.urlParams_.Set("prettyPrint", "false")
  1071. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/sku/{skuId}/user/{userId}")
  1072. urls += "?" + c.urlParams_.Encode()
  1073. req, err := http.NewRequest("PATCH", urls, body)
  1074. if err != nil {
  1075. return nil, err
  1076. }
  1077. req.Header = reqHeaders
  1078. googleapi.Expand(req.URL, map[string]string{
  1079. "productId": c.productId,
  1080. "skuId": c.skuId,
  1081. "userId": c.userId,
  1082. })
  1083. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1084. }
  1085. // Do executes the "licensing.licenseAssignments.patch" call.
  1086. // Exactly one of *LicenseAssignment or error will be non-nil. Any
  1087. // non-2xx status code is an error. Response headers are in either
  1088. // *LicenseAssignment.ServerResponse.Header or (if a response was
  1089. // returned at all) in error.(*googleapi.Error).Header. Use
  1090. // googleapi.IsNotModified to check whether the returned error was
  1091. // because http.StatusNotModified was returned.
  1092. func (c *LicenseAssignmentsPatchCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
  1093. gensupport.SetOptions(c.urlParams_, opts...)
  1094. res, err := c.doRequest("json")
  1095. if res != nil && res.StatusCode == http.StatusNotModified {
  1096. if res.Body != nil {
  1097. res.Body.Close()
  1098. }
  1099. return nil, &googleapi.Error{
  1100. Code: res.StatusCode,
  1101. Header: res.Header,
  1102. }
  1103. }
  1104. if err != nil {
  1105. return nil, err
  1106. }
  1107. defer googleapi.CloseBody(res)
  1108. if err := googleapi.CheckResponse(res); err != nil {
  1109. return nil, err
  1110. }
  1111. ret := &LicenseAssignment{
  1112. ServerResponse: googleapi.ServerResponse{
  1113. Header: res.Header,
  1114. HTTPStatusCode: res.StatusCode,
  1115. },
  1116. }
  1117. target := &ret
  1118. if err := gensupport.DecodeResponse(target, res); err != nil {
  1119. return nil, err
  1120. }
  1121. return ret, nil
  1122. // {
  1123. // "description": "Assign License. This method supports patch semantics.",
  1124. // "httpMethod": "PATCH",
  1125. // "id": "licensing.licenseAssignments.patch",
  1126. // "parameterOrder": [
  1127. // "productId",
  1128. // "skuId",
  1129. // "userId"
  1130. // ],
  1131. // "parameters": {
  1132. // "productId": {
  1133. // "description": "Name for product",
  1134. // "location": "path",
  1135. // "required": true,
  1136. // "type": "string"
  1137. // },
  1138. // "skuId": {
  1139. // "description": "Name for sku for which license would be revoked",
  1140. // "location": "path",
  1141. // "required": true,
  1142. // "type": "string"
  1143. // },
  1144. // "userId": {
  1145. // "description": "email id or unique Id of the user",
  1146. // "location": "path",
  1147. // "required": true,
  1148. // "type": "string"
  1149. // }
  1150. // },
  1151. // "path": "{productId}/sku/{skuId}/user/{userId}",
  1152. // "request": {
  1153. // "$ref": "LicenseAssignment"
  1154. // },
  1155. // "response": {
  1156. // "$ref": "LicenseAssignment"
  1157. // },
  1158. // "scopes": [
  1159. // "https://www.googleapis.com/auth/apps.licensing"
  1160. // ]
  1161. // }
  1162. }
  1163. // method id "licensing.licenseAssignments.update":
  1164. type LicenseAssignmentsUpdateCall struct {
  1165. s *Service
  1166. productId string
  1167. skuId string
  1168. userId string
  1169. licenseassignment *LicenseAssignment
  1170. urlParams_ gensupport.URLParams
  1171. ctx_ context.Context
  1172. header_ http.Header
  1173. }
  1174. // Update: Assign License.
  1175. func (r *LicenseAssignmentsService) Update(productId string, skuId string, userId string, licenseassignment *LicenseAssignment) *LicenseAssignmentsUpdateCall {
  1176. c := &LicenseAssignmentsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1177. c.productId = productId
  1178. c.skuId = skuId
  1179. c.userId = userId
  1180. c.licenseassignment = licenseassignment
  1181. return c
  1182. }
  1183. // Fields allows partial responses to be retrieved. See
  1184. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1185. // for more information.
  1186. func (c *LicenseAssignmentsUpdateCall) Fields(s ...googleapi.Field) *LicenseAssignmentsUpdateCall {
  1187. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1188. return c
  1189. }
  1190. // Context sets the context to be used in this call's Do method. Any
  1191. // pending HTTP request will be aborted if the provided context is
  1192. // canceled.
  1193. func (c *LicenseAssignmentsUpdateCall) Context(ctx context.Context) *LicenseAssignmentsUpdateCall {
  1194. c.ctx_ = ctx
  1195. return c
  1196. }
  1197. // Header returns an http.Header that can be modified by the caller to
  1198. // add HTTP headers to the request.
  1199. func (c *LicenseAssignmentsUpdateCall) Header() http.Header {
  1200. if c.header_ == nil {
  1201. c.header_ = make(http.Header)
  1202. }
  1203. return c.header_
  1204. }
  1205. func (c *LicenseAssignmentsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1206. reqHeaders := make(http.Header)
  1207. for k, v := range c.header_ {
  1208. reqHeaders[k] = v
  1209. }
  1210. reqHeaders.Set("User-Agent", c.s.userAgent())
  1211. var body io.Reader = nil
  1212. body, err := googleapi.WithoutDataWrapper.JSONReader(c.licenseassignment)
  1213. if err != nil {
  1214. return nil, err
  1215. }
  1216. reqHeaders.Set("Content-Type", "application/json")
  1217. c.urlParams_.Set("alt", alt)
  1218. c.urlParams_.Set("prettyPrint", "false")
  1219. urls := googleapi.ResolveRelative(c.s.BasePath, "{productId}/sku/{skuId}/user/{userId}")
  1220. urls += "?" + c.urlParams_.Encode()
  1221. req, err := http.NewRequest("PUT", urls, body)
  1222. if err != nil {
  1223. return nil, err
  1224. }
  1225. req.Header = reqHeaders
  1226. googleapi.Expand(req.URL, map[string]string{
  1227. "productId": c.productId,
  1228. "skuId": c.skuId,
  1229. "userId": c.userId,
  1230. })
  1231. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1232. }
  1233. // Do executes the "licensing.licenseAssignments.update" call.
  1234. // Exactly one of *LicenseAssignment or error will be non-nil. Any
  1235. // non-2xx status code is an error. Response headers are in either
  1236. // *LicenseAssignment.ServerResponse.Header or (if a response was
  1237. // returned at all) in error.(*googleapi.Error).Header. Use
  1238. // googleapi.IsNotModified to check whether the returned error was
  1239. // because http.StatusNotModified was returned.
  1240. func (c *LicenseAssignmentsUpdateCall) Do(opts ...googleapi.CallOption) (*LicenseAssignment, error) {
  1241. gensupport.SetOptions(c.urlParams_, opts...)
  1242. res, err := c.doRequest("json")
  1243. if res != nil && res.StatusCode == http.StatusNotModified {
  1244. if res.Body != nil {
  1245. res.Body.Close()
  1246. }
  1247. return nil, &googleapi.Error{
  1248. Code: res.StatusCode,
  1249. Header: res.Header,
  1250. }
  1251. }
  1252. if err != nil {
  1253. return nil, err
  1254. }
  1255. defer googleapi.CloseBody(res)
  1256. if err := googleapi.CheckResponse(res); err != nil {
  1257. return nil, err
  1258. }
  1259. ret := &LicenseAssignment{
  1260. ServerResponse: googleapi.ServerResponse{
  1261. Header: res.Header,
  1262. HTTPStatusCode: res.StatusCode,
  1263. },
  1264. }
  1265. target := &ret
  1266. if err := gensupport.DecodeResponse(target, res); err != nil {
  1267. return nil, err
  1268. }
  1269. return ret, nil
  1270. // {
  1271. // "description": "Assign License.",
  1272. // "httpMethod": "PUT",
  1273. // "id": "licensing.licenseAssignments.update",
  1274. // "parameterOrder": [
  1275. // "productId",
  1276. // "skuId",
  1277. // "userId"
  1278. // ],
  1279. // "parameters": {
  1280. // "productId": {
  1281. // "description": "Name for product",
  1282. // "location": "path",
  1283. // "required": true,
  1284. // "type": "string"
  1285. // },
  1286. // "skuId": {
  1287. // "description": "Name for sku for which license would be revoked",
  1288. // "location": "path",
  1289. // "required": true,
  1290. // "type": "string"
  1291. // },
  1292. // "userId": {
  1293. // "description": "email id or unique Id of the user",
  1294. // "location": "path",
  1295. // "required": true,
  1296. // "type": "string"
  1297. // }
  1298. // },
  1299. // "path": "{productId}/sku/{skuId}/user/{userId}",
  1300. // "request": {
  1301. // "$ref": "LicenseAssignment"
  1302. // },
  1303. // "response": {
  1304. // "$ref": "LicenseAssignment"
  1305. // },
  1306. // "scopes": [
  1307. // "https://www.googleapis.com/auth/apps.licensing"
  1308. // ]
  1309. // }
  1310. }