Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

1228 linhas
39 KiB

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