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

1141 lines
34 KiB

  1. // Copyright 2018 Google Inc. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // AUTO-GENERATED CODE. DO NOT EDIT.
  5. // Package prediction provides access to the Prediction API.
  6. //
  7. // See https://developers.google.com/prediction/docs/developer-guide
  8. //
  9. // Usage example:
  10. //
  11. // import "google.golang.org/api/prediction/v1.2"
  12. // ...
  13. // predictionService, err := prediction.New(oauthHttpClient)
  14. package prediction // import "google.golang.org/api/prediction/v1.2"
  15. import (
  16. "bytes"
  17. "context"
  18. "encoding/json"
  19. "errors"
  20. "fmt"
  21. "io"
  22. "net/http"
  23. "net/url"
  24. "strconv"
  25. "strings"
  26. gensupport "google.golang.org/api/gensupport"
  27. googleapi "google.golang.org/api/googleapi"
  28. )
  29. // Always reference these packages, just in case the auto-generated code
  30. // below doesn't.
  31. var _ = bytes.NewBuffer
  32. var _ = strconv.Itoa
  33. var _ = fmt.Sprintf
  34. var _ = json.NewDecoder
  35. var _ = io.Copy
  36. var _ = url.Parse
  37. var _ = gensupport.MarshalJSON
  38. var _ = googleapi.Version
  39. var _ = errors.New
  40. var _ = strings.Replace
  41. var _ = context.Canceled
  42. const apiId = "prediction:v1.2"
  43. const apiName = "prediction"
  44. const apiVersion = "v1.2"
  45. const basePath = "https://www.googleapis.com/prediction/v1.2/"
  46. // OAuth2 scopes used by this API.
  47. const (
  48. // Manage your data and permissions in Google Cloud Storage
  49. DevstorageFullControlScope = "https://www.googleapis.com/auth/devstorage.full_control"
  50. // View your data in Google Cloud Storage
  51. DevstorageReadOnlyScope = "https://www.googleapis.com/auth/devstorage.read_only"
  52. // Manage your data in Google Cloud Storage
  53. DevstorageReadWriteScope = "https://www.googleapis.com/auth/devstorage.read_write"
  54. // Manage your data in the Google Prediction API
  55. PredictionScope = "https://www.googleapis.com/auth/prediction"
  56. )
  57. func New(client *http.Client) (*Service, error) {
  58. if client == nil {
  59. return nil, errors.New("client is nil")
  60. }
  61. s := &Service{client: client, BasePath: basePath}
  62. s.Hostedmodels = NewHostedmodelsService(s)
  63. s.Training = NewTrainingService(s)
  64. return s, nil
  65. }
  66. type Service struct {
  67. client *http.Client
  68. BasePath string // API endpoint base URL
  69. UserAgent string // optional additional User-Agent fragment
  70. Hostedmodels *HostedmodelsService
  71. Training *TrainingService
  72. }
  73. func (s *Service) userAgent() string {
  74. if s.UserAgent == "" {
  75. return googleapi.UserAgent
  76. }
  77. return googleapi.UserAgent + " " + s.UserAgent
  78. }
  79. func NewHostedmodelsService(s *Service) *HostedmodelsService {
  80. rs := &HostedmodelsService{s: s}
  81. return rs
  82. }
  83. type HostedmodelsService struct {
  84. s *Service
  85. }
  86. func NewTrainingService(s *Service) *TrainingService {
  87. rs := &TrainingService{s: s}
  88. return rs
  89. }
  90. type TrainingService struct {
  91. s *Service
  92. }
  93. type Input struct {
  94. Input *InputInput `json:"input,omitempty"`
  95. // ForceSendFields is a list of field names (e.g. "Input") to
  96. // unconditionally include in API requests. By default, fields with
  97. // empty values are omitted from API requests. However, any non-pointer,
  98. // non-interface field appearing in ForceSendFields will be sent to the
  99. // server regardless of whether the field is empty or not. This may be
  100. // used to include empty fields in Patch requests.
  101. ForceSendFields []string `json:"-"`
  102. // NullFields is a list of field names (e.g. "Input") to include in API
  103. // requests with the JSON null value. By default, fields with empty
  104. // values are omitted from API requests. However, any field with an
  105. // empty value appearing in NullFields will be sent to the server as
  106. // null. It is an error if a field in this list has a non-empty value.
  107. // This may be used to include null fields in Patch requests.
  108. NullFields []string `json:"-"`
  109. }
  110. func (s *Input) MarshalJSON() ([]byte, error) {
  111. type NoMethod Input
  112. raw := NoMethod(*s)
  113. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  114. }
  115. type InputInput struct {
  116. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  117. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  118. // unconditionally include in API requests. By default, fields with
  119. // empty values are omitted from API requests. However, any non-pointer,
  120. // non-interface field appearing in ForceSendFields will be sent to the
  121. // server regardless of whether the field is empty or not. This may be
  122. // used to include empty fields in Patch requests.
  123. ForceSendFields []string `json:"-"`
  124. // NullFields is a list of field names (e.g. "CsvInstance") to include
  125. // in API requests with the JSON null value. By default, fields with
  126. // empty values are omitted from API requests. However, any field with
  127. // an empty value appearing in NullFields will be sent to the server as
  128. // null. It is an error if a field in this list has a non-empty value.
  129. // This may be used to include null fields in Patch requests.
  130. NullFields []string `json:"-"`
  131. }
  132. func (s *InputInput) MarshalJSON() ([]byte, error) {
  133. type NoMethod InputInput
  134. raw := NoMethod(*s)
  135. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  136. }
  137. type Output struct {
  138. Id string `json:"id,omitempty"`
  139. Kind string `json:"kind,omitempty"`
  140. OutputLabel string `json:"outputLabel,omitempty"`
  141. OutputMulti []*OutputOutputMulti `json:"outputMulti,omitempty"`
  142. OutputValue float64 `json:"outputValue,omitempty"`
  143. SelfLink string `json:"selfLink,omitempty"`
  144. // ServerResponse contains the HTTP response code and headers from the
  145. // server.
  146. googleapi.ServerResponse `json:"-"`
  147. // ForceSendFields is a list of field names (e.g. "Id") to
  148. // unconditionally include in API requests. By default, fields with
  149. // empty values are omitted from API requests. However, any non-pointer,
  150. // non-interface field appearing in ForceSendFields will be sent to the
  151. // server regardless of whether the field is empty or not. This may be
  152. // used to include empty fields in Patch requests.
  153. ForceSendFields []string `json:"-"`
  154. // NullFields is a list of field names (e.g. "Id") to include in API
  155. // requests with the JSON null value. By default, fields with empty
  156. // values are omitted from API requests. However, any field with an
  157. // empty value appearing in NullFields will be sent to the server as
  158. // null. It is an error if a field in this list has a non-empty value.
  159. // This may be used to include null fields in Patch requests.
  160. NullFields []string `json:"-"`
  161. }
  162. func (s *Output) MarshalJSON() ([]byte, error) {
  163. type NoMethod Output
  164. raw := NoMethod(*s)
  165. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  166. }
  167. func (s *Output) UnmarshalJSON(data []byte) error {
  168. type NoMethod Output
  169. var s1 struct {
  170. OutputValue gensupport.JSONFloat64 `json:"outputValue"`
  171. *NoMethod
  172. }
  173. s1.NoMethod = (*NoMethod)(s)
  174. if err := json.Unmarshal(data, &s1); err != nil {
  175. return err
  176. }
  177. s.OutputValue = float64(s1.OutputValue)
  178. return nil
  179. }
  180. type OutputOutputMulti struct {
  181. Label string `json:"label,omitempty"`
  182. Score float64 `json:"score,omitempty"`
  183. // ForceSendFields is a list of field names (e.g. "Label") to
  184. // unconditionally include in API requests. By default, fields with
  185. // empty values are omitted from API requests. However, any non-pointer,
  186. // non-interface field appearing in ForceSendFields will be sent to the
  187. // server regardless of whether the field is empty or not. This may be
  188. // used to include empty fields in Patch requests.
  189. ForceSendFields []string `json:"-"`
  190. // NullFields is a list of field names (e.g. "Label") to include in API
  191. // requests with the JSON null value. By default, fields with empty
  192. // values are omitted from API requests. However, any field with an
  193. // empty value appearing in NullFields will be sent to the server as
  194. // null. It is an error if a field in this list has a non-empty value.
  195. // This may be used to include null fields in Patch requests.
  196. NullFields []string `json:"-"`
  197. }
  198. func (s *OutputOutputMulti) MarshalJSON() ([]byte, error) {
  199. type NoMethod OutputOutputMulti
  200. raw := NoMethod(*s)
  201. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  202. }
  203. func (s *OutputOutputMulti) UnmarshalJSON(data []byte) error {
  204. type NoMethod OutputOutputMulti
  205. var s1 struct {
  206. Score gensupport.JSONFloat64 `json:"score"`
  207. *NoMethod
  208. }
  209. s1.NoMethod = (*NoMethod)(s)
  210. if err := json.Unmarshal(data, &s1); err != nil {
  211. return err
  212. }
  213. s.Score = float64(s1.Score)
  214. return nil
  215. }
  216. type Training struct {
  217. Id string `json:"id,omitempty"`
  218. Kind string `json:"kind,omitempty"`
  219. ModelInfo *TrainingModelInfo `json:"modelInfo,omitempty"`
  220. SelfLink string `json:"selfLink,omitempty"`
  221. TrainingStatus string `json:"trainingStatus,omitempty"`
  222. // ServerResponse contains the HTTP response code and headers from the
  223. // server.
  224. googleapi.ServerResponse `json:"-"`
  225. // ForceSendFields is a list of field names (e.g. "Id") to
  226. // unconditionally include in API requests. By default, fields with
  227. // empty values are omitted from API requests. However, any non-pointer,
  228. // non-interface field appearing in ForceSendFields will be sent to the
  229. // server regardless of whether the field is empty or not. This may be
  230. // used to include empty fields in Patch requests.
  231. ForceSendFields []string `json:"-"`
  232. // NullFields is a list of field names (e.g. "Id") to include in API
  233. // requests with the JSON null value. By default, fields with empty
  234. // values are omitted from API requests. However, any field with an
  235. // empty value appearing in NullFields will be sent to the server as
  236. // null. It is an error if a field in this list has a non-empty value.
  237. // This may be used to include null fields in Patch requests.
  238. NullFields []string `json:"-"`
  239. }
  240. func (s *Training) MarshalJSON() ([]byte, error) {
  241. type NoMethod Training
  242. raw := NoMethod(*s)
  243. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  244. }
  245. type TrainingModelInfo struct {
  246. ClassificationAccuracy float64 `json:"classificationAccuracy,omitempty"`
  247. MeanSquaredError float64 `json:"meanSquaredError,omitempty"`
  248. ModelType string `json:"modelType,omitempty"`
  249. // ForceSendFields is a list of field names (e.g.
  250. // "ClassificationAccuracy") to unconditionally include in API requests.
  251. // By default, fields with empty values are omitted from API requests.
  252. // However, any non-pointer, non-interface field appearing in
  253. // ForceSendFields will be sent to the server regardless of whether the
  254. // field is empty or not. This may be used to include empty fields in
  255. // Patch requests.
  256. ForceSendFields []string `json:"-"`
  257. // NullFields is a list of field names (e.g. "ClassificationAccuracy")
  258. // to include in API requests with the JSON null value. By default,
  259. // fields with empty values are omitted from API requests. However, any
  260. // field with an empty value appearing in NullFields will be sent to the
  261. // server as null. It is an error if a field in this list has a
  262. // non-empty value. This may be used to include null fields in Patch
  263. // requests.
  264. NullFields []string `json:"-"`
  265. }
  266. func (s *TrainingModelInfo) MarshalJSON() ([]byte, error) {
  267. type NoMethod TrainingModelInfo
  268. raw := NoMethod(*s)
  269. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  270. }
  271. func (s *TrainingModelInfo) UnmarshalJSON(data []byte) error {
  272. type NoMethod TrainingModelInfo
  273. var s1 struct {
  274. ClassificationAccuracy gensupport.JSONFloat64 `json:"classificationAccuracy"`
  275. MeanSquaredError gensupport.JSONFloat64 `json:"meanSquaredError"`
  276. *NoMethod
  277. }
  278. s1.NoMethod = (*NoMethod)(s)
  279. if err := json.Unmarshal(data, &s1); err != nil {
  280. return err
  281. }
  282. s.ClassificationAccuracy = float64(s1.ClassificationAccuracy)
  283. s.MeanSquaredError = float64(s1.MeanSquaredError)
  284. return nil
  285. }
  286. type Update struct {
  287. // ClassLabel: The true class label of this instance
  288. ClassLabel string `json:"classLabel,omitempty"`
  289. // CsvInstance: The input features for this instance
  290. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  291. // ForceSendFields is a list of field names (e.g. "ClassLabel") to
  292. // unconditionally include in API requests. By default, fields with
  293. // empty values are omitted from API requests. However, any non-pointer,
  294. // non-interface field appearing in ForceSendFields will be sent to the
  295. // server regardless of whether the field is empty or not. This may be
  296. // used to include empty fields in Patch requests.
  297. ForceSendFields []string `json:"-"`
  298. // NullFields is a list of field names (e.g. "ClassLabel") to include in
  299. // API requests with the JSON null value. By default, fields with empty
  300. // values are omitted from API requests. However, any field with an
  301. // empty value appearing in NullFields will be sent to the server as
  302. // null. It is an error if a field in this list has a non-empty value.
  303. // This may be used to include null fields in Patch requests.
  304. NullFields []string `json:"-"`
  305. }
  306. func (s *Update) MarshalJSON() ([]byte, error) {
  307. type NoMethod Update
  308. raw := NoMethod(*s)
  309. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  310. }
  311. // method id "prediction.predict":
  312. type PredictCall struct {
  313. s *Service
  314. data string
  315. input *Input
  316. urlParams_ gensupport.URLParams
  317. ctx_ context.Context
  318. header_ http.Header
  319. }
  320. // Predict: Submit data and request a prediction
  321. func (s *Service) Predict(data string, input *Input) *PredictCall {
  322. c := &PredictCall{s: s, urlParams_: make(gensupport.URLParams)}
  323. c.data = data
  324. c.input = input
  325. return c
  326. }
  327. // Fields allows partial responses to be retrieved. See
  328. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  329. // for more information.
  330. func (c *PredictCall) Fields(s ...googleapi.Field) *PredictCall {
  331. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  332. return c
  333. }
  334. // Context sets the context to be used in this call's Do method. Any
  335. // pending HTTP request will be aborted if the provided context is
  336. // canceled.
  337. func (c *PredictCall) Context(ctx context.Context) *PredictCall {
  338. c.ctx_ = ctx
  339. return c
  340. }
  341. // Header returns an http.Header that can be modified by the caller to
  342. // add HTTP headers to the request.
  343. func (c *PredictCall) Header() http.Header {
  344. if c.header_ == nil {
  345. c.header_ = make(http.Header)
  346. }
  347. return c.header_
  348. }
  349. func (c *PredictCall) doRequest(alt string) (*http.Response, error) {
  350. reqHeaders := make(http.Header)
  351. for k, v := range c.header_ {
  352. reqHeaders[k] = v
  353. }
  354. reqHeaders.Set("User-Agent", c.s.userAgent())
  355. var body io.Reader = nil
  356. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  357. if err != nil {
  358. return nil, err
  359. }
  360. reqHeaders.Set("Content-Type", "application/json")
  361. c.urlParams_.Set("alt", alt)
  362. urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}/predict")
  363. urls += "?" + c.urlParams_.Encode()
  364. req, _ := http.NewRequest("POST", urls, body)
  365. req.Header = reqHeaders
  366. googleapi.Expand(req.URL, map[string]string{
  367. "data": c.data,
  368. })
  369. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  370. }
  371. // Do executes the "prediction.predict" call.
  372. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  373. // code is an error. Response headers are in either
  374. // *Output.ServerResponse.Header or (if a response was returned at all)
  375. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  376. // check whether the returned error was because http.StatusNotModified
  377. // was returned.
  378. func (c *PredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  379. gensupport.SetOptions(c.urlParams_, opts...)
  380. res, err := c.doRequest("json")
  381. if res != nil && res.StatusCode == http.StatusNotModified {
  382. if res.Body != nil {
  383. res.Body.Close()
  384. }
  385. return nil, &googleapi.Error{
  386. Code: res.StatusCode,
  387. Header: res.Header,
  388. }
  389. }
  390. if err != nil {
  391. return nil, err
  392. }
  393. defer googleapi.CloseBody(res)
  394. if err := googleapi.CheckResponse(res); err != nil {
  395. return nil, err
  396. }
  397. ret := &Output{
  398. ServerResponse: googleapi.ServerResponse{
  399. Header: res.Header,
  400. HTTPStatusCode: res.StatusCode,
  401. },
  402. }
  403. target := &ret
  404. if err := gensupport.DecodeResponse(target, res); err != nil {
  405. return nil, err
  406. }
  407. return ret, nil
  408. // {
  409. // "description": "Submit data and request a prediction",
  410. // "httpMethod": "POST",
  411. // "id": "prediction.predict",
  412. // "parameterOrder": [
  413. // "data"
  414. // ],
  415. // "parameters": {
  416. // "data": {
  417. // "description": "mybucket%2Fmydata resource in Google Storage",
  418. // "location": "path",
  419. // "required": true,
  420. // "type": "string"
  421. // }
  422. // },
  423. // "path": "training/{data}/predict",
  424. // "request": {
  425. // "$ref": "Input"
  426. // },
  427. // "response": {
  428. // "$ref": "Output"
  429. // },
  430. // "scopes": [
  431. // "https://www.googleapis.com/auth/prediction"
  432. // ]
  433. // }
  434. }
  435. // method id "prediction.hostedmodels.predict":
  436. type HostedmodelsPredictCall struct {
  437. s *Service
  438. hostedModelName string
  439. input *Input
  440. urlParams_ gensupport.URLParams
  441. ctx_ context.Context
  442. header_ http.Header
  443. }
  444. // Predict: Submit input and request an output against a hosted model
  445. func (r *HostedmodelsService) Predict(hostedModelName string, input *Input) *HostedmodelsPredictCall {
  446. c := &HostedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  447. c.hostedModelName = hostedModelName
  448. c.input = input
  449. return c
  450. }
  451. // Fields allows partial responses to be retrieved. See
  452. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  453. // for more information.
  454. func (c *HostedmodelsPredictCall) Fields(s ...googleapi.Field) *HostedmodelsPredictCall {
  455. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  456. return c
  457. }
  458. // Context sets the context to be used in this call's Do method. Any
  459. // pending HTTP request will be aborted if the provided context is
  460. // canceled.
  461. func (c *HostedmodelsPredictCall) Context(ctx context.Context) *HostedmodelsPredictCall {
  462. c.ctx_ = ctx
  463. return c
  464. }
  465. // Header returns an http.Header that can be modified by the caller to
  466. // add HTTP headers to the request.
  467. func (c *HostedmodelsPredictCall) Header() http.Header {
  468. if c.header_ == nil {
  469. c.header_ = make(http.Header)
  470. }
  471. return c.header_
  472. }
  473. func (c *HostedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  474. reqHeaders := make(http.Header)
  475. for k, v := range c.header_ {
  476. reqHeaders[k] = v
  477. }
  478. reqHeaders.Set("User-Agent", c.s.userAgent())
  479. var body io.Reader = nil
  480. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  481. if err != nil {
  482. return nil, err
  483. }
  484. reqHeaders.Set("Content-Type", "application/json")
  485. c.urlParams_.Set("alt", alt)
  486. urls := googleapi.ResolveRelative(c.s.BasePath, "hostedmodels/{hostedModelName}/predict")
  487. urls += "?" + c.urlParams_.Encode()
  488. req, _ := http.NewRequest("POST", urls, body)
  489. req.Header = reqHeaders
  490. googleapi.Expand(req.URL, map[string]string{
  491. "hostedModelName": c.hostedModelName,
  492. })
  493. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  494. }
  495. // Do executes the "prediction.hostedmodels.predict" call.
  496. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  497. // code is an error. Response headers are in either
  498. // *Output.ServerResponse.Header or (if a response was returned at all)
  499. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  500. // check whether the returned error was because http.StatusNotModified
  501. // was returned.
  502. func (c *HostedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  503. gensupport.SetOptions(c.urlParams_, opts...)
  504. res, err := c.doRequest("json")
  505. if res != nil && res.StatusCode == http.StatusNotModified {
  506. if res.Body != nil {
  507. res.Body.Close()
  508. }
  509. return nil, &googleapi.Error{
  510. Code: res.StatusCode,
  511. Header: res.Header,
  512. }
  513. }
  514. if err != nil {
  515. return nil, err
  516. }
  517. defer googleapi.CloseBody(res)
  518. if err := googleapi.CheckResponse(res); err != nil {
  519. return nil, err
  520. }
  521. ret := &Output{
  522. ServerResponse: googleapi.ServerResponse{
  523. Header: res.Header,
  524. HTTPStatusCode: res.StatusCode,
  525. },
  526. }
  527. target := &ret
  528. if err := gensupport.DecodeResponse(target, res); err != nil {
  529. return nil, err
  530. }
  531. return ret, nil
  532. // {
  533. // "description": "Submit input and request an output against a hosted model",
  534. // "httpMethod": "POST",
  535. // "id": "prediction.hostedmodels.predict",
  536. // "parameterOrder": [
  537. // "hostedModelName"
  538. // ],
  539. // "parameters": {
  540. // "hostedModelName": {
  541. // "description": "The name of a hosted model",
  542. // "location": "path",
  543. // "required": true,
  544. // "type": "string"
  545. // }
  546. // },
  547. // "path": "hostedmodels/{hostedModelName}/predict",
  548. // "request": {
  549. // "$ref": "Input"
  550. // },
  551. // "response": {
  552. // "$ref": "Output"
  553. // },
  554. // "scopes": [
  555. // "https://www.googleapis.com/auth/prediction"
  556. // ]
  557. // }
  558. }
  559. // method id "prediction.training.delete":
  560. type TrainingDeleteCall struct {
  561. s *Service
  562. data string
  563. urlParams_ gensupport.URLParams
  564. ctx_ context.Context
  565. header_ http.Header
  566. }
  567. // Delete: Delete a trained model
  568. func (r *TrainingService) Delete(data string) *TrainingDeleteCall {
  569. c := &TrainingDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  570. c.data = data
  571. return c
  572. }
  573. // Fields allows partial responses to be retrieved. See
  574. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  575. // for more information.
  576. func (c *TrainingDeleteCall) Fields(s ...googleapi.Field) *TrainingDeleteCall {
  577. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  578. return c
  579. }
  580. // Context sets the context to be used in this call's Do method. Any
  581. // pending HTTP request will be aborted if the provided context is
  582. // canceled.
  583. func (c *TrainingDeleteCall) Context(ctx context.Context) *TrainingDeleteCall {
  584. c.ctx_ = ctx
  585. return c
  586. }
  587. // Header returns an http.Header that can be modified by the caller to
  588. // add HTTP headers to the request.
  589. func (c *TrainingDeleteCall) Header() http.Header {
  590. if c.header_ == nil {
  591. c.header_ = make(http.Header)
  592. }
  593. return c.header_
  594. }
  595. func (c *TrainingDeleteCall) doRequest(alt string) (*http.Response, error) {
  596. reqHeaders := make(http.Header)
  597. for k, v := range c.header_ {
  598. reqHeaders[k] = v
  599. }
  600. reqHeaders.Set("User-Agent", c.s.userAgent())
  601. var body io.Reader = nil
  602. c.urlParams_.Set("alt", alt)
  603. urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}")
  604. urls += "?" + c.urlParams_.Encode()
  605. req, _ := http.NewRequest("DELETE", urls, body)
  606. req.Header = reqHeaders
  607. googleapi.Expand(req.URL, map[string]string{
  608. "data": c.data,
  609. })
  610. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  611. }
  612. // Do executes the "prediction.training.delete" call.
  613. func (c *TrainingDeleteCall) Do(opts ...googleapi.CallOption) error {
  614. gensupport.SetOptions(c.urlParams_, opts...)
  615. res, err := c.doRequest("json")
  616. if err != nil {
  617. return err
  618. }
  619. defer googleapi.CloseBody(res)
  620. if err := googleapi.CheckResponse(res); err != nil {
  621. return err
  622. }
  623. return nil
  624. // {
  625. // "description": "Delete a trained model",
  626. // "httpMethod": "DELETE",
  627. // "id": "prediction.training.delete",
  628. // "parameterOrder": [
  629. // "data"
  630. // ],
  631. // "parameters": {
  632. // "data": {
  633. // "description": "mybucket/mydata resource in Google Storage",
  634. // "location": "path",
  635. // "required": true,
  636. // "type": "string"
  637. // }
  638. // },
  639. // "path": "training/{data}",
  640. // "scopes": [
  641. // "https://www.googleapis.com/auth/prediction"
  642. // ]
  643. // }
  644. }
  645. // method id "prediction.training.get":
  646. type TrainingGetCall struct {
  647. s *Service
  648. data string
  649. urlParams_ gensupport.URLParams
  650. ifNoneMatch_ string
  651. ctx_ context.Context
  652. header_ http.Header
  653. }
  654. // Get: Check training status of your model
  655. func (r *TrainingService) Get(data string) *TrainingGetCall {
  656. c := &TrainingGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  657. c.data = data
  658. return c
  659. }
  660. // Fields allows partial responses to be retrieved. See
  661. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  662. // for more information.
  663. func (c *TrainingGetCall) Fields(s ...googleapi.Field) *TrainingGetCall {
  664. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  665. return c
  666. }
  667. // IfNoneMatch sets the optional parameter which makes the operation
  668. // fail if the object's ETag matches the given value. This is useful for
  669. // getting updates only after the object has changed since the last
  670. // request. Use googleapi.IsNotModified to check whether the response
  671. // error from Do is the result of In-None-Match.
  672. func (c *TrainingGetCall) IfNoneMatch(entityTag string) *TrainingGetCall {
  673. c.ifNoneMatch_ = entityTag
  674. return c
  675. }
  676. // Context sets the context to be used in this call's Do method. Any
  677. // pending HTTP request will be aborted if the provided context is
  678. // canceled.
  679. func (c *TrainingGetCall) Context(ctx context.Context) *TrainingGetCall {
  680. c.ctx_ = ctx
  681. return c
  682. }
  683. // Header returns an http.Header that can be modified by the caller to
  684. // add HTTP headers to the request.
  685. func (c *TrainingGetCall) Header() http.Header {
  686. if c.header_ == nil {
  687. c.header_ = make(http.Header)
  688. }
  689. return c.header_
  690. }
  691. func (c *TrainingGetCall) doRequest(alt string) (*http.Response, error) {
  692. reqHeaders := make(http.Header)
  693. for k, v := range c.header_ {
  694. reqHeaders[k] = v
  695. }
  696. reqHeaders.Set("User-Agent", c.s.userAgent())
  697. if c.ifNoneMatch_ != "" {
  698. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  699. }
  700. var body io.Reader = nil
  701. c.urlParams_.Set("alt", alt)
  702. urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}")
  703. urls += "?" + c.urlParams_.Encode()
  704. req, _ := http.NewRequest("GET", urls, body)
  705. req.Header = reqHeaders
  706. googleapi.Expand(req.URL, map[string]string{
  707. "data": c.data,
  708. })
  709. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  710. }
  711. // Do executes the "prediction.training.get" call.
  712. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  713. // code is an error. Response headers are in either
  714. // *Training.ServerResponse.Header or (if a response was returned at
  715. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  716. // to check whether the returned error was because
  717. // http.StatusNotModified was returned.
  718. func (c *TrainingGetCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  719. gensupport.SetOptions(c.urlParams_, opts...)
  720. res, err := c.doRequest("json")
  721. if res != nil && res.StatusCode == http.StatusNotModified {
  722. if res.Body != nil {
  723. res.Body.Close()
  724. }
  725. return nil, &googleapi.Error{
  726. Code: res.StatusCode,
  727. Header: res.Header,
  728. }
  729. }
  730. if err != nil {
  731. return nil, err
  732. }
  733. defer googleapi.CloseBody(res)
  734. if err := googleapi.CheckResponse(res); err != nil {
  735. return nil, err
  736. }
  737. ret := &Training{
  738. ServerResponse: googleapi.ServerResponse{
  739. Header: res.Header,
  740. HTTPStatusCode: res.StatusCode,
  741. },
  742. }
  743. target := &ret
  744. if err := gensupport.DecodeResponse(target, res); err != nil {
  745. return nil, err
  746. }
  747. return ret, nil
  748. // {
  749. // "description": "Check training status of your model",
  750. // "httpMethod": "GET",
  751. // "id": "prediction.training.get",
  752. // "parameterOrder": [
  753. // "data"
  754. // ],
  755. // "parameters": {
  756. // "data": {
  757. // "description": "mybucket/mydata resource in Google Storage",
  758. // "location": "path",
  759. // "required": true,
  760. // "type": "string"
  761. // }
  762. // },
  763. // "path": "training/{data}",
  764. // "response": {
  765. // "$ref": "Training"
  766. // },
  767. // "scopes": [
  768. // "https://www.googleapis.com/auth/prediction"
  769. // ]
  770. // }
  771. }
  772. // method id "prediction.training.insert":
  773. type TrainingInsertCall struct {
  774. s *Service
  775. training *Training
  776. urlParams_ gensupport.URLParams
  777. ctx_ context.Context
  778. header_ http.Header
  779. }
  780. // Insert: Begin training your model
  781. func (r *TrainingService) Insert(training *Training) *TrainingInsertCall {
  782. c := &TrainingInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  783. c.training = training
  784. return c
  785. }
  786. // Data sets the optional parameter "data": mybucket/mydata resource in
  787. // Google Storage
  788. func (c *TrainingInsertCall) Data(data string) *TrainingInsertCall {
  789. c.urlParams_.Set("data", data)
  790. return c
  791. }
  792. // Fields allows partial responses to be retrieved. See
  793. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  794. // for more information.
  795. func (c *TrainingInsertCall) Fields(s ...googleapi.Field) *TrainingInsertCall {
  796. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  797. return c
  798. }
  799. // Context sets the context to be used in this call's Do method. Any
  800. // pending HTTP request will be aborted if the provided context is
  801. // canceled.
  802. func (c *TrainingInsertCall) Context(ctx context.Context) *TrainingInsertCall {
  803. c.ctx_ = ctx
  804. return c
  805. }
  806. // Header returns an http.Header that can be modified by the caller to
  807. // add HTTP headers to the request.
  808. func (c *TrainingInsertCall) Header() http.Header {
  809. if c.header_ == nil {
  810. c.header_ = make(http.Header)
  811. }
  812. return c.header_
  813. }
  814. func (c *TrainingInsertCall) doRequest(alt string) (*http.Response, error) {
  815. reqHeaders := make(http.Header)
  816. for k, v := range c.header_ {
  817. reqHeaders[k] = v
  818. }
  819. reqHeaders.Set("User-Agent", c.s.userAgent())
  820. var body io.Reader = nil
  821. body, err := googleapi.WithoutDataWrapper.JSONReader(c.training)
  822. if err != nil {
  823. return nil, err
  824. }
  825. reqHeaders.Set("Content-Type", "application/json")
  826. c.urlParams_.Set("alt", alt)
  827. urls := googleapi.ResolveRelative(c.s.BasePath, "training")
  828. urls += "?" + c.urlParams_.Encode()
  829. req, _ := http.NewRequest("POST", urls, body)
  830. req.Header = reqHeaders
  831. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  832. }
  833. // Do executes the "prediction.training.insert" call.
  834. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  835. // code is an error. Response headers are in either
  836. // *Training.ServerResponse.Header or (if a response was returned at
  837. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  838. // to check whether the returned error was because
  839. // http.StatusNotModified was returned.
  840. func (c *TrainingInsertCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  841. gensupport.SetOptions(c.urlParams_, opts...)
  842. res, err := c.doRequest("json")
  843. if res != nil && res.StatusCode == http.StatusNotModified {
  844. if res.Body != nil {
  845. res.Body.Close()
  846. }
  847. return nil, &googleapi.Error{
  848. Code: res.StatusCode,
  849. Header: res.Header,
  850. }
  851. }
  852. if err != nil {
  853. return nil, err
  854. }
  855. defer googleapi.CloseBody(res)
  856. if err := googleapi.CheckResponse(res); err != nil {
  857. return nil, err
  858. }
  859. ret := &Training{
  860. ServerResponse: googleapi.ServerResponse{
  861. Header: res.Header,
  862. HTTPStatusCode: res.StatusCode,
  863. },
  864. }
  865. target := &ret
  866. if err := gensupport.DecodeResponse(target, res); err != nil {
  867. return nil, err
  868. }
  869. return ret, nil
  870. // {
  871. // "description": "Begin training your model",
  872. // "httpMethod": "POST",
  873. // "id": "prediction.training.insert",
  874. // "parameters": {
  875. // "data": {
  876. // "description": "mybucket/mydata resource in Google Storage",
  877. // "location": "query",
  878. // "type": "string"
  879. // }
  880. // },
  881. // "path": "training",
  882. // "request": {
  883. // "$ref": "Training"
  884. // },
  885. // "response": {
  886. // "$ref": "Training"
  887. // },
  888. // "scopes": [
  889. // "https://www.googleapis.com/auth/devstorage.full_control",
  890. // "https://www.googleapis.com/auth/devstorage.read_only",
  891. // "https://www.googleapis.com/auth/devstorage.read_write",
  892. // "https://www.googleapis.com/auth/prediction"
  893. // ]
  894. // }
  895. }
  896. // method id "prediction.training.update":
  897. type TrainingUpdateCall struct {
  898. s *Service
  899. data string
  900. update *Update
  901. urlParams_ gensupport.URLParams
  902. ctx_ context.Context
  903. header_ http.Header
  904. }
  905. // Update: Add new data to a trained model
  906. func (r *TrainingService) Update(data string, update *Update) *TrainingUpdateCall {
  907. c := &TrainingUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  908. c.data = data
  909. c.update = update
  910. return c
  911. }
  912. // Fields allows partial responses to be retrieved. See
  913. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  914. // for more information.
  915. func (c *TrainingUpdateCall) Fields(s ...googleapi.Field) *TrainingUpdateCall {
  916. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  917. return c
  918. }
  919. // Context sets the context to be used in this call's Do method. Any
  920. // pending HTTP request will be aborted if the provided context is
  921. // canceled.
  922. func (c *TrainingUpdateCall) Context(ctx context.Context) *TrainingUpdateCall {
  923. c.ctx_ = ctx
  924. return c
  925. }
  926. // Header returns an http.Header that can be modified by the caller to
  927. // add HTTP headers to the request.
  928. func (c *TrainingUpdateCall) Header() http.Header {
  929. if c.header_ == nil {
  930. c.header_ = make(http.Header)
  931. }
  932. return c.header_
  933. }
  934. func (c *TrainingUpdateCall) doRequest(alt string) (*http.Response, error) {
  935. reqHeaders := make(http.Header)
  936. for k, v := range c.header_ {
  937. reqHeaders[k] = v
  938. }
  939. reqHeaders.Set("User-Agent", c.s.userAgent())
  940. var body io.Reader = nil
  941. body, err := googleapi.WithoutDataWrapper.JSONReader(c.update)
  942. if err != nil {
  943. return nil, err
  944. }
  945. reqHeaders.Set("Content-Type", "application/json")
  946. c.urlParams_.Set("alt", alt)
  947. urls := googleapi.ResolveRelative(c.s.BasePath, "training/{data}")
  948. urls += "?" + c.urlParams_.Encode()
  949. req, _ := http.NewRequest("PUT", urls, body)
  950. req.Header = reqHeaders
  951. googleapi.Expand(req.URL, map[string]string{
  952. "data": c.data,
  953. })
  954. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  955. }
  956. // Do executes the "prediction.training.update" call.
  957. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  958. // code is an error. Response headers are in either
  959. // *Training.ServerResponse.Header or (if a response was returned at
  960. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  961. // to check whether the returned error was because
  962. // http.StatusNotModified was returned.
  963. func (c *TrainingUpdateCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  964. gensupport.SetOptions(c.urlParams_, opts...)
  965. res, err := c.doRequest("json")
  966. if res != nil && res.StatusCode == http.StatusNotModified {
  967. if res.Body != nil {
  968. res.Body.Close()
  969. }
  970. return nil, &googleapi.Error{
  971. Code: res.StatusCode,
  972. Header: res.Header,
  973. }
  974. }
  975. if err != nil {
  976. return nil, err
  977. }
  978. defer googleapi.CloseBody(res)
  979. if err := googleapi.CheckResponse(res); err != nil {
  980. return nil, err
  981. }
  982. ret := &Training{
  983. ServerResponse: googleapi.ServerResponse{
  984. Header: res.Header,
  985. HTTPStatusCode: res.StatusCode,
  986. },
  987. }
  988. target := &ret
  989. if err := gensupport.DecodeResponse(target, res); err != nil {
  990. return nil, err
  991. }
  992. return ret, nil
  993. // {
  994. // "description": "Add new data to a trained model",
  995. // "httpMethod": "PUT",
  996. // "id": "prediction.training.update",
  997. // "parameterOrder": [
  998. // "data"
  999. // ],
  1000. // "parameters": {
  1001. // "data": {
  1002. // "description": "mybucket/mydata resource in Google Storage",
  1003. // "location": "path",
  1004. // "required": true,
  1005. // "type": "string"
  1006. // }
  1007. // },
  1008. // "path": "training/{data}",
  1009. // "request": {
  1010. // "$ref": "Update"
  1011. // },
  1012. // "response": {
  1013. // "$ref": "Training"
  1014. // },
  1015. // "scopes": [
  1016. // "https://www.googleapis.com/auth/prediction"
  1017. // ]
  1018. // }
  1019. }