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.
 
 
 

1233 lines
39 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.4"
  12. // ...
  13. // predictionService, err := prediction.New(oauthHttpClient)
  14. package prediction // import "google.golang.org/api/prediction/v1.4"
  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.4"
  43. const apiName = "prediction"
  44. const apiVersion = "v1.4"
  45. const basePath = "https://www.googleapis.com/prediction/v1.4/"
  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.Trainedmodels = NewTrainedmodelsService(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. Trainedmodels *TrainedmodelsService
  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 NewTrainedmodelsService(s *Service) *TrainedmodelsService {
  87. rs := &TrainedmodelsService{s: s}
  88. return rs
  89. }
  90. type TrainedmodelsService struct {
  91. s *Service
  92. }
  93. type Input struct {
  94. // Input: Input to the model for a prediction
  95. Input *InputInput `json:"input,omitempty"`
  96. // ForceSendFields is a list of field names (e.g. "Input") to
  97. // unconditionally include in API requests. By default, fields with
  98. // empty values are omitted from API requests. However, any non-pointer,
  99. // non-interface field appearing in ForceSendFields will be sent to the
  100. // server regardless of whether the field is empty or not. This may be
  101. // used to include empty fields in Patch requests.
  102. ForceSendFields []string `json:"-"`
  103. // NullFields is a list of field names (e.g. "Input") to include in API
  104. // requests with the JSON null value. By default, fields with empty
  105. // values are omitted from API requests. However, any field with an
  106. // empty value appearing in NullFields will be sent to the server as
  107. // null. It is an error if a field in this list has a non-empty value.
  108. // This may be used to include null fields in Patch requests.
  109. NullFields []string `json:"-"`
  110. }
  111. func (s *Input) MarshalJSON() ([]byte, error) {
  112. type NoMethod Input
  113. raw := NoMethod(*s)
  114. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  115. }
  116. // InputInput: Input to the model for a prediction
  117. type InputInput struct {
  118. // CsvInstance: A list of input features, these can be strings or
  119. // doubles.
  120. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  121. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  122. // unconditionally include in API requests. By default, fields with
  123. // empty values are omitted from API requests. However, any non-pointer,
  124. // non-interface field appearing in ForceSendFields will be sent to the
  125. // server regardless of whether the field is empty or not. This may be
  126. // used to include empty fields in Patch requests.
  127. ForceSendFields []string `json:"-"`
  128. // NullFields is a list of field names (e.g. "CsvInstance") to include
  129. // in API requests with the JSON null value. By default, fields with
  130. // empty values are omitted from API requests. However, any field with
  131. // an empty value appearing in NullFields will be sent to the server as
  132. // null. It is an error if a field in this list has a non-empty value.
  133. // This may be used to include null fields in Patch requests.
  134. NullFields []string `json:"-"`
  135. }
  136. func (s *InputInput) MarshalJSON() ([]byte, error) {
  137. type NoMethod InputInput
  138. raw := NoMethod(*s)
  139. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  140. }
  141. type Output struct {
  142. // Id: The unique name for the predictive model.
  143. Id string `json:"id,omitempty"`
  144. // Kind: What kind of resource this is.
  145. Kind string `json:"kind,omitempty"`
  146. // OutputLabel: The most likely class label [Categorical models only].
  147. OutputLabel string `json:"outputLabel,omitempty"`
  148. // OutputMulti: A list of class labels with their estimated
  149. // probabilities [Categorical models only].
  150. OutputMulti []*OutputOutputMulti `json:"outputMulti,omitempty"`
  151. // OutputValue: The estimated regression value [Regression models only].
  152. OutputValue float64 `json:"outputValue,omitempty"`
  153. // SelfLink: A URL to re-request this resource.
  154. SelfLink string `json:"selfLink,omitempty"`
  155. // ServerResponse contains the HTTP response code and headers from the
  156. // server.
  157. googleapi.ServerResponse `json:"-"`
  158. // ForceSendFields is a list of field names (e.g. "Id") to
  159. // unconditionally include in API requests. By default, fields with
  160. // empty values are omitted from API requests. However, any non-pointer,
  161. // non-interface field appearing in ForceSendFields will be sent to the
  162. // server regardless of whether the field is empty or not. This may be
  163. // used to include empty fields in Patch requests.
  164. ForceSendFields []string `json:"-"`
  165. // NullFields is a list of field names (e.g. "Id") to include in API
  166. // requests with the JSON null value. By default, fields with empty
  167. // values are omitted from API requests. However, any field with an
  168. // empty value appearing in NullFields will be sent to the server as
  169. // null. It is an error if a field in this list has a non-empty value.
  170. // This may be used to include null fields in Patch requests.
  171. NullFields []string `json:"-"`
  172. }
  173. func (s *Output) MarshalJSON() ([]byte, error) {
  174. type NoMethod Output
  175. raw := NoMethod(*s)
  176. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  177. }
  178. func (s *Output) UnmarshalJSON(data []byte) error {
  179. type NoMethod Output
  180. var s1 struct {
  181. OutputValue gensupport.JSONFloat64 `json:"outputValue"`
  182. *NoMethod
  183. }
  184. s1.NoMethod = (*NoMethod)(s)
  185. if err := json.Unmarshal(data, &s1); err != nil {
  186. return err
  187. }
  188. s.OutputValue = float64(s1.OutputValue)
  189. return nil
  190. }
  191. type OutputOutputMulti struct {
  192. // Label: The class label.
  193. Label string `json:"label,omitempty"`
  194. // Score: The probability of the class label.
  195. Score float64 `json:"score,omitempty"`
  196. // ForceSendFields is a list of field names (e.g. "Label") to
  197. // unconditionally include in API requests. By default, fields with
  198. // empty values are omitted from API requests. However, any non-pointer,
  199. // non-interface field appearing in ForceSendFields will be sent to the
  200. // server regardless of whether the field is empty or not. This may be
  201. // used to include empty fields in Patch requests.
  202. ForceSendFields []string `json:"-"`
  203. // NullFields is a list of field names (e.g. "Label") to include in API
  204. // requests with the JSON null value. By default, fields with empty
  205. // values are omitted from API requests. However, any field with an
  206. // empty value appearing in NullFields will be sent to the server as
  207. // null. It is an error if a field in this list has a non-empty value.
  208. // This may be used to include null fields in Patch requests.
  209. NullFields []string `json:"-"`
  210. }
  211. func (s *OutputOutputMulti) MarshalJSON() ([]byte, error) {
  212. type NoMethod OutputOutputMulti
  213. raw := NoMethod(*s)
  214. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  215. }
  216. func (s *OutputOutputMulti) UnmarshalJSON(data []byte) error {
  217. type NoMethod OutputOutputMulti
  218. var s1 struct {
  219. Score gensupport.JSONFloat64 `json:"score"`
  220. *NoMethod
  221. }
  222. s1.NoMethod = (*NoMethod)(s)
  223. if err := json.Unmarshal(data, &s1); err != nil {
  224. return err
  225. }
  226. s.Score = float64(s1.Score)
  227. return nil
  228. }
  229. type Training struct {
  230. // DataAnalysis: Data Analysis.
  231. DataAnalysis *TrainingDataAnalysis `json:"dataAnalysis,omitempty"`
  232. // Id: The unique name for the predictive model.
  233. Id string `json:"id,omitempty"`
  234. // Kind: What kind of resource this is.
  235. Kind string `json:"kind,omitempty"`
  236. // ModelInfo: Model metadata.
  237. ModelInfo *TrainingModelInfo `json:"modelInfo,omitempty"`
  238. // SelfLink: A URL to re-request this resource.
  239. SelfLink string `json:"selfLink,omitempty"`
  240. // StorageDataLocation: Google storage location of the training data
  241. // file.
  242. StorageDataLocation string `json:"storageDataLocation,omitempty"`
  243. // StoragePMMLLocation: Google storage location of the preprocessing
  244. // pmml file.
  245. StoragePMMLLocation string `json:"storagePMMLLocation,omitempty"`
  246. // StoragePMMLModelLocation: Google storage location of the pmml model
  247. // file.
  248. StoragePMMLModelLocation string `json:"storagePMMLModelLocation,omitempty"`
  249. // TrainingStatus: The current status of the training job. This can be
  250. // one of following: RUNNING; DONE; ERROR; ERROR: TRAINING JOB NOT FOUND
  251. TrainingStatus string `json:"trainingStatus,omitempty"`
  252. // Utility: A class weighting function, which allows the importance
  253. // weights for class labels to be specified [Categorical models only].
  254. Utility []map[string]float64 `json:"utility,omitempty"`
  255. // ServerResponse contains the HTTP response code and headers from the
  256. // server.
  257. googleapi.ServerResponse `json:"-"`
  258. // ForceSendFields is a list of field names (e.g. "DataAnalysis") to
  259. // unconditionally include in API requests. By default, fields with
  260. // empty values are omitted from API requests. However, any non-pointer,
  261. // non-interface field appearing in ForceSendFields will be sent to the
  262. // server regardless of whether the field is empty or not. This may be
  263. // used to include empty fields in Patch requests.
  264. ForceSendFields []string `json:"-"`
  265. // NullFields is a list of field names (e.g. "DataAnalysis") to include
  266. // in API requests with the JSON null value. By default, fields with
  267. // empty values are omitted from API requests. However, any field with
  268. // an empty value appearing in NullFields will be sent to the server as
  269. // null. It is an error if a field in this list has a non-empty value.
  270. // This may be used to include null fields in Patch requests.
  271. NullFields []string `json:"-"`
  272. }
  273. func (s *Training) MarshalJSON() ([]byte, error) {
  274. type NoMethod Training
  275. raw := NoMethod(*s)
  276. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  277. }
  278. // TrainingDataAnalysis: Data Analysis.
  279. type TrainingDataAnalysis struct {
  280. Warnings []string `json:"warnings,omitempty"`
  281. // ForceSendFields is a list of field names (e.g. "Warnings") to
  282. // unconditionally include in API requests. By default, fields with
  283. // empty values are omitted from API requests. However, any non-pointer,
  284. // non-interface field appearing in ForceSendFields will be sent to the
  285. // server regardless of whether the field is empty or not. This may be
  286. // used to include empty fields in Patch requests.
  287. ForceSendFields []string `json:"-"`
  288. // NullFields is a list of field names (e.g. "Warnings") to include in
  289. // API requests with the JSON null value. By default, fields with empty
  290. // values are omitted from API requests. However, any field with an
  291. // empty value appearing in NullFields will be sent to the server as
  292. // null. It is an error if a field in this list has a non-empty value.
  293. // This may be used to include null fields in Patch requests.
  294. NullFields []string `json:"-"`
  295. }
  296. func (s *TrainingDataAnalysis) MarshalJSON() ([]byte, error) {
  297. type NoMethod TrainingDataAnalysis
  298. raw := NoMethod(*s)
  299. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  300. }
  301. // TrainingModelInfo: Model metadata.
  302. type TrainingModelInfo struct {
  303. // ClassWeightedAccuracy: Estimated accuracy of model taking utility
  304. // weights into account [Categorical models only].
  305. ClassWeightedAccuracy float64 `json:"classWeightedAccuracy,omitempty"`
  306. // ClassificationAccuracy: A number between 0.0 and 1.0, where 1.0 is
  307. // 100% accurate. This is an estimate, based on the amount and quality
  308. // of the training data, of the estimated prediction accuracy. You can
  309. // use this is a guide to decide whether the results are accurate enough
  310. // for your needs. This estimate will be more reliable if your real
  311. // input data is similar to your training data [Categorical models
  312. // only].
  313. ClassificationAccuracy float64 `json:"classificationAccuracy,omitempty"`
  314. // ConfusionMatrix: An output confusion matrix. This shows an estimate
  315. // for how this model will do in predictions. This is first indexed by
  316. // the true class label. For each true class label, this provides a pair
  317. // {predicted_label, count}, where count is the estimated number of
  318. // times the model will predict the predicted label given the true
  319. // label. Will not output if more then 100 classes [Categorical models
  320. // only].
  321. ConfusionMatrix map[string]map[string]float64 `json:"confusionMatrix,omitempty"`
  322. // ConfusionMatrixRowTotals: A list of the confusion matrix row totals
  323. ConfusionMatrixRowTotals map[string]float64 `json:"confusionMatrixRowTotals,omitempty"`
  324. // MeanSquaredError: An estimated mean squared error. The can be used to
  325. // measure the quality of the predicted model [Regression models only].
  326. MeanSquaredError float64 `json:"meanSquaredError,omitempty"`
  327. // ModelType: Type of predictive model (CLASSIFICATION or REGRESSION)
  328. ModelType string `json:"modelType,omitempty"`
  329. // NumberInstances: Number of valid data instances used in the trained
  330. // model.
  331. NumberInstances int64 `json:"numberInstances,omitempty,string"`
  332. // NumberLabels: Number of class labels in the trained model
  333. // [Categorical models only].
  334. NumberLabels int64 `json:"numberLabels,omitempty,string"`
  335. // ForceSendFields is a list of field names (e.g.
  336. // "ClassWeightedAccuracy") to unconditionally include in API requests.
  337. // By default, fields with empty values are omitted from API requests.
  338. // However, any non-pointer, non-interface field appearing in
  339. // ForceSendFields will be sent to the server regardless of whether the
  340. // field is empty or not. This may be used to include empty fields in
  341. // Patch requests.
  342. ForceSendFields []string `json:"-"`
  343. // NullFields is a list of field names (e.g. "ClassWeightedAccuracy") to
  344. // include in API requests with the JSON null value. By default, fields
  345. // with empty values are omitted from API requests. However, any field
  346. // with an empty value appearing in NullFields will be sent to the
  347. // server as null. It is an error if a field in this list has a
  348. // non-empty value. This may be used to include null fields in Patch
  349. // requests.
  350. NullFields []string `json:"-"`
  351. }
  352. func (s *TrainingModelInfo) MarshalJSON() ([]byte, error) {
  353. type NoMethod TrainingModelInfo
  354. raw := NoMethod(*s)
  355. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  356. }
  357. func (s *TrainingModelInfo) UnmarshalJSON(data []byte) error {
  358. type NoMethod TrainingModelInfo
  359. var s1 struct {
  360. ClassWeightedAccuracy gensupport.JSONFloat64 `json:"classWeightedAccuracy"`
  361. ClassificationAccuracy gensupport.JSONFloat64 `json:"classificationAccuracy"`
  362. MeanSquaredError gensupport.JSONFloat64 `json:"meanSquaredError"`
  363. *NoMethod
  364. }
  365. s1.NoMethod = (*NoMethod)(s)
  366. if err := json.Unmarshal(data, &s1); err != nil {
  367. return err
  368. }
  369. s.ClassWeightedAccuracy = float64(s1.ClassWeightedAccuracy)
  370. s.ClassificationAccuracy = float64(s1.ClassificationAccuracy)
  371. s.MeanSquaredError = float64(s1.MeanSquaredError)
  372. return nil
  373. }
  374. type Update struct {
  375. // CsvInstance: The input features for this instance
  376. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  377. // Label: The class label of this instance
  378. Label string `json:"label,omitempty"`
  379. // Output: The generic output value - could be regression value or class
  380. // label
  381. Output string `json:"output,omitempty"`
  382. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  383. // unconditionally include in API requests. By default, fields with
  384. // empty values are omitted from API requests. However, any non-pointer,
  385. // non-interface field appearing in ForceSendFields will be sent to the
  386. // server regardless of whether the field is empty or not. This may be
  387. // used to include empty fields in Patch requests.
  388. ForceSendFields []string `json:"-"`
  389. // NullFields is a list of field names (e.g. "CsvInstance") to include
  390. // in API requests with the JSON null value. By default, fields with
  391. // empty values are omitted from API requests. However, any field with
  392. // an empty value appearing in NullFields will be sent to the server as
  393. // null. It is an error if a field in this list has a non-empty value.
  394. // This may be used to include null fields in Patch requests.
  395. NullFields []string `json:"-"`
  396. }
  397. func (s *Update) MarshalJSON() ([]byte, error) {
  398. type NoMethod Update
  399. raw := NoMethod(*s)
  400. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  401. }
  402. // method id "prediction.hostedmodels.predict":
  403. type HostedmodelsPredictCall struct {
  404. s *Service
  405. hostedModelName string
  406. input *Input
  407. urlParams_ gensupport.URLParams
  408. ctx_ context.Context
  409. header_ http.Header
  410. }
  411. // Predict: Submit input and request an output against a hosted model.
  412. func (r *HostedmodelsService) Predict(hostedModelName string, input *Input) *HostedmodelsPredictCall {
  413. c := &HostedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  414. c.hostedModelName = hostedModelName
  415. c.input = input
  416. return c
  417. }
  418. // Fields allows partial responses to be retrieved. See
  419. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  420. // for more information.
  421. func (c *HostedmodelsPredictCall) Fields(s ...googleapi.Field) *HostedmodelsPredictCall {
  422. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  423. return c
  424. }
  425. // Context sets the context to be used in this call's Do method. Any
  426. // pending HTTP request will be aborted if the provided context is
  427. // canceled.
  428. func (c *HostedmodelsPredictCall) Context(ctx context.Context) *HostedmodelsPredictCall {
  429. c.ctx_ = ctx
  430. return c
  431. }
  432. // Header returns an http.Header that can be modified by the caller to
  433. // add HTTP headers to the request.
  434. func (c *HostedmodelsPredictCall) Header() http.Header {
  435. if c.header_ == nil {
  436. c.header_ = make(http.Header)
  437. }
  438. return c.header_
  439. }
  440. func (c *HostedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  441. reqHeaders := make(http.Header)
  442. for k, v := range c.header_ {
  443. reqHeaders[k] = v
  444. }
  445. reqHeaders.Set("User-Agent", c.s.userAgent())
  446. var body io.Reader = nil
  447. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  448. if err != nil {
  449. return nil, err
  450. }
  451. reqHeaders.Set("Content-Type", "application/json")
  452. c.urlParams_.Set("alt", alt)
  453. urls := googleapi.ResolveRelative(c.s.BasePath, "hostedmodels/{hostedModelName}/predict")
  454. urls += "?" + c.urlParams_.Encode()
  455. req, _ := http.NewRequest("POST", urls, body)
  456. req.Header = reqHeaders
  457. googleapi.Expand(req.URL, map[string]string{
  458. "hostedModelName": c.hostedModelName,
  459. })
  460. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  461. }
  462. // Do executes the "prediction.hostedmodels.predict" call.
  463. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  464. // code is an error. Response headers are in either
  465. // *Output.ServerResponse.Header or (if a response was returned at all)
  466. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  467. // check whether the returned error was because http.StatusNotModified
  468. // was returned.
  469. func (c *HostedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  470. gensupport.SetOptions(c.urlParams_, opts...)
  471. res, err := c.doRequest("json")
  472. if res != nil && res.StatusCode == http.StatusNotModified {
  473. if res.Body != nil {
  474. res.Body.Close()
  475. }
  476. return nil, &googleapi.Error{
  477. Code: res.StatusCode,
  478. Header: res.Header,
  479. }
  480. }
  481. if err != nil {
  482. return nil, err
  483. }
  484. defer googleapi.CloseBody(res)
  485. if err := googleapi.CheckResponse(res); err != nil {
  486. return nil, err
  487. }
  488. ret := &Output{
  489. ServerResponse: googleapi.ServerResponse{
  490. Header: res.Header,
  491. HTTPStatusCode: res.StatusCode,
  492. },
  493. }
  494. target := &ret
  495. if err := gensupport.DecodeResponse(target, res); err != nil {
  496. return nil, err
  497. }
  498. return ret, nil
  499. // {
  500. // "description": "Submit input and request an output against a hosted model.",
  501. // "httpMethod": "POST",
  502. // "id": "prediction.hostedmodels.predict",
  503. // "parameterOrder": [
  504. // "hostedModelName"
  505. // ],
  506. // "parameters": {
  507. // "hostedModelName": {
  508. // "description": "The name of a hosted model.",
  509. // "location": "path",
  510. // "required": true,
  511. // "type": "string"
  512. // }
  513. // },
  514. // "path": "hostedmodels/{hostedModelName}/predict",
  515. // "request": {
  516. // "$ref": "Input"
  517. // },
  518. // "response": {
  519. // "$ref": "Output"
  520. // },
  521. // "scopes": [
  522. // "https://www.googleapis.com/auth/prediction"
  523. // ]
  524. // }
  525. }
  526. // method id "prediction.trainedmodels.delete":
  527. type TrainedmodelsDeleteCall struct {
  528. s *Service
  529. id string
  530. urlParams_ gensupport.URLParams
  531. ctx_ context.Context
  532. header_ http.Header
  533. }
  534. // Delete: Delete a trained model.
  535. func (r *TrainedmodelsService) Delete(id string) *TrainedmodelsDeleteCall {
  536. c := &TrainedmodelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  537. c.id = id
  538. return c
  539. }
  540. // Fields allows partial responses to be retrieved. See
  541. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  542. // for more information.
  543. func (c *TrainedmodelsDeleteCall) Fields(s ...googleapi.Field) *TrainedmodelsDeleteCall {
  544. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  545. return c
  546. }
  547. // Context sets the context to be used in this call's Do method. Any
  548. // pending HTTP request will be aborted if the provided context is
  549. // canceled.
  550. func (c *TrainedmodelsDeleteCall) Context(ctx context.Context) *TrainedmodelsDeleteCall {
  551. c.ctx_ = ctx
  552. return c
  553. }
  554. // Header returns an http.Header that can be modified by the caller to
  555. // add HTTP headers to the request.
  556. func (c *TrainedmodelsDeleteCall) Header() http.Header {
  557. if c.header_ == nil {
  558. c.header_ = make(http.Header)
  559. }
  560. return c.header_
  561. }
  562. func (c *TrainedmodelsDeleteCall) doRequest(alt string) (*http.Response, error) {
  563. reqHeaders := make(http.Header)
  564. for k, v := range c.header_ {
  565. reqHeaders[k] = v
  566. }
  567. reqHeaders.Set("User-Agent", c.s.userAgent())
  568. var body io.Reader = nil
  569. c.urlParams_.Set("alt", alt)
  570. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  571. urls += "?" + c.urlParams_.Encode()
  572. req, _ := http.NewRequest("DELETE", urls, body)
  573. req.Header = reqHeaders
  574. googleapi.Expand(req.URL, map[string]string{
  575. "id": c.id,
  576. })
  577. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  578. }
  579. // Do executes the "prediction.trainedmodels.delete" call.
  580. func (c *TrainedmodelsDeleteCall) Do(opts ...googleapi.CallOption) error {
  581. gensupport.SetOptions(c.urlParams_, opts...)
  582. res, err := c.doRequest("json")
  583. if err != nil {
  584. return err
  585. }
  586. defer googleapi.CloseBody(res)
  587. if err := googleapi.CheckResponse(res); err != nil {
  588. return err
  589. }
  590. return nil
  591. // {
  592. // "description": "Delete a trained model.",
  593. // "httpMethod": "DELETE",
  594. // "id": "prediction.trainedmodels.delete",
  595. // "parameterOrder": [
  596. // "id"
  597. // ],
  598. // "parameters": {
  599. // "id": {
  600. // "description": "The unique name for the predictive model.",
  601. // "location": "path",
  602. // "required": true,
  603. // "type": "string"
  604. // }
  605. // },
  606. // "path": "trainedmodels/{id}",
  607. // "scopes": [
  608. // "https://www.googleapis.com/auth/prediction"
  609. // ]
  610. // }
  611. }
  612. // method id "prediction.trainedmodels.get":
  613. type TrainedmodelsGetCall struct {
  614. s *Service
  615. id string
  616. urlParams_ gensupport.URLParams
  617. ifNoneMatch_ string
  618. ctx_ context.Context
  619. header_ http.Header
  620. }
  621. // Get: Check training status of your model.
  622. func (r *TrainedmodelsService) Get(id string) *TrainedmodelsGetCall {
  623. c := &TrainedmodelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  624. c.id = id
  625. return c
  626. }
  627. // Fields allows partial responses to be retrieved. See
  628. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  629. // for more information.
  630. func (c *TrainedmodelsGetCall) Fields(s ...googleapi.Field) *TrainedmodelsGetCall {
  631. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  632. return c
  633. }
  634. // IfNoneMatch sets the optional parameter which makes the operation
  635. // fail if the object's ETag matches the given value. This is useful for
  636. // getting updates only after the object has changed since the last
  637. // request. Use googleapi.IsNotModified to check whether the response
  638. // error from Do is the result of In-None-Match.
  639. func (c *TrainedmodelsGetCall) IfNoneMatch(entityTag string) *TrainedmodelsGetCall {
  640. c.ifNoneMatch_ = entityTag
  641. return c
  642. }
  643. // Context sets the context to be used in this call's Do method. Any
  644. // pending HTTP request will be aborted if the provided context is
  645. // canceled.
  646. func (c *TrainedmodelsGetCall) Context(ctx context.Context) *TrainedmodelsGetCall {
  647. c.ctx_ = ctx
  648. return c
  649. }
  650. // Header returns an http.Header that can be modified by the caller to
  651. // add HTTP headers to the request.
  652. func (c *TrainedmodelsGetCall) Header() http.Header {
  653. if c.header_ == nil {
  654. c.header_ = make(http.Header)
  655. }
  656. return c.header_
  657. }
  658. func (c *TrainedmodelsGetCall) doRequest(alt string) (*http.Response, error) {
  659. reqHeaders := make(http.Header)
  660. for k, v := range c.header_ {
  661. reqHeaders[k] = v
  662. }
  663. reqHeaders.Set("User-Agent", c.s.userAgent())
  664. if c.ifNoneMatch_ != "" {
  665. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  666. }
  667. var body io.Reader = nil
  668. c.urlParams_.Set("alt", alt)
  669. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  670. urls += "?" + c.urlParams_.Encode()
  671. req, _ := http.NewRequest("GET", urls, body)
  672. req.Header = reqHeaders
  673. googleapi.Expand(req.URL, map[string]string{
  674. "id": c.id,
  675. })
  676. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  677. }
  678. // Do executes the "prediction.trainedmodels.get" call.
  679. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  680. // code is an error. Response headers are in either
  681. // *Training.ServerResponse.Header or (if a response was returned at
  682. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  683. // to check whether the returned error was because
  684. // http.StatusNotModified was returned.
  685. func (c *TrainedmodelsGetCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  686. gensupport.SetOptions(c.urlParams_, opts...)
  687. res, err := c.doRequest("json")
  688. if res != nil && res.StatusCode == http.StatusNotModified {
  689. if res.Body != nil {
  690. res.Body.Close()
  691. }
  692. return nil, &googleapi.Error{
  693. Code: res.StatusCode,
  694. Header: res.Header,
  695. }
  696. }
  697. if err != nil {
  698. return nil, err
  699. }
  700. defer googleapi.CloseBody(res)
  701. if err := googleapi.CheckResponse(res); err != nil {
  702. return nil, err
  703. }
  704. ret := &Training{
  705. ServerResponse: googleapi.ServerResponse{
  706. Header: res.Header,
  707. HTTPStatusCode: res.StatusCode,
  708. },
  709. }
  710. target := &ret
  711. if err := gensupport.DecodeResponse(target, res); err != nil {
  712. return nil, err
  713. }
  714. return ret, nil
  715. // {
  716. // "description": "Check training status of your model.",
  717. // "httpMethod": "GET",
  718. // "id": "prediction.trainedmodels.get",
  719. // "parameterOrder": [
  720. // "id"
  721. // ],
  722. // "parameters": {
  723. // "id": {
  724. // "description": "The unique name for the predictive model.",
  725. // "location": "path",
  726. // "required": true,
  727. // "type": "string"
  728. // }
  729. // },
  730. // "path": "trainedmodels/{id}",
  731. // "response": {
  732. // "$ref": "Training"
  733. // },
  734. // "scopes": [
  735. // "https://www.googleapis.com/auth/prediction"
  736. // ]
  737. // }
  738. }
  739. // method id "prediction.trainedmodels.insert":
  740. type TrainedmodelsInsertCall struct {
  741. s *Service
  742. training *Training
  743. urlParams_ gensupport.URLParams
  744. ctx_ context.Context
  745. header_ http.Header
  746. }
  747. // Insert: Begin training your model.
  748. func (r *TrainedmodelsService) Insert(training *Training) *TrainedmodelsInsertCall {
  749. c := &TrainedmodelsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  750. c.training = training
  751. return c
  752. }
  753. // Fields allows partial responses to be retrieved. See
  754. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  755. // for more information.
  756. func (c *TrainedmodelsInsertCall) Fields(s ...googleapi.Field) *TrainedmodelsInsertCall {
  757. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  758. return c
  759. }
  760. // Context sets the context to be used in this call's Do method. Any
  761. // pending HTTP request will be aborted if the provided context is
  762. // canceled.
  763. func (c *TrainedmodelsInsertCall) Context(ctx context.Context) *TrainedmodelsInsertCall {
  764. c.ctx_ = ctx
  765. return c
  766. }
  767. // Header returns an http.Header that can be modified by the caller to
  768. // add HTTP headers to the request.
  769. func (c *TrainedmodelsInsertCall) Header() http.Header {
  770. if c.header_ == nil {
  771. c.header_ = make(http.Header)
  772. }
  773. return c.header_
  774. }
  775. func (c *TrainedmodelsInsertCall) doRequest(alt string) (*http.Response, error) {
  776. reqHeaders := make(http.Header)
  777. for k, v := range c.header_ {
  778. reqHeaders[k] = v
  779. }
  780. reqHeaders.Set("User-Agent", c.s.userAgent())
  781. var body io.Reader = nil
  782. body, err := googleapi.WithoutDataWrapper.JSONReader(c.training)
  783. if err != nil {
  784. return nil, err
  785. }
  786. reqHeaders.Set("Content-Type", "application/json")
  787. c.urlParams_.Set("alt", alt)
  788. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels")
  789. urls += "?" + c.urlParams_.Encode()
  790. req, _ := http.NewRequest("POST", urls, body)
  791. req.Header = reqHeaders
  792. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  793. }
  794. // Do executes the "prediction.trainedmodels.insert" call.
  795. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  796. // code is an error. Response headers are in either
  797. // *Training.ServerResponse.Header or (if a response was returned at
  798. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  799. // to check whether the returned error was because
  800. // http.StatusNotModified was returned.
  801. func (c *TrainedmodelsInsertCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  802. gensupport.SetOptions(c.urlParams_, opts...)
  803. res, err := c.doRequest("json")
  804. if res != nil && res.StatusCode == http.StatusNotModified {
  805. if res.Body != nil {
  806. res.Body.Close()
  807. }
  808. return nil, &googleapi.Error{
  809. Code: res.StatusCode,
  810. Header: res.Header,
  811. }
  812. }
  813. if err != nil {
  814. return nil, err
  815. }
  816. defer googleapi.CloseBody(res)
  817. if err := googleapi.CheckResponse(res); err != nil {
  818. return nil, err
  819. }
  820. ret := &Training{
  821. ServerResponse: googleapi.ServerResponse{
  822. Header: res.Header,
  823. HTTPStatusCode: res.StatusCode,
  824. },
  825. }
  826. target := &ret
  827. if err := gensupport.DecodeResponse(target, res); err != nil {
  828. return nil, err
  829. }
  830. return ret, nil
  831. // {
  832. // "description": "Begin training your model.",
  833. // "httpMethod": "POST",
  834. // "id": "prediction.trainedmodels.insert",
  835. // "path": "trainedmodels",
  836. // "request": {
  837. // "$ref": "Training"
  838. // },
  839. // "response": {
  840. // "$ref": "Training"
  841. // },
  842. // "scopes": [
  843. // "https://www.googleapis.com/auth/devstorage.full_control",
  844. // "https://www.googleapis.com/auth/devstorage.read_only",
  845. // "https://www.googleapis.com/auth/devstorage.read_write",
  846. // "https://www.googleapis.com/auth/prediction"
  847. // ]
  848. // }
  849. }
  850. // method id "prediction.trainedmodels.predict":
  851. type TrainedmodelsPredictCall struct {
  852. s *Service
  853. id string
  854. input *Input
  855. urlParams_ gensupport.URLParams
  856. ctx_ context.Context
  857. header_ http.Header
  858. }
  859. // Predict: Submit model id and request a prediction
  860. func (r *TrainedmodelsService) Predict(id string, input *Input) *TrainedmodelsPredictCall {
  861. c := &TrainedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  862. c.id = id
  863. c.input = input
  864. return c
  865. }
  866. // Fields allows partial responses to be retrieved. See
  867. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  868. // for more information.
  869. func (c *TrainedmodelsPredictCall) Fields(s ...googleapi.Field) *TrainedmodelsPredictCall {
  870. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  871. return c
  872. }
  873. // Context sets the context to be used in this call's Do method. Any
  874. // pending HTTP request will be aborted if the provided context is
  875. // canceled.
  876. func (c *TrainedmodelsPredictCall) Context(ctx context.Context) *TrainedmodelsPredictCall {
  877. c.ctx_ = ctx
  878. return c
  879. }
  880. // Header returns an http.Header that can be modified by the caller to
  881. // add HTTP headers to the request.
  882. func (c *TrainedmodelsPredictCall) Header() http.Header {
  883. if c.header_ == nil {
  884. c.header_ = make(http.Header)
  885. }
  886. return c.header_
  887. }
  888. func (c *TrainedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  889. reqHeaders := make(http.Header)
  890. for k, v := range c.header_ {
  891. reqHeaders[k] = v
  892. }
  893. reqHeaders.Set("User-Agent", c.s.userAgent())
  894. var body io.Reader = nil
  895. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  896. if err != nil {
  897. return nil, err
  898. }
  899. reqHeaders.Set("Content-Type", "application/json")
  900. c.urlParams_.Set("alt", alt)
  901. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/predict")
  902. urls += "?" + c.urlParams_.Encode()
  903. req, _ := http.NewRequest("POST", urls, body)
  904. req.Header = reqHeaders
  905. googleapi.Expand(req.URL, map[string]string{
  906. "id": c.id,
  907. })
  908. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  909. }
  910. // Do executes the "prediction.trainedmodels.predict" call.
  911. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  912. // code is an error. Response headers are in either
  913. // *Output.ServerResponse.Header or (if a response was returned at all)
  914. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  915. // check whether the returned error was because http.StatusNotModified
  916. // was returned.
  917. func (c *TrainedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  918. gensupport.SetOptions(c.urlParams_, opts...)
  919. res, err := c.doRequest("json")
  920. if res != nil && res.StatusCode == http.StatusNotModified {
  921. if res.Body != nil {
  922. res.Body.Close()
  923. }
  924. return nil, &googleapi.Error{
  925. Code: res.StatusCode,
  926. Header: res.Header,
  927. }
  928. }
  929. if err != nil {
  930. return nil, err
  931. }
  932. defer googleapi.CloseBody(res)
  933. if err := googleapi.CheckResponse(res); err != nil {
  934. return nil, err
  935. }
  936. ret := &Output{
  937. ServerResponse: googleapi.ServerResponse{
  938. Header: res.Header,
  939. HTTPStatusCode: res.StatusCode,
  940. },
  941. }
  942. target := &ret
  943. if err := gensupport.DecodeResponse(target, res); err != nil {
  944. return nil, err
  945. }
  946. return ret, nil
  947. // {
  948. // "description": "Submit model id and request a prediction",
  949. // "httpMethod": "POST",
  950. // "id": "prediction.trainedmodels.predict",
  951. // "parameterOrder": [
  952. // "id"
  953. // ],
  954. // "parameters": {
  955. // "id": {
  956. // "description": "The unique name for the predictive model.",
  957. // "location": "path",
  958. // "required": true,
  959. // "type": "string"
  960. // }
  961. // },
  962. // "path": "trainedmodels/{id}/predict",
  963. // "request": {
  964. // "$ref": "Input"
  965. // },
  966. // "response": {
  967. // "$ref": "Output"
  968. // },
  969. // "scopes": [
  970. // "https://www.googleapis.com/auth/prediction"
  971. // ]
  972. // }
  973. }
  974. // method id "prediction.trainedmodels.update":
  975. type TrainedmodelsUpdateCall struct {
  976. s *Service
  977. id string
  978. update *Update
  979. urlParams_ gensupport.URLParams
  980. ctx_ context.Context
  981. header_ http.Header
  982. }
  983. // Update: Add new data to a trained model.
  984. func (r *TrainedmodelsService) Update(id string, update *Update) *TrainedmodelsUpdateCall {
  985. c := &TrainedmodelsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  986. c.id = id
  987. c.update = update
  988. return c
  989. }
  990. // Fields allows partial responses to be retrieved. See
  991. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  992. // for more information.
  993. func (c *TrainedmodelsUpdateCall) Fields(s ...googleapi.Field) *TrainedmodelsUpdateCall {
  994. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  995. return c
  996. }
  997. // Context sets the context to be used in this call's Do method. Any
  998. // pending HTTP request will be aborted if the provided context is
  999. // canceled.
  1000. func (c *TrainedmodelsUpdateCall) Context(ctx context.Context) *TrainedmodelsUpdateCall {
  1001. c.ctx_ = ctx
  1002. return c
  1003. }
  1004. // Header returns an http.Header that can be modified by the caller to
  1005. // add HTTP headers to the request.
  1006. func (c *TrainedmodelsUpdateCall) Header() http.Header {
  1007. if c.header_ == nil {
  1008. c.header_ = make(http.Header)
  1009. }
  1010. return c.header_
  1011. }
  1012. func (c *TrainedmodelsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1013. reqHeaders := make(http.Header)
  1014. for k, v := range c.header_ {
  1015. reqHeaders[k] = v
  1016. }
  1017. reqHeaders.Set("User-Agent", c.s.userAgent())
  1018. var body io.Reader = nil
  1019. body, err := googleapi.WithoutDataWrapper.JSONReader(c.update)
  1020. if err != nil {
  1021. return nil, err
  1022. }
  1023. reqHeaders.Set("Content-Type", "application/json")
  1024. c.urlParams_.Set("alt", alt)
  1025. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  1026. urls += "?" + c.urlParams_.Encode()
  1027. req, _ := http.NewRequest("PUT", urls, body)
  1028. req.Header = reqHeaders
  1029. googleapi.Expand(req.URL, map[string]string{
  1030. "id": c.id,
  1031. })
  1032. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1033. }
  1034. // Do executes the "prediction.trainedmodels.update" call.
  1035. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  1036. // code is an error. Response headers are in either
  1037. // *Training.ServerResponse.Header or (if a response was returned at
  1038. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1039. // to check whether the returned error was because
  1040. // http.StatusNotModified was returned.
  1041. func (c *TrainedmodelsUpdateCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  1042. gensupport.SetOptions(c.urlParams_, opts...)
  1043. res, err := c.doRequest("json")
  1044. if res != nil && res.StatusCode == http.StatusNotModified {
  1045. if res.Body != nil {
  1046. res.Body.Close()
  1047. }
  1048. return nil, &googleapi.Error{
  1049. Code: res.StatusCode,
  1050. Header: res.Header,
  1051. }
  1052. }
  1053. if err != nil {
  1054. return nil, err
  1055. }
  1056. defer googleapi.CloseBody(res)
  1057. if err := googleapi.CheckResponse(res); err != nil {
  1058. return nil, err
  1059. }
  1060. ret := &Training{
  1061. ServerResponse: googleapi.ServerResponse{
  1062. Header: res.Header,
  1063. HTTPStatusCode: res.StatusCode,
  1064. },
  1065. }
  1066. target := &ret
  1067. if err := gensupport.DecodeResponse(target, res); err != nil {
  1068. return nil, err
  1069. }
  1070. return ret, nil
  1071. // {
  1072. // "description": "Add new data to a trained model.",
  1073. // "httpMethod": "PUT",
  1074. // "id": "prediction.trainedmodels.update",
  1075. // "parameterOrder": [
  1076. // "id"
  1077. // ],
  1078. // "parameters": {
  1079. // "id": {
  1080. // "description": "The unique name for the predictive model.",
  1081. // "location": "path",
  1082. // "required": true,
  1083. // "type": "string"
  1084. // }
  1085. // },
  1086. // "path": "trainedmodels/{id}",
  1087. // "request": {
  1088. // "$ref": "Update"
  1089. // },
  1090. // "response": {
  1091. // "$ref": "Training"
  1092. // },
  1093. // "scopes": [
  1094. // "https://www.googleapis.com/auth/prediction"
  1095. // ]
  1096. // }
  1097. }