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.
 
 
 

1988 lines
68 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.5"
  8. // ...
  9. // predictionService, err := prediction.New(oauthHttpClient)
  10. package prediction // import "google.golang.org/api/prediction/v1.5"
  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.5"
  41. const apiName = "prediction"
  42. const apiVersion = "v1.5"
  43. const basePath = "https://www.googleapis.com/prediction/v1.5/"
  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 Analyze struct {
  92. // DataDescription: Description of the data the model was trained on.
  93. DataDescription *AnalyzeDataDescription `json:"dataDescription,omitempty"`
  94. // Errors: List of errors with the data.
  95. Errors []map[string]string `json:"errors,omitempty"`
  96. // Id: The unique name for the predictive model.
  97. Id string `json:"id,omitempty"`
  98. // Kind: What kind of resource this is.
  99. Kind string `json:"kind,omitempty"`
  100. // ModelDescription: Description of the model.
  101. ModelDescription *AnalyzeModelDescription `json:"modelDescription,omitempty"`
  102. // SelfLink: A URL to re-request this resource.
  103. SelfLink string `json:"selfLink,omitempty"`
  104. // ServerResponse contains the HTTP response code and headers from the
  105. // server.
  106. googleapi.ServerResponse `json:"-"`
  107. // ForceSendFields is a list of field names (e.g. "DataDescription") to
  108. // unconditionally include in API requests. By default, fields with
  109. // empty values are omitted from API requests. However, any non-pointer,
  110. // non-interface field appearing in ForceSendFields will be sent to the
  111. // server regardless of whether the field is empty or not. This may be
  112. // used to include empty fields in Patch requests.
  113. ForceSendFields []string `json:"-"`
  114. // NullFields is a list of field names (e.g. "DataDescription") to
  115. // include in API requests with the JSON null value. By default, fields
  116. // with empty values are omitted from API requests. However, any field
  117. // with an empty value appearing in NullFields will be sent to the
  118. // server as null. It is an error if a field in this list has a
  119. // non-empty value. This may be used to include null fields in Patch
  120. // requests.
  121. NullFields []string `json:"-"`
  122. }
  123. func (s *Analyze) MarshalJSON() ([]byte, error) {
  124. type NoMethod Analyze
  125. raw := NoMethod(*s)
  126. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  127. }
  128. // AnalyzeDataDescription: Description of the data the model was trained
  129. // on.
  130. type AnalyzeDataDescription struct {
  131. // Features: Description of the input features in the data set.
  132. Features []*AnalyzeDataDescriptionFeatures `json:"features,omitempty"`
  133. // OutputFeature: Description of the output value or label.
  134. OutputFeature *AnalyzeDataDescriptionOutputFeature `json:"outputFeature,omitempty"`
  135. // ForceSendFields is a list of field names (e.g. "Features") to
  136. // unconditionally include in API requests. By default, fields with
  137. // empty values are omitted from API requests. However, any non-pointer,
  138. // non-interface field appearing in ForceSendFields will be sent to the
  139. // server regardless of whether the field is empty or not. This may be
  140. // used to include empty fields in Patch requests.
  141. ForceSendFields []string `json:"-"`
  142. // NullFields is a list of field names (e.g. "Features") to include in
  143. // API requests with the JSON null value. By default, fields with empty
  144. // values are omitted from API requests. However, any field with an
  145. // empty value appearing in NullFields will be sent to the server as
  146. // null. It is an error if a field in this list has a non-empty value.
  147. // This may be used to include null fields in Patch requests.
  148. NullFields []string `json:"-"`
  149. }
  150. func (s *AnalyzeDataDescription) MarshalJSON() ([]byte, error) {
  151. type NoMethod AnalyzeDataDescription
  152. raw := NoMethod(*s)
  153. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  154. }
  155. type AnalyzeDataDescriptionFeatures struct {
  156. // Categorical: Description of the categorical values of this feature.
  157. Categorical *AnalyzeDataDescriptionFeaturesCategorical `json:"categorical,omitempty"`
  158. // Index: The feature index.
  159. Index int64 `json:"index,omitempty,string"`
  160. // Numeric: Description of the numeric values of this feature.
  161. Numeric *AnalyzeDataDescriptionFeaturesNumeric `json:"numeric,omitempty"`
  162. // Text: Description of multiple-word text values of this feature.
  163. Text *AnalyzeDataDescriptionFeaturesText `json:"text,omitempty"`
  164. // ForceSendFields is a list of field names (e.g. "Categorical") to
  165. // unconditionally include in API requests. By default, fields with
  166. // empty values are omitted from API requests. However, any non-pointer,
  167. // non-interface field appearing in ForceSendFields will be sent to the
  168. // server regardless of whether the field is empty or not. This may be
  169. // used to include empty fields in Patch requests.
  170. ForceSendFields []string `json:"-"`
  171. // NullFields is a list of field names (e.g. "Categorical") to include
  172. // in API requests with the JSON null value. By default, fields with
  173. // empty values are omitted from API requests. However, any field with
  174. // an empty value appearing in NullFields will be sent to the server as
  175. // null. It is an error if a field in this list has a non-empty value.
  176. // This may be used to include null fields in Patch requests.
  177. NullFields []string `json:"-"`
  178. }
  179. func (s *AnalyzeDataDescriptionFeatures) MarshalJSON() ([]byte, error) {
  180. type NoMethod AnalyzeDataDescriptionFeatures
  181. raw := NoMethod(*s)
  182. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  183. }
  184. // AnalyzeDataDescriptionFeaturesCategorical: Description of the
  185. // categorical values of this feature.
  186. type AnalyzeDataDescriptionFeaturesCategorical struct {
  187. // Count: Number of categorical values for this feature in the data.
  188. Count int64 `json:"count,omitempty,string"`
  189. // Values: List of all the categories for this feature in the data set.
  190. Values []*AnalyzeDataDescriptionFeaturesCategoricalValues `json:"values,omitempty"`
  191. // ForceSendFields is a list of field names (e.g. "Count") to
  192. // unconditionally include in API requests. By default, fields with
  193. // empty values are omitted from API requests. However, any non-pointer,
  194. // non-interface field appearing in ForceSendFields will be sent to the
  195. // server regardless of whether the field is empty or not. This may be
  196. // used to include empty fields in Patch requests.
  197. ForceSendFields []string `json:"-"`
  198. // NullFields is a list of field names (e.g. "Count") to include in API
  199. // requests with the JSON null value. By default, fields with empty
  200. // values are omitted from API requests. However, any field with an
  201. // empty value appearing in NullFields will be sent to the server as
  202. // null. It is an error if a field in this list has a non-empty value.
  203. // This may be used to include null fields in Patch requests.
  204. NullFields []string `json:"-"`
  205. }
  206. func (s *AnalyzeDataDescriptionFeaturesCategorical) MarshalJSON() ([]byte, error) {
  207. type NoMethod AnalyzeDataDescriptionFeaturesCategorical
  208. raw := NoMethod(*s)
  209. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  210. }
  211. type AnalyzeDataDescriptionFeaturesCategoricalValues struct {
  212. // Count: Number of times this feature had this value.
  213. Count int64 `json:"count,omitempty,string"`
  214. // Value: The category name.
  215. Value string `json:"value,omitempty"`
  216. // ForceSendFields is a list of field names (e.g. "Count") to
  217. // unconditionally include in API requests. By default, fields with
  218. // empty values are omitted from API requests. However, any non-pointer,
  219. // non-interface field appearing in ForceSendFields will be sent to the
  220. // server regardless of whether the field is empty or not. This may be
  221. // used to include empty fields in Patch requests.
  222. ForceSendFields []string `json:"-"`
  223. // NullFields is a list of field names (e.g. "Count") to include in API
  224. // requests with the JSON null value. By default, fields with empty
  225. // values are omitted from API requests. However, any field with an
  226. // empty value appearing in NullFields will be sent to the server as
  227. // null. It is an error if a field in this list has a non-empty value.
  228. // This may be used to include null fields in Patch requests.
  229. NullFields []string `json:"-"`
  230. }
  231. func (s *AnalyzeDataDescriptionFeaturesCategoricalValues) MarshalJSON() ([]byte, error) {
  232. type NoMethod AnalyzeDataDescriptionFeaturesCategoricalValues
  233. raw := NoMethod(*s)
  234. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  235. }
  236. // AnalyzeDataDescriptionFeaturesNumeric: Description of the numeric
  237. // values of this feature.
  238. type AnalyzeDataDescriptionFeaturesNumeric struct {
  239. // Count: Number of numeric values for this feature in the data set.
  240. Count int64 `json:"count,omitempty,string"`
  241. // Mean: Mean of the numeric values of this feature in the data set.
  242. Mean float64 `json:"mean,omitempty"`
  243. // Variance: Variance of the numeric values of this feature in the data
  244. // set.
  245. Variance float64 `json:"variance,omitempty"`
  246. // ForceSendFields is a list of field names (e.g. "Count") to
  247. // unconditionally include in API requests. By default, fields with
  248. // empty values are omitted from API requests. However, any non-pointer,
  249. // non-interface field appearing in ForceSendFields will be sent to the
  250. // server regardless of whether the field is empty or not. This may be
  251. // used to include empty fields in Patch requests.
  252. ForceSendFields []string `json:"-"`
  253. // NullFields is a list of field names (e.g. "Count") to include in API
  254. // requests with the JSON null value. By default, fields with empty
  255. // values are omitted from API requests. However, any field with an
  256. // empty value appearing in NullFields will be sent to the server as
  257. // null. It is an error if a field in this list has a non-empty value.
  258. // This may be used to include null fields in Patch requests.
  259. NullFields []string `json:"-"`
  260. }
  261. func (s *AnalyzeDataDescriptionFeaturesNumeric) MarshalJSON() ([]byte, error) {
  262. type NoMethod AnalyzeDataDescriptionFeaturesNumeric
  263. raw := NoMethod(*s)
  264. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  265. }
  266. func (s *AnalyzeDataDescriptionFeaturesNumeric) UnmarshalJSON(data []byte) error {
  267. type NoMethod AnalyzeDataDescriptionFeaturesNumeric
  268. var s1 struct {
  269. Mean gensupport.JSONFloat64 `json:"mean"`
  270. Variance gensupport.JSONFloat64 `json:"variance"`
  271. *NoMethod
  272. }
  273. s1.NoMethod = (*NoMethod)(s)
  274. if err := json.Unmarshal(data, &s1); err != nil {
  275. return err
  276. }
  277. s.Mean = float64(s1.Mean)
  278. s.Variance = float64(s1.Variance)
  279. return nil
  280. }
  281. // AnalyzeDataDescriptionFeaturesText: Description of multiple-word text
  282. // values of this feature.
  283. type AnalyzeDataDescriptionFeaturesText struct {
  284. // Count: Number of multiple-word text values for this feature.
  285. Count int64 `json:"count,omitempty,string"`
  286. // ForceSendFields is a list of field names (e.g. "Count") to
  287. // unconditionally include in API requests. By default, fields with
  288. // empty values are omitted from API requests. However, any non-pointer,
  289. // non-interface field appearing in ForceSendFields will be sent to the
  290. // server regardless of whether the field is empty or not. This may be
  291. // used to include empty fields in Patch requests.
  292. ForceSendFields []string `json:"-"`
  293. // NullFields is a list of field names (e.g. "Count") to include in API
  294. // requests with the JSON null value. By default, fields with empty
  295. // values are omitted from API requests. However, any field with an
  296. // empty value appearing in NullFields will be sent to the server as
  297. // null. It is an error if a field in this list has a non-empty value.
  298. // This may be used to include null fields in Patch requests.
  299. NullFields []string `json:"-"`
  300. }
  301. func (s *AnalyzeDataDescriptionFeaturesText) MarshalJSON() ([]byte, error) {
  302. type NoMethod AnalyzeDataDescriptionFeaturesText
  303. raw := NoMethod(*s)
  304. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  305. }
  306. // AnalyzeDataDescriptionOutputFeature: Description of the output value
  307. // or label.
  308. type AnalyzeDataDescriptionOutputFeature struct {
  309. // Numeric: Description of the output values in the data set.
  310. Numeric *AnalyzeDataDescriptionOutputFeatureNumeric `json:"numeric,omitempty"`
  311. // Text: Description of the output labels in the data set.
  312. Text []*AnalyzeDataDescriptionOutputFeatureText `json:"text,omitempty"`
  313. // ForceSendFields is a list of field names (e.g. "Numeric") to
  314. // unconditionally include in API requests. By default, fields with
  315. // empty values are omitted from API requests. However, any non-pointer,
  316. // non-interface field appearing in ForceSendFields will be sent to the
  317. // server regardless of whether the field is empty or not. This may be
  318. // used to include empty fields in Patch requests.
  319. ForceSendFields []string `json:"-"`
  320. // NullFields is a list of field names (e.g. "Numeric") to include in
  321. // API requests with the JSON null value. By default, fields with empty
  322. // values are omitted from API requests. However, any field with an
  323. // empty value appearing in NullFields will be sent to the server as
  324. // null. It is an error if a field in this list has a non-empty value.
  325. // This may be used to include null fields in Patch requests.
  326. NullFields []string `json:"-"`
  327. }
  328. func (s *AnalyzeDataDescriptionOutputFeature) MarshalJSON() ([]byte, error) {
  329. type NoMethod AnalyzeDataDescriptionOutputFeature
  330. raw := NoMethod(*s)
  331. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  332. }
  333. // AnalyzeDataDescriptionOutputFeatureNumeric: Description of the output
  334. // values in the data set.
  335. type AnalyzeDataDescriptionOutputFeatureNumeric struct {
  336. // Count: Number of numeric output values in the data set.
  337. Count int64 `json:"count,omitempty,string"`
  338. // Mean: Mean of the output values in the data set.
  339. Mean float64 `json:"mean,omitempty"`
  340. // Variance: Variance of the output values in the data set.
  341. Variance float64 `json:"variance,omitempty"`
  342. // ForceSendFields is a list of field names (e.g. "Count") to
  343. // unconditionally include in API requests. By default, fields with
  344. // empty values are omitted from API requests. However, any non-pointer,
  345. // non-interface field appearing in ForceSendFields will be sent to the
  346. // server regardless of whether the field is empty or not. This may be
  347. // used to include empty fields in Patch requests.
  348. ForceSendFields []string `json:"-"`
  349. // NullFields is a list of field names (e.g. "Count") to include in API
  350. // requests with the JSON null value. By default, fields with empty
  351. // values are omitted from API requests. However, any field with an
  352. // empty value appearing in NullFields will be sent to the server as
  353. // null. It is an error if a field in this list has a non-empty value.
  354. // This may be used to include null fields in Patch requests.
  355. NullFields []string `json:"-"`
  356. }
  357. func (s *AnalyzeDataDescriptionOutputFeatureNumeric) MarshalJSON() ([]byte, error) {
  358. type NoMethod AnalyzeDataDescriptionOutputFeatureNumeric
  359. raw := NoMethod(*s)
  360. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  361. }
  362. func (s *AnalyzeDataDescriptionOutputFeatureNumeric) UnmarshalJSON(data []byte) error {
  363. type NoMethod AnalyzeDataDescriptionOutputFeatureNumeric
  364. var s1 struct {
  365. Mean gensupport.JSONFloat64 `json:"mean"`
  366. Variance gensupport.JSONFloat64 `json:"variance"`
  367. *NoMethod
  368. }
  369. s1.NoMethod = (*NoMethod)(s)
  370. if err := json.Unmarshal(data, &s1); err != nil {
  371. return err
  372. }
  373. s.Mean = float64(s1.Mean)
  374. s.Variance = float64(s1.Variance)
  375. return nil
  376. }
  377. type AnalyzeDataDescriptionOutputFeatureText struct {
  378. // Count: Number of times the output label occurred in the data set.
  379. Count int64 `json:"count,omitempty,string"`
  380. // Value: The output label.
  381. Value string `json:"value,omitempty"`
  382. // ForceSendFields is a list of field names (e.g. "Count") 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. "Count") to include in API
  390. // requests with the JSON null value. By default, fields with empty
  391. // values are omitted from API requests. However, any field with an
  392. // 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 *AnalyzeDataDescriptionOutputFeatureText) MarshalJSON() ([]byte, error) {
  398. type NoMethod AnalyzeDataDescriptionOutputFeatureText
  399. raw := NoMethod(*s)
  400. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  401. }
  402. // AnalyzeModelDescription: Description of the model.
  403. type AnalyzeModelDescription struct {
  404. // ConfusionMatrix: An output confusion matrix. This shows an estimate
  405. // for how this model will do in predictions. This is first indexed by
  406. // the true class label. For each true class label, this provides a pair
  407. // {predicted_label, count}, where count is the estimated number of
  408. // times the model will predict the predicted label given the true
  409. // label. Will not output if more then 100 classes [Categorical models
  410. // only].
  411. ConfusionMatrix map[string]map[string]float64 `json:"confusionMatrix,omitempty"`
  412. // ConfusionMatrixRowTotals: A list of the confusion matrix row totals
  413. ConfusionMatrixRowTotals map[string]float64 `json:"confusionMatrixRowTotals,omitempty"`
  414. // Modelinfo: Basic information about the model.
  415. Modelinfo *Training `json:"modelinfo,omitempty"`
  416. // ForceSendFields is a list of field names (e.g. "ConfusionMatrix") to
  417. // unconditionally include in API requests. By default, fields with
  418. // empty values are omitted from API requests. However, any non-pointer,
  419. // non-interface field appearing in ForceSendFields will be sent to the
  420. // server regardless of whether the field is empty or not. This may be
  421. // used to include empty fields in Patch requests.
  422. ForceSendFields []string `json:"-"`
  423. // NullFields is a list of field names (e.g. "ConfusionMatrix") to
  424. // include in API requests with the JSON null value. By default, fields
  425. // with empty values are omitted from API requests. However, any field
  426. // with an empty value appearing in NullFields will be sent to the
  427. // server as null. It is an error if a field in this list has a
  428. // non-empty value. This may be used to include null fields in Patch
  429. // requests.
  430. NullFields []string `json:"-"`
  431. }
  432. func (s *AnalyzeModelDescription) MarshalJSON() ([]byte, error) {
  433. type NoMethod AnalyzeModelDescription
  434. raw := NoMethod(*s)
  435. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  436. }
  437. type Input struct {
  438. // Input: Input to the model for a prediction
  439. Input *InputInput `json:"input,omitempty"`
  440. // ForceSendFields is a list of field names (e.g. "Input") to
  441. // unconditionally include in API requests. By default, fields with
  442. // empty values are omitted from API requests. However, any non-pointer,
  443. // non-interface field appearing in ForceSendFields will be sent to the
  444. // server regardless of whether the field is empty or not. This may be
  445. // used to include empty fields in Patch requests.
  446. ForceSendFields []string `json:"-"`
  447. // NullFields is a list of field names (e.g. "Input") to include in API
  448. // requests with the JSON null value. By default, fields with empty
  449. // values are omitted from API requests. However, any field with an
  450. // empty value appearing in NullFields will be sent to the server as
  451. // null. It is an error if a field in this list has a non-empty value.
  452. // This may be used to include null fields in Patch requests.
  453. NullFields []string `json:"-"`
  454. }
  455. func (s *Input) MarshalJSON() ([]byte, error) {
  456. type NoMethod Input
  457. raw := NoMethod(*s)
  458. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  459. }
  460. // InputInput: Input to the model for a prediction
  461. type InputInput struct {
  462. // CsvInstance: A list of input features, these can be strings or
  463. // doubles.
  464. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  465. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  466. // unconditionally include in API requests. By default, fields with
  467. // empty values are omitted from API requests. However, any non-pointer,
  468. // non-interface field appearing in ForceSendFields will be sent to the
  469. // server regardless of whether the field is empty or not. This may be
  470. // used to include empty fields in Patch requests.
  471. ForceSendFields []string `json:"-"`
  472. // NullFields is a list of field names (e.g. "CsvInstance") to include
  473. // in API requests with the JSON null value. By default, fields with
  474. // empty values are omitted from API requests. However, any field with
  475. // an empty value appearing in NullFields will be sent to the server as
  476. // null. It is an error if a field in this list has a non-empty value.
  477. // This may be used to include null fields in Patch requests.
  478. NullFields []string `json:"-"`
  479. }
  480. func (s *InputInput) MarshalJSON() ([]byte, error) {
  481. type NoMethod InputInput
  482. raw := NoMethod(*s)
  483. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  484. }
  485. type List struct {
  486. // Items: List of models.
  487. Items []*Training `json:"items,omitempty"`
  488. // Kind: What kind of resource this is.
  489. Kind string `json:"kind,omitempty"`
  490. // NextPageToken: Pagination token to fetch the next page, if one
  491. // exists.
  492. NextPageToken string `json:"nextPageToken,omitempty"`
  493. // SelfLink: A URL to re-request this resource.
  494. SelfLink string `json:"selfLink,omitempty"`
  495. // ServerResponse contains the HTTP response code and headers from the
  496. // server.
  497. googleapi.ServerResponse `json:"-"`
  498. // ForceSendFields is a list of field names (e.g. "Items") to
  499. // unconditionally include in API requests. By default, fields with
  500. // empty values are omitted from API requests. However, any non-pointer,
  501. // non-interface field appearing in ForceSendFields will be sent to the
  502. // server regardless of whether the field is empty or not. This may be
  503. // used to include empty fields in Patch requests.
  504. ForceSendFields []string `json:"-"`
  505. // NullFields is a list of field names (e.g. "Items") to include in API
  506. // requests with the JSON null value. By default, fields with empty
  507. // values are omitted from API requests. However, any field with an
  508. // empty value appearing in NullFields will be sent to the server as
  509. // null. It is an error if a field in this list has a non-empty value.
  510. // This may be used to include null fields in Patch requests.
  511. NullFields []string `json:"-"`
  512. }
  513. func (s *List) MarshalJSON() ([]byte, error) {
  514. type NoMethod List
  515. raw := NoMethod(*s)
  516. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  517. }
  518. type Output struct {
  519. // Id: The unique name for the predictive model.
  520. Id string `json:"id,omitempty"`
  521. // Kind: What kind of resource this is.
  522. Kind string `json:"kind,omitempty"`
  523. // OutputLabel: The most likely class label [Categorical models only].
  524. OutputLabel string `json:"outputLabel,omitempty"`
  525. // OutputMulti: A list of class labels with their estimated
  526. // probabilities [Categorical models only].
  527. OutputMulti []*OutputOutputMulti `json:"outputMulti,omitempty"`
  528. // OutputValue: The estimated regression value [Regression models only].
  529. OutputValue float64 `json:"outputValue,omitempty"`
  530. // SelfLink: A URL to re-request this resource.
  531. SelfLink string `json:"selfLink,omitempty"`
  532. // ServerResponse contains the HTTP response code and headers from the
  533. // server.
  534. googleapi.ServerResponse `json:"-"`
  535. // ForceSendFields is a list of field names (e.g. "Id") to
  536. // unconditionally include in API requests. By default, fields with
  537. // empty values are omitted from API requests. However, any non-pointer,
  538. // non-interface field appearing in ForceSendFields will be sent to the
  539. // server regardless of whether the field is empty or not. This may be
  540. // used to include empty fields in Patch requests.
  541. ForceSendFields []string `json:"-"`
  542. // NullFields is a list of field names (e.g. "Id") to include in API
  543. // requests with the JSON null value. By default, fields with empty
  544. // values are omitted from API requests. However, any field with an
  545. // empty value appearing in NullFields will be sent to the server as
  546. // null. It is an error if a field in this list has a non-empty value.
  547. // This may be used to include null fields in Patch requests.
  548. NullFields []string `json:"-"`
  549. }
  550. func (s *Output) MarshalJSON() ([]byte, error) {
  551. type NoMethod Output
  552. raw := NoMethod(*s)
  553. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  554. }
  555. func (s *Output) UnmarshalJSON(data []byte) error {
  556. type NoMethod Output
  557. var s1 struct {
  558. OutputValue gensupport.JSONFloat64 `json:"outputValue"`
  559. *NoMethod
  560. }
  561. s1.NoMethod = (*NoMethod)(s)
  562. if err := json.Unmarshal(data, &s1); err != nil {
  563. return err
  564. }
  565. s.OutputValue = float64(s1.OutputValue)
  566. return nil
  567. }
  568. type OutputOutputMulti struct {
  569. // Label: The class label.
  570. Label string `json:"label,omitempty"`
  571. // Score: The probability of the class label.
  572. Score float64 `json:"score,omitempty"`
  573. // ForceSendFields is a list of field names (e.g. "Label") to
  574. // unconditionally include in API requests. By default, fields with
  575. // empty values are omitted from API requests. However, any non-pointer,
  576. // non-interface field appearing in ForceSendFields will be sent to the
  577. // server regardless of whether the field is empty or not. This may be
  578. // used to include empty fields in Patch requests.
  579. ForceSendFields []string `json:"-"`
  580. // NullFields is a list of field names (e.g. "Label") to include in API
  581. // requests with the JSON null value. By default, fields with empty
  582. // values are omitted from API requests. However, any field with an
  583. // empty value appearing in NullFields will be sent to the server as
  584. // null. It is an error if a field in this list has a non-empty value.
  585. // This may be used to include null fields in Patch requests.
  586. NullFields []string `json:"-"`
  587. }
  588. func (s *OutputOutputMulti) MarshalJSON() ([]byte, error) {
  589. type NoMethod OutputOutputMulti
  590. raw := NoMethod(*s)
  591. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  592. }
  593. func (s *OutputOutputMulti) UnmarshalJSON(data []byte) error {
  594. type NoMethod OutputOutputMulti
  595. var s1 struct {
  596. Score gensupport.JSONFloat64 `json:"score"`
  597. *NoMethod
  598. }
  599. s1.NoMethod = (*NoMethod)(s)
  600. if err := json.Unmarshal(data, &s1); err != nil {
  601. return err
  602. }
  603. s.Score = float64(s1.Score)
  604. return nil
  605. }
  606. type Training struct {
  607. // Created: Insert time of the model (as a RFC 3339 timestamp).
  608. Created string `json:"created,omitempty"`
  609. // Id: The unique name for the predictive model.
  610. Id string `json:"id,omitempty"`
  611. // Kind: What kind of resource this is.
  612. Kind string `json:"kind,omitempty"`
  613. // ModelInfo: Model metadata.
  614. ModelInfo *TrainingModelInfo `json:"modelInfo,omitempty"`
  615. // ModelType: Type of predictive model (classification or regression)
  616. ModelType string `json:"modelType,omitempty"`
  617. // SelfLink: A URL to re-request this resource.
  618. SelfLink string `json:"selfLink,omitempty"`
  619. // StorageDataLocation: Google storage location of the training data
  620. // file.
  621. StorageDataLocation string `json:"storageDataLocation,omitempty"`
  622. // StoragePMMLLocation: Google storage location of the preprocessing
  623. // pmml file.
  624. StoragePMMLLocation string `json:"storagePMMLLocation,omitempty"`
  625. // StoragePMMLModelLocation: Google storage location of the pmml model
  626. // file.
  627. StoragePMMLModelLocation string `json:"storagePMMLModelLocation,omitempty"`
  628. // TrainingComplete: Training completion time (as a RFC 3339 timestamp).
  629. TrainingComplete string `json:"trainingComplete,omitempty"`
  630. // TrainingInstances: Instances to train model on.
  631. TrainingInstances []*TrainingTrainingInstances `json:"trainingInstances,omitempty"`
  632. // TrainingStatus: The current status of the training job. This can be
  633. // one of following: RUNNING; DONE; ERROR; ERROR: TRAINING JOB NOT FOUND
  634. TrainingStatus string `json:"trainingStatus,omitempty"`
  635. // Utility: A class weighting function, which allows the importance
  636. // weights for class labels to be specified [Categorical models only].
  637. Utility []map[string]float64 `json:"utility,omitempty"`
  638. // ServerResponse contains the HTTP response code and headers from the
  639. // server.
  640. googleapi.ServerResponse `json:"-"`
  641. // ForceSendFields is a list of field names (e.g. "Created") to
  642. // unconditionally include in API requests. By default, fields with
  643. // empty values are omitted from API requests. However, any non-pointer,
  644. // non-interface field appearing in ForceSendFields will be sent to the
  645. // server regardless of whether the field is empty or not. This may be
  646. // used to include empty fields in Patch requests.
  647. ForceSendFields []string `json:"-"`
  648. // NullFields is a list of field names (e.g. "Created") to include in
  649. // API requests with the JSON null value. By default, fields with empty
  650. // values are omitted from API requests. However, any field with an
  651. // empty value appearing in NullFields will be sent to the server as
  652. // null. It is an error if a field in this list has a non-empty value.
  653. // This may be used to include null fields in Patch requests.
  654. NullFields []string `json:"-"`
  655. }
  656. func (s *Training) MarshalJSON() ([]byte, error) {
  657. type NoMethod Training
  658. raw := NoMethod(*s)
  659. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  660. }
  661. // TrainingModelInfo: Model metadata.
  662. type TrainingModelInfo struct {
  663. // ClassWeightedAccuracy: Estimated accuracy of model taking utility
  664. // weights into account [Categorical models only].
  665. ClassWeightedAccuracy float64 `json:"classWeightedAccuracy,omitempty"`
  666. // ClassificationAccuracy: A number between 0.0 and 1.0, where 1.0 is
  667. // 100% accurate. This is an estimate, based on the amount and quality
  668. // of the training data, of the estimated prediction accuracy. You can
  669. // use this is a guide to decide whether the results are accurate enough
  670. // for your needs. This estimate will be more reliable if your real
  671. // input data is similar to your training data [Categorical models
  672. // only].
  673. ClassificationAccuracy float64 `json:"classificationAccuracy,omitempty"`
  674. // MeanSquaredError: An estimated mean squared error. The can be used to
  675. // measure the quality of the predicted model [Regression models only].
  676. MeanSquaredError float64 `json:"meanSquaredError,omitempty"`
  677. // ModelType: Type of predictive model (CLASSIFICATION or REGRESSION)
  678. ModelType string `json:"modelType,omitempty"`
  679. // NumberInstances: Number of valid data instances used in the trained
  680. // model.
  681. NumberInstances int64 `json:"numberInstances,omitempty,string"`
  682. // NumberLabels: Number of class labels in the trained model
  683. // [Categorical models only].
  684. NumberLabels int64 `json:"numberLabels,omitempty,string"`
  685. // ForceSendFields is a list of field names (e.g.
  686. // "ClassWeightedAccuracy") to unconditionally include in API requests.
  687. // By default, fields with empty values are omitted from API requests.
  688. // However, any non-pointer, non-interface field appearing in
  689. // ForceSendFields will be sent to the server regardless of whether the
  690. // field is empty or not. This may be used to include empty fields in
  691. // Patch requests.
  692. ForceSendFields []string `json:"-"`
  693. // NullFields is a list of field names (e.g. "ClassWeightedAccuracy") to
  694. // include in API requests with the JSON null value. By default, fields
  695. // with empty values are omitted from API requests. However, any field
  696. // with an empty value appearing in NullFields will be sent to the
  697. // server as null. It is an error if a field in this list has a
  698. // non-empty value. This may be used to include null fields in Patch
  699. // requests.
  700. NullFields []string `json:"-"`
  701. }
  702. func (s *TrainingModelInfo) MarshalJSON() ([]byte, error) {
  703. type NoMethod TrainingModelInfo
  704. raw := NoMethod(*s)
  705. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  706. }
  707. func (s *TrainingModelInfo) UnmarshalJSON(data []byte) error {
  708. type NoMethod TrainingModelInfo
  709. var s1 struct {
  710. ClassWeightedAccuracy gensupport.JSONFloat64 `json:"classWeightedAccuracy"`
  711. ClassificationAccuracy gensupport.JSONFloat64 `json:"classificationAccuracy"`
  712. MeanSquaredError gensupport.JSONFloat64 `json:"meanSquaredError"`
  713. *NoMethod
  714. }
  715. s1.NoMethod = (*NoMethod)(s)
  716. if err := json.Unmarshal(data, &s1); err != nil {
  717. return err
  718. }
  719. s.ClassWeightedAccuracy = float64(s1.ClassWeightedAccuracy)
  720. s.ClassificationAccuracy = float64(s1.ClassificationAccuracy)
  721. s.MeanSquaredError = float64(s1.MeanSquaredError)
  722. return nil
  723. }
  724. type TrainingTrainingInstances struct {
  725. // CsvInstance: The input features for this instance
  726. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  727. // Output: The generic output value - could be regression or class label
  728. Output string `json:"output,omitempty"`
  729. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  730. // unconditionally include in API requests. By default, fields with
  731. // empty values are omitted from API requests. However, any non-pointer,
  732. // non-interface field appearing in ForceSendFields will be sent to the
  733. // server regardless of whether the field is empty or not. This may be
  734. // used to include empty fields in Patch requests.
  735. ForceSendFields []string `json:"-"`
  736. // NullFields is a list of field names (e.g. "CsvInstance") to include
  737. // in API requests with the JSON null value. By default, fields with
  738. // empty values are omitted from API requests. However, any field with
  739. // an empty value appearing in NullFields will be sent to the server as
  740. // null. It is an error if a field in this list has a non-empty value.
  741. // This may be used to include null fields in Patch requests.
  742. NullFields []string `json:"-"`
  743. }
  744. func (s *TrainingTrainingInstances) MarshalJSON() ([]byte, error) {
  745. type NoMethod TrainingTrainingInstances
  746. raw := NoMethod(*s)
  747. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  748. }
  749. type Update struct {
  750. // CsvInstance: The input features for this instance
  751. CsvInstance []interface{} `json:"csvInstance,omitempty"`
  752. // Label: The class label of this instance
  753. Label string `json:"label,omitempty"`
  754. // Output: The generic output value - could be regression value or class
  755. // label
  756. Output string `json:"output,omitempty"`
  757. // ForceSendFields is a list of field names (e.g. "CsvInstance") to
  758. // unconditionally include in API requests. By default, fields with
  759. // empty values are omitted from API requests. However, any non-pointer,
  760. // non-interface field appearing in ForceSendFields will be sent to the
  761. // server regardless of whether the field is empty or not. This may be
  762. // used to include empty fields in Patch requests.
  763. ForceSendFields []string `json:"-"`
  764. // NullFields is a list of field names (e.g. "CsvInstance") to include
  765. // in API requests with the JSON null value. By default, fields with
  766. // empty values are omitted from API requests. However, any field with
  767. // an empty value appearing in NullFields will be sent to the server as
  768. // null. It is an error if a field in this list has a non-empty value.
  769. // This may be used to include null fields in Patch requests.
  770. NullFields []string `json:"-"`
  771. }
  772. func (s *Update) MarshalJSON() ([]byte, error) {
  773. type NoMethod Update
  774. raw := NoMethod(*s)
  775. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  776. }
  777. // method id "prediction.hostedmodels.predict":
  778. type HostedmodelsPredictCall struct {
  779. s *Service
  780. hostedModelName string
  781. input *Input
  782. urlParams_ gensupport.URLParams
  783. ctx_ context.Context
  784. header_ http.Header
  785. }
  786. // Predict: Submit input and request an output against a hosted model.
  787. func (r *HostedmodelsService) Predict(hostedModelName string, input *Input) *HostedmodelsPredictCall {
  788. c := &HostedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  789. c.hostedModelName = hostedModelName
  790. c.input = input
  791. return c
  792. }
  793. // Fields allows partial responses to be retrieved. See
  794. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  795. // for more information.
  796. func (c *HostedmodelsPredictCall) Fields(s ...googleapi.Field) *HostedmodelsPredictCall {
  797. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  798. return c
  799. }
  800. // Context sets the context to be used in this call's Do method. Any
  801. // pending HTTP request will be aborted if the provided context is
  802. // canceled.
  803. func (c *HostedmodelsPredictCall) Context(ctx context.Context) *HostedmodelsPredictCall {
  804. c.ctx_ = ctx
  805. return c
  806. }
  807. // Header returns an http.Header that can be modified by the caller to
  808. // add HTTP headers to the request.
  809. func (c *HostedmodelsPredictCall) Header() http.Header {
  810. if c.header_ == nil {
  811. c.header_ = make(http.Header)
  812. }
  813. return c.header_
  814. }
  815. func (c *HostedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  816. reqHeaders := make(http.Header)
  817. for k, v := range c.header_ {
  818. reqHeaders[k] = v
  819. }
  820. reqHeaders.Set("User-Agent", c.s.userAgent())
  821. var body io.Reader = nil
  822. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  823. if err != nil {
  824. return nil, err
  825. }
  826. reqHeaders.Set("Content-Type", "application/json")
  827. c.urlParams_.Set("alt", alt)
  828. urls := googleapi.ResolveRelative(c.s.BasePath, "hostedmodels/{hostedModelName}/predict")
  829. urls += "?" + c.urlParams_.Encode()
  830. req, _ := http.NewRequest("POST", urls, body)
  831. req.Header = reqHeaders
  832. googleapi.Expand(req.URL, map[string]string{
  833. "hostedModelName": c.hostedModelName,
  834. })
  835. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  836. }
  837. // Do executes the "prediction.hostedmodels.predict" call.
  838. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  839. // code is an error. Response headers are in either
  840. // *Output.ServerResponse.Header or (if a response was returned at all)
  841. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  842. // check whether the returned error was because http.StatusNotModified
  843. // was returned.
  844. func (c *HostedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  845. gensupport.SetOptions(c.urlParams_, opts...)
  846. res, err := c.doRequest("json")
  847. if res != nil && res.StatusCode == http.StatusNotModified {
  848. if res.Body != nil {
  849. res.Body.Close()
  850. }
  851. return nil, &googleapi.Error{
  852. Code: res.StatusCode,
  853. Header: res.Header,
  854. }
  855. }
  856. if err != nil {
  857. return nil, err
  858. }
  859. defer googleapi.CloseBody(res)
  860. if err := googleapi.CheckResponse(res); err != nil {
  861. return nil, err
  862. }
  863. ret := &Output{
  864. ServerResponse: googleapi.ServerResponse{
  865. Header: res.Header,
  866. HTTPStatusCode: res.StatusCode,
  867. },
  868. }
  869. target := &ret
  870. if err := gensupport.DecodeResponse(target, res); err != nil {
  871. return nil, err
  872. }
  873. return ret, nil
  874. // {
  875. // "description": "Submit input and request an output against a hosted model.",
  876. // "httpMethod": "POST",
  877. // "id": "prediction.hostedmodels.predict",
  878. // "parameterOrder": [
  879. // "hostedModelName"
  880. // ],
  881. // "parameters": {
  882. // "hostedModelName": {
  883. // "description": "The name of a hosted model.",
  884. // "location": "path",
  885. // "required": true,
  886. // "type": "string"
  887. // }
  888. // },
  889. // "path": "hostedmodels/{hostedModelName}/predict",
  890. // "request": {
  891. // "$ref": "Input"
  892. // },
  893. // "response": {
  894. // "$ref": "Output"
  895. // },
  896. // "scopes": [
  897. // "https://www.googleapis.com/auth/prediction"
  898. // ]
  899. // }
  900. }
  901. // method id "prediction.trainedmodels.analyze":
  902. type TrainedmodelsAnalyzeCall struct {
  903. s *Service
  904. id string
  905. urlParams_ gensupport.URLParams
  906. ifNoneMatch_ string
  907. ctx_ context.Context
  908. header_ http.Header
  909. }
  910. // Analyze: Get analysis of the model and the data the model was trained
  911. // on.
  912. func (r *TrainedmodelsService) Analyze(id string) *TrainedmodelsAnalyzeCall {
  913. c := &TrainedmodelsAnalyzeCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  914. c.id = id
  915. return c
  916. }
  917. // Fields allows partial responses to be retrieved. See
  918. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  919. // for more information.
  920. func (c *TrainedmodelsAnalyzeCall) Fields(s ...googleapi.Field) *TrainedmodelsAnalyzeCall {
  921. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  922. return c
  923. }
  924. // IfNoneMatch sets the optional parameter which makes the operation
  925. // fail if the object's ETag matches the given value. This is useful for
  926. // getting updates only after the object has changed since the last
  927. // request. Use googleapi.IsNotModified to check whether the response
  928. // error from Do is the result of In-None-Match.
  929. func (c *TrainedmodelsAnalyzeCall) IfNoneMatch(entityTag string) *TrainedmodelsAnalyzeCall {
  930. c.ifNoneMatch_ = entityTag
  931. return c
  932. }
  933. // Context sets the context to be used in this call's Do method. Any
  934. // pending HTTP request will be aborted if the provided context is
  935. // canceled.
  936. func (c *TrainedmodelsAnalyzeCall) Context(ctx context.Context) *TrainedmodelsAnalyzeCall {
  937. c.ctx_ = ctx
  938. return c
  939. }
  940. // Header returns an http.Header that can be modified by the caller to
  941. // add HTTP headers to the request.
  942. func (c *TrainedmodelsAnalyzeCall) Header() http.Header {
  943. if c.header_ == nil {
  944. c.header_ = make(http.Header)
  945. }
  946. return c.header_
  947. }
  948. func (c *TrainedmodelsAnalyzeCall) doRequest(alt string) (*http.Response, error) {
  949. reqHeaders := make(http.Header)
  950. for k, v := range c.header_ {
  951. reqHeaders[k] = v
  952. }
  953. reqHeaders.Set("User-Agent", c.s.userAgent())
  954. if c.ifNoneMatch_ != "" {
  955. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  956. }
  957. var body io.Reader = nil
  958. c.urlParams_.Set("alt", alt)
  959. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/analyze")
  960. urls += "?" + c.urlParams_.Encode()
  961. req, _ := http.NewRequest("GET", urls, body)
  962. req.Header = reqHeaders
  963. googleapi.Expand(req.URL, map[string]string{
  964. "id": c.id,
  965. })
  966. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  967. }
  968. // Do executes the "prediction.trainedmodels.analyze" call.
  969. // Exactly one of *Analyze or error will be non-nil. Any non-2xx status
  970. // code is an error. Response headers are in either
  971. // *Analyze.ServerResponse.Header or (if a response was returned at all)
  972. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  973. // check whether the returned error was because http.StatusNotModified
  974. // was returned.
  975. func (c *TrainedmodelsAnalyzeCall) Do(opts ...googleapi.CallOption) (*Analyze, error) {
  976. gensupport.SetOptions(c.urlParams_, opts...)
  977. res, err := c.doRequest("json")
  978. if res != nil && res.StatusCode == http.StatusNotModified {
  979. if res.Body != nil {
  980. res.Body.Close()
  981. }
  982. return nil, &googleapi.Error{
  983. Code: res.StatusCode,
  984. Header: res.Header,
  985. }
  986. }
  987. if err != nil {
  988. return nil, err
  989. }
  990. defer googleapi.CloseBody(res)
  991. if err := googleapi.CheckResponse(res); err != nil {
  992. return nil, err
  993. }
  994. ret := &Analyze{
  995. ServerResponse: googleapi.ServerResponse{
  996. Header: res.Header,
  997. HTTPStatusCode: res.StatusCode,
  998. },
  999. }
  1000. target := &ret
  1001. if err := gensupport.DecodeResponse(target, res); err != nil {
  1002. return nil, err
  1003. }
  1004. return ret, nil
  1005. // {
  1006. // "description": "Get analysis of the model and the data the model was trained on.",
  1007. // "httpMethod": "GET",
  1008. // "id": "prediction.trainedmodels.analyze",
  1009. // "parameterOrder": [
  1010. // "id"
  1011. // ],
  1012. // "parameters": {
  1013. // "id": {
  1014. // "description": "The unique name for the predictive model.",
  1015. // "location": "path",
  1016. // "required": true,
  1017. // "type": "string"
  1018. // }
  1019. // },
  1020. // "path": "trainedmodels/{id}/analyze",
  1021. // "response": {
  1022. // "$ref": "Analyze"
  1023. // },
  1024. // "scopes": [
  1025. // "https://www.googleapis.com/auth/prediction"
  1026. // ]
  1027. // }
  1028. }
  1029. // method id "prediction.trainedmodels.delete":
  1030. type TrainedmodelsDeleteCall struct {
  1031. s *Service
  1032. id string
  1033. urlParams_ gensupport.URLParams
  1034. ctx_ context.Context
  1035. header_ http.Header
  1036. }
  1037. // Delete: Delete a trained model.
  1038. func (r *TrainedmodelsService) Delete(id string) *TrainedmodelsDeleteCall {
  1039. c := &TrainedmodelsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1040. c.id = id
  1041. return c
  1042. }
  1043. // Fields allows partial responses to be retrieved. See
  1044. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1045. // for more information.
  1046. func (c *TrainedmodelsDeleteCall) Fields(s ...googleapi.Field) *TrainedmodelsDeleteCall {
  1047. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1048. return c
  1049. }
  1050. // Context sets the context to be used in this call's Do method. Any
  1051. // pending HTTP request will be aborted if the provided context is
  1052. // canceled.
  1053. func (c *TrainedmodelsDeleteCall) Context(ctx context.Context) *TrainedmodelsDeleteCall {
  1054. c.ctx_ = ctx
  1055. return c
  1056. }
  1057. // Header returns an http.Header that can be modified by the caller to
  1058. // add HTTP headers to the request.
  1059. func (c *TrainedmodelsDeleteCall) Header() http.Header {
  1060. if c.header_ == nil {
  1061. c.header_ = make(http.Header)
  1062. }
  1063. return c.header_
  1064. }
  1065. func (c *TrainedmodelsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1066. reqHeaders := make(http.Header)
  1067. for k, v := range c.header_ {
  1068. reqHeaders[k] = v
  1069. }
  1070. reqHeaders.Set("User-Agent", c.s.userAgent())
  1071. var body io.Reader = nil
  1072. c.urlParams_.Set("alt", alt)
  1073. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  1074. urls += "?" + c.urlParams_.Encode()
  1075. req, _ := http.NewRequest("DELETE", urls, body)
  1076. req.Header = reqHeaders
  1077. googleapi.Expand(req.URL, map[string]string{
  1078. "id": c.id,
  1079. })
  1080. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1081. }
  1082. // Do executes the "prediction.trainedmodels.delete" call.
  1083. func (c *TrainedmodelsDeleteCall) Do(opts ...googleapi.CallOption) error {
  1084. gensupport.SetOptions(c.urlParams_, opts...)
  1085. res, err := c.doRequest("json")
  1086. if err != nil {
  1087. return err
  1088. }
  1089. defer googleapi.CloseBody(res)
  1090. if err := googleapi.CheckResponse(res); err != nil {
  1091. return err
  1092. }
  1093. return nil
  1094. // {
  1095. // "description": "Delete a trained model.",
  1096. // "httpMethod": "DELETE",
  1097. // "id": "prediction.trainedmodels.delete",
  1098. // "parameterOrder": [
  1099. // "id"
  1100. // ],
  1101. // "parameters": {
  1102. // "id": {
  1103. // "description": "The unique name for the predictive model.",
  1104. // "location": "path",
  1105. // "required": true,
  1106. // "type": "string"
  1107. // }
  1108. // },
  1109. // "path": "trainedmodels/{id}",
  1110. // "scopes": [
  1111. // "https://www.googleapis.com/auth/prediction"
  1112. // ]
  1113. // }
  1114. }
  1115. // method id "prediction.trainedmodels.get":
  1116. type TrainedmodelsGetCall struct {
  1117. s *Service
  1118. id string
  1119. urlParams_ gensupport.URLParams
  1120. ifNoneMatch_ string
  1121. ctx_ context.Context
  1122. header_ http.Header
  1123. }
  1124. // Get: Check training status of your model.
  1125. func (r *TrainedmodelsService) Get(id string) *TrainedmodelsGetCall {
  1126. c := &TrainedmodelsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1127. c.id = id
  1128. return c
  1129. }
  1130. // Fields allows partial responses to be retrieved. See
  1131. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1132. // for more information.
  1133. func (c *TrainedmodelsGetCall) Fields(s ...googleapi.Field) *TrainedmodelsGetCall {
  1134. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1135. return c
  1136. }
  1137. // IfNoneMatch sets the optional parameter which makes the operation
  1138. // fail if the object's ETag matches the given value. This is useful for
  1139. // getting updates only after the object has changed since the last
  1140. // request. Use googleapi.IsNotModified to check whether the response
  1141. // error from Do is the result of In-None-Match.
  1142. func (c *TrainedmodelsGetCall) IfNoneMatch(entityTag string) *TrainedmodelsGetCall {
  1143. c.ifNoneMatch_ = entityTag
  1144. return c
  1145. }
  1146. // Context sets the context to be used in this call's Do method. Any
  1147. // pending HTTP request will be aborted if the provided context is
  1148. // canceled.
  1149. func (c *TrainedmodelsGetCall) Context(ctx context.Context) *TrainedmodelsGetCall {
  1150. c.ctx_ = ctx
  1151. return c
  1152. }
  1153. // Header returns an http.Header that can be modified by the caller to
  1154. // add HTTP headers to the request.
  1155. func (c *TrainedmodelsGetCall) Header() http.Header {
  1156. if c.header_ == nil {
  1157. c.header_ = make(http.Header)
  1158. }
  1159. return c.header_
  1160. }
  1161. func (c *TrainedmodelsGetCall) doRequest(alt string) (*http.Response, error) {
  1162. reqHeaders := make(http.Header)
  1163. for k, v := range c.header_ {
  1164. reqHeaders[k] = v
  1165. }
  1166. reqHeaders.Set("User-Agent", c.s.userAgent())
  1167. if c.ifNoneMatch_ != "" {
  1168. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1169. }
  1170. var body io.Reader = nil
  1171. c.urlParams_.Set("alt", alt)
  1172. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  1173. urls += "?" + c.urlParams_.Encode()
  1174. req, _ := http.NewRequest("GET", urls, body)
  1175. req.Header = reqHeaders
  1176. googleapi.Expand(req.URL, map[string]string{
  1177. "id": c.id,
  1178. })
  1179. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1180. }
  1181. // Do executes the "prediction.trainedmodels.get" call.
  1182. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  1183. // code is an error. Response headers are in either
  1184. // *Training.ServerResponse.Header or (if a response was returned at
  1185. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1186. // to check whether the returned error was because
  1187. // http.StatusNotModified was returned.
  1188. func (c *TrainedmodelsGetCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  1189. gensupport.SetOptions(c.urlParams_, opts...)
  1190. res, err := c.doRequest("json")
  1191. if res != nil && res.StatusCode == http.StatusNotModified {
  1192. if res.Body != nil {
  1193. res.Body.Close()
  1194. }
  1195. return nil, &googleapi.Error{
  1196. Code: res.StatusCode,
  1197. Header: res.Header,
  1198. }
  1199. }
  1200. if err != nil {
  1201. return nil, err
  1202. }
  1203. defer googleapi.CloseBody(res)
  1204. if err := googleapi.CheckResponse(res); err != nil {
  1205. return nil, err
  1206. }
  1207. ret := &Training{
  1208. ServerResponse: googleapi.ServerResponse{
  1209. Header: res.Header,
  1210. HTTPStatusCode: res.StatusCode,
  1211. },
  1212. }
  1213. target := &ret
  1214. if err := gensupport.DecodeResponse(target, res); err != nil {
  1215. return nil, err
  1216. }
  1217. return ret, nil
  1218. // {
  1219. // "description": "Check training status of your model.",
  1220. // "httpMethod": "GET",
  1221. // "id": "prediction.trainedmodels.get",
  1222. // "parameterOrder": [
  1223. // "id"
  1224. // ],
  1225. // "parameters": {
  1226. // "id": {
  1227. // "description": "The unique name for the predictive model.",
  1228. // "location": "path",
  1229. // "required": true,
  1230. // "type": "string"
  1231. // }
  1232. // },
  1233. // "path": "trainedmodels/{id}",
  1234. // "response": {
  1235. // "$ref": "Training"
  1236. // },
  1237. // "scopes": [
  1238. // "https://www.googleapis.com/auth/prediction"
  1239. // ]
  1240. // }
  1241. }
  1242. // method id "prediction.trainedmodels.insert":
  1243. type TrainedmodelsInsertCall struct {
  1244. s *Service
  1245. training *Training
  1246. urlParams_ gensupport.URLParams
  1247. ctx_ context.Context
  1248. header_ http.Header
  1249. }
  1250. // Insert: Begin training your model.
  1251. func (r *TrainedmodelsService) Insert(training *Training) *TrainedmodelsInsertCall {
  1252. c := &TrainedmodelsInsertCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1253. c.training = training
  1254. return c
  1255. }
  1256. // Fields allows partial responses to be retrieved. See
  1257. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1258. // for more information.
  1259. func (c *TrainedmodelsInsertCall) Fields(s ...googleapi.Field) *TrainedmodelsInsertCall {
  1260. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1261. return c
  1262. }
  1263. // Context sets the context to be used in this call's Do method. Any
  1264. // pending HTTP request will be aborted if the provided context is
  1265. // canceled.
  1266. func (c *TrainedmodelsInsertCall) Context(ctx context.Context) *TrainedmodelsInsertCall {
  1267. c.ctx_ = ctx
  1268. return c
  1269. }
  1270. // Header returns an http.Header that can be modified by the caller to
  1271. // add HTTP headers to the request.
  1272. func (c *TrainedmodelsInsertCall) Header() http.Header {
  1273. if c.header_ == nil {
  1274. c.header_ = make(http.Header)
  1275. }
  1276. return c.header_
  1277. }
  1278. func (c *TrainedmodelsInsertCall) doRequest(alt string) (*http.Response, error) {
  1279. reqHeaders := make(http.Header)
  1280. for k, v := range c.header_ {
  1281. reqHeaders[k] = v
  1282. }
  1283. reqHeaders.Set("User-Agent", c.s.userAgent())
  1284. var body io.Reader = nil
  1285. body, err := googleapi.WithoutDataWrapper.JSONReader(c.training)
  1286. if err != nil {
  1287. return nil, err
  1288. }
  1289. reqHeaders.Set("Content-Type", "application/json")
  1290. c.urlParams_.Set("alt", alt)
  1291. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels")
  1292. urls += "?" + c.urlParams_.Encode()
  1293. req, _ := http.NewRequest("POST", urls, body)
  1294. req.Header = reqHeaders
  1295. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1296. }
  1297. // Do executes the "prediction.trainedmodels.insert" call.
  1298. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  1299. // code is an error. Response headers are in either
  1300. // *Training.ServerResponse.Header or (if a response was returned at
  1301. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1302. // to check whether the returned error was because
  1303. // http.StatusNotModified was returned.
  1304. func (c *TrainedmodelsInsertCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  1305. gensupport.SetOptions(c.urlParams_, opts...)
  1306. res, err := c.doRequest("json")
  1307. if res != nil && res.StatusCode == http.StatusNotModified {
  1308. if res.Body != nil {
  1309. res.Body.Close()
  1310. }
  1311. return nil, &googleapi.Error{
  1312. Code: res.StatusCode,
  1313. Header: res.Header,
  1314. }
  1315. }
  1316. if err != nil {
  1317. return nil, err
  1318. }
  1319. defer googleapi.CloseBody(res)
  1320. if err := googleapi.CheckResponse(res); err != nil {
  1321. return nil, err
  1322. }
  1323. ret := &Training{
  1324. ServerResponse: googleapi.ServerResponse{
  1325. Header: res.Header,
  1326. HTTPStatusCode: res.StatusCode,
  1327. },
  1328. }
  1329. target := &ret
  1330. if err := gensupport.DecodeResponse(target, res); err != nil {
  1331. return nil, err
  1332. }
  1333. return ret, nil
  1334. // {
  1335. // "description": "Begin training your model.",
  1336. // "httpMethod": "POST",
  1337. // "id": "prediction.trainedmodels.insert",
  1338. // "path": "trainedmodels",
  1339. // "request": {
  1340. // "$ref": "Training"
  1341. // },
  1342. // "response": {
  1343. // "$ref": "Training"
  1344. // },
  1345. // "scopes": [
  1346. // "https://www.googleapis.com/auth/devstorage.full_control",
  1347. // "https://www.googleapis.com/auth/devstorage.read_only",
  1348. // "https://www.googleapis.com/auth/devstorage.read_write",
  1349. // "https://www.googleapis.com/auth/prediction"
  1350. // ]
  1351. // }
  1352. }
  1353. // method id "prediction.trainedmodels.list":
  1354. type TrainedmodelsListCall struct {
  1355. s *Service
  1356. urlParams_ gensupport.URLParams
  1357. ifNoneMatch_ string
  1358. ctx_ context.Context
  1359. header_ http.Header
  1360. }
  1361. // List: List available models.
  1362. func (r *TrainedmodelsService) List() *TrainedmodelsListCall {
  1363. c := &TrainedmodelsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1364. return c
  1365. }
  1366. // MaxResults sets the optional parameter "maxResults": Maximum number
  1367. // of results to return
  1368. func (c *TrainedmodelsListCall) MaxResults(maxResults int64) *TrainedmodelsListCall {
  1369. c.urlParams_.Set("maxResults", fmt.Sprint(maxResults))
  1370. return c
  1371. }
  1372. // PageToken sets the optional parameter "pageToken": Pagination token
  1373. func (c *TrainedmodelsListCall) PageToken(pageToken string) *TrainedmodelsListCall {
  1374. c.urlParams_.Set("pageToken", pageToken)
  1375. return c
  1376. }
  1377. // Fields allows partial responses to be retrieved. See
  1378. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1379. // for more information.
  1380. func (c *TrainedmodelsListCall) Fields(s ...googleapi.Field) *TrainedmodelsListCall {
  1381. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1382. return c
  1383. }
  1384. // IfNoneMatch sets the optional parameter which makes the operation
  1385. // fail if the object's ETag matches the given value. This is useful for
  1386. // getting updates only after the object has changed since the last
  1387. // request. Use googleapi.IsNotModified to check whether the response
  1388. // error from Do is the result of In-None-Match.
  1389. func (c *TrainedmodelsListCall) IfNoneMatch(entityTag string) *TrainedmodelsListCall {
  1390. c.ifNoneMatch_ = entityTag
  1391. return c
  1392. }
  1393. // Context sets the context to be used in this call's Do method. Any
  1394. // pending HTTP request will be aborted if the provided context is
  1395. // canceled.
  1396. func (c *TrainedmodelsListCall) Context(ctx context.Context) *TrainedmodelsListCall {
  1397. c.ctx_ = ctx
  1398. return c
  1399. }
  1400. // Header returns an http.Header that can be modified by the caller to
  1401. // add HTTP headers to the request.
  1402. func (c *TrainedmodelsListCall) Header() http.Header {
  1403. if c.header_ == nil {
  1404. c.header_ = make(http.Header)
  1405. }
  1406. return c.header_
  1407. }
  1408. func (c *TrainedmodelsListCall) doRequest(alt string) (*http.Response, error) {
  1409. reqHeaders := make(http.Header)
  1410. for k, v := range c.header_ {
  1411. reqHeaders[k] = v
  1412. }
  1413. reqHeaders.Set("User-Agent", c.s.userAgent())
  1414. if c.ifNoneMatch_ != "" {
  1415. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  1416. }
  1417. var body io.Reader = nil
  1418. c.urlParams_.Set("alt", alt)
  1419. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/list")
  1420. urls += "?" + c.urlParams_.Encode()
  1421. req, _ := http.NewRequest("GET", urls, body)
  1422. req.Header = reqHeaders
  1423. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1424. }
  1425. // Do executes the "prediction.trainedmodels.list" call.
  1426. // Exactly one of *List or error will be non-nil. Any non-2xx status
  1427. // code is an error. Response headers are in either
  1428. // *List.ServerResponse.Header or (if a response was returned at all) in
  1429. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1430. // whether the returned error was because http.StatusNotModified was
  1431. // returned.
  1432. func (c *TrainedmodelsListCall) Do(opts ...googleapi.CallOption) (*List, error) {
  1433. gensupport.SetOptions(c.urlParams_, opts...)
  1434. res, err := c.doRequest("json")
  1435. if res != nil && res.StatusCode == http.StatusNotModified {
  1436. if res.Body != nil {
  1437. res.Body.Close()
  1438. }
  1439. return nil, &googleapi.Error{
  1440. Code: res.StatusCode,
  1441. Header: res.Header,
  1442. }
  1443. }
  1444. if err != nil {
  1445. return nil, err
  1446. }
  1447. defer googleapi.CloseBody(res)
  1448. if err := googleapi.CheckResponse(res); err != nil {
  1449. return nil, err
  1450. }
  1451. ret := &List{
  1452. ServerResponse: googleapi.ServerResponse{
  1453. Header: res.Header,
  1454. HTTPStatusCode: res.StatusCode,
  1455. },
  1456. }
  1457. target := &ret
  1458. if err := gensupport.DecodeResponse(target, res); err != nil {
  1459. return nil, err
  1460. }
  1461. return ret, nil
  1462. // {
  1463. // "description": "List available models.",
  1464. // "httpMethod": "GET",
  1465. // "id": "prediction.trainedmodels.list",
  1466. // "parameters": {
  1467. // "maxResults": {
  1468. // "description": "Maximum number of results to return",
  1469. // "format": "uint32",
  1470. // "location": "query",
  1471. // "minimum": "0",
  1472. // "type": "integer"
  1473. // },
  1474. // "pageToken": {
  1475. // "description": "Pagination token",
  1476. // "location": "query",
  1477. // "type": "string"
  1478. // }
  1479. // },
  1480. // "path": "trainedmodels/list",
  1481. // "response": {
  1482. // "$ref": "List"
  1483. // },
  1484. // "scopes": [
  1485. // "https://www.googleapis.com/auth/prediction"
  1486. // ]
  1487. // }
  1488. }
  1489. // Pages invokes f for each page of results.
  1490. // A non-nil error returned from f will halt the iteration.
  1491. // The provided context supersedes any context provided to the Context method.
  1492. func (c *TrainedmodelsListCall) Pages(ctx context.Context, f func(*List) error) error {
  1493. c.ctx_ = ctx
  1494. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1495. for {
  1496. x, err := c.Do()
  1497. if err != nil {
  1498. return err
  1499. }
  1500. if err := f(x); err != nil {
  1501. return err
  1502. }
  1503. if x.NextPageToken == "" {
  1504. return nil
  1505. }
  1506. c.PageToken(x.NextPageToken)
  1507. }
  1508. }
  1509. // method id "prediction.trainedmodels.predict":
  1510. type TrainedmodelsPredictCall struct {
  1511. s *Service
  1512. id string
  1513. input *Input
  1514. urlParams_ gensupport.URLParams
  1515. ctx_ context.Context
  1516. header_ http.Header
  1517. }
  1518. // Predict: Submit model id and request a prediction.
  1519. func (r *TrainedmodelsService) Predict(id string, input *Input) *TrainedmodelsPredictCall {
  1520. c := &TrainedmodelsPredictCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1521. c.id = id
  1522. c.input = input
  1523. return c
  1524. }
  1525. // Fields allows partial responses to be retrieved. See
  1526. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1527. // for more information.
  1528. func (c *TrainedmodelsPredictCall) Fields(s ...googleapi.Field) *TrainedmodelsPredictCall {
  1529. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1530. return c
  1531. }
  1532. // Context sets the context to be used in this call's Do method. Any
  1533. // pending HTTP request will be aborted if the provided context is
  1534. // canceled.
  1535. func (c *TrainedmodelsPredictCall) Context(ctx context.Context) *TrainedmodelsPredictCall {
  1536. c.ctx_ = ctx
  1537. return c
  1538. }
  1539. // Header returns an http.Header that can be modified by the caller to
  1540. // add HTTP headers to the request.
  1541. func (c *TrainedmodelsPredictCall) Header() http.Header {
  1542. if c.header_ == nil {
  1543. c.header_ = make(http.Header)
  1544. }
  1545. return c.header_
  1546. }
  1547. func (c *TrainedmodelsPredictCall) doRequest(alt string) (*http.Response, error) {
  1548. reqHeaders := make(http.Header)
  1549. for k, v := range c.header_ {
  1550. reqHeaders[k] = v
  1551. }
  1552. reqHeaders.Set("User-Agent", c.s.userAgent())
  1553. var body io.Reader = nil
  1554. body, err := googleapi.WithoutDataWrapper.JSONReader(c.input)
  1555. if err != nil {
  1556. return nil, err
  1557. }
  1558. reqHeaders.Set("Content-Type", "application/json")
  1559. c.urlParams_.Set("alt", alt)
  1560. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}/predict")
  1561. urls += "?" + c.urlParams_.Encode()
  1562. req, _ := http.NewRequest("POST", urls, body)
  1563. req.Header = reqHeaders
  1564. googleapi.Expand(req.URL, map[string]string{
  1565. "id": c.id,
  1566. })
  1567. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1568. }
  1569. // Do executes the "prediction.trainedmodels.predict" call.
  1570. // Exactly one of *Output or error will be non-nil. Any non-2xx status
  1571. // code is an error. Response headers are in either
  1572. // *Output.ServerResponse.Header or (if a response was returned at all)
  1573. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1574. // check whether the returned error was because http.StatusNotModified
  1575. // was returned.
  1576. func (c *TrainedmodelsPredictCall) Do(opts ...googleapi.CallOption) (*Output, error) {
  1577. gensupport.SetOptions(c.urlParams_, opts...)
  1578. res, err := c.doRequest("json")
  1579. if res != nil && res.StatusCode == http.StatusNotModified {
  1580. if res.Body != nil {
  1581. res.Body.Close()
  1582. }
  1583. return nil, &googleapi.Error{
  1584. Code: res.StatusCode,
  1585. Header: res.Header,
  1586. }
  1587. }
  1588. if err != nil {
  1589. return nil, err
  1590. }
  1591. defer googleapi.CloseBody(res)
  1592. if err := googleapi.CheckResponse(res); err != nil {
  1593. return nil, err
  1594. }
  1595. ret := &Output{
  1596. ServerResponse: googleapi.ServerResponse{
  1597. Header: res.Header,
  1598. HTTPStatusCode: res.StatusCode,
  1599. },
  1600. }
  1601. target := &ret
  1602. if err := gensupport.DecodeResponse(target, res); err != nil {
  1603. return nil, err
  1604. }
  1605. return ret, nil
  1606. // {
  1607. // "description": "Submit model id and request a prediction.",
  1608. // "httpMethod": "POST",
  1609. // "id": "prediction.trainedmodels.predict",
  1610. // "parameterOrder": [
  1611. // "id"
  1612. // ],
  1613. // "parameters": {
  1614. // "id": {
  1615. // "description": "The unique name for the predictive model.",
  1616. // "location": "path",
  1617. // "required": true,
  1618. // "type": "string"
  1619. // }
  1620. // },
  1621. // "path": "trainedmodels/{id}/predict",
  1622. // "request": {
  1623. // "$ref": "Input"
  1624. // },
  1625. // "response": {
  1626. // "$ref": "Output"
  1627. // },
  1628. // "scopes": [
  1629. // "https://www.googleapis.com/auth/prediction"
  1630. // ]
  1631. // }
  1632. }
  1633. // method id "prediction.trainedmodels.update":
  1634. type TrainedmodelsUpdateCall struct {
  1635. s *Service
  1636. id string
  1637. update *Update
  1638. urlParams_ gensupport.URLParams
  1639. ctx_ context.Context
  1640. header_ http.Header
  1641. }
  1642. // Update: Add new data to a trained model.
  1643. func (r *TrainedmodelsService) Update(id string, update *Update) *TrainedmodelsUpdateCall {
  1644. c := &TrainedmodelsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1645. c.id = id
  1646. c.update = update
  1647. return c
  1648. }
  1649. // Fields allows partial responses to be retrieved. See
  1650. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1651. // for more information.
  1652. func (c *TrainedmodelsUpdateCall) Fields(s ...googleapi.Field) *TrainedmodelsUpdateCall {
  1653. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1654. return c
  1655. }
  1656. // Context sets the context to be used in this call's Do method. Any
  1657. // pending HTTP request will be aborted if the provided context is
  1658. // canceled.
  1659. func (c *TrainedmodelsUpdateCall) Context(ctx context.Context) *TrainedmodelsUpdateCall {
  1660. c.ctx_ = ctx
  1661. return c
  1662. }
  1663. // Header returns an http.Header that can be modified by the caller to
  1664. // add HTTP headers to the request.
  1665. func (c *TrainedmodelsUpdateCall) Header() http.Header {
  1666. if c.header_ == nil {
  1667. c.header_ = make(http.Header)
  1668. }
  1669. return c.header_
  1670. }
  1671. func (c *TrainedmodelsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1672. reqHeaders := make(http.Header)
  1673. for k, v := range c.header_ {
  1674. reqHeaders[k] = v
  1675. }
  1676. reqHeaders.Set("User-Agent", c.s.userAgent())
  1677. var body io.Reader = nil
  1678. body, err := googleapi.WithoutDataWrapper.JSONReader(c.update)
  1679. if err != nil {
  1680. return nil, err
  1681. }
  1682. reqHeaders.Set("Content-Type", "application/json")
  1683. c.urlParams_.Set("alt", alt)
  1684. urls := googleapi.ResolveRelative(c.s.BasePath, "trainedmodels/{id}")
  1685. urls += "?" + c.urlParams_.Encode()
  1686. req, _ := http.NewRequest("PUT", urls, body)
  1687. req.Header = reqHeaders
  1688. googleapi.Expand(req.URL, map[string]string{
  1689. "id": c.id,
  1690. })
  1691. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  1692. }
  1693. // Do executes the "prediction.trainedmodels.update" call.
  1694. // Exactly one of *Training or error will be non-nil. Any non-2xx status
  1695. // code is an error. Response headers are in either
  1696. // *Training.ServerResponse.Header or (if a response was returned at
  1697. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1698. // to check whether the returned error was because
  1699. // http.StatusNotModified was returned.
  1700. func (c *TrainedmodelsUpdateCall) Do(opts ...googleapi.CallOption) (*Training, error) {
  1701. gensupport.SetOptions(c.urlParams_, opts...)
  1702. res, err := c.doRequest("json")
  1703. if res != nil && res.StatusCode == http.StatusNotModified {
  1704. if res.Body != nil {
  1705. res.Body.Close()
  1706. }
  1707. return nil, &googleapi.Error{
  1708. Code: res.StatusCode,
  1709. Header: res.Header,
  1710. }
  1711. }
  1712. if err != nil {
  1713. return nil, err
  1714. }
  1715. defer googleapi.CloseBody(res)
  1716. if err := googleapi.CheckResponse(res); err != nil {
  1717. return nil, err
  1718. }
  1719. ret := &Training{
  1720. ServerResponse: googleapi.ServerResponse{
  1721. Header: res.Header,
  1722. HTTPStatusCode: res.StatusCode,
  1723. },
  1724. }
  1725. target := &ret
  1726. if err := gensupport.DecodeResponse(target, res); err != nil {
  1727. return nil, err
  1728. }
  1729. return ret, nil
  1730. // {
  1731. // "description": "Add new data to a trained model.",
  1732. // "httpMethod": "PUT",
  1733. // "id": "prediction.trainedmodels.update",
  1734. // "parameterOrder": [
  1735. // "id"
  1736. // ],
  1737. // "parameters": {
  1738. // "id": {
  1739. // "description": "The unique name for the predictive model.",
  1740. // "location": "path",
  1741. // "required": true,
  1742. // "type": "string"
  1743. // }
  1744. // },
  1745. // "path": "trainedmodels/{id}",
  1746. // "request": {
  1747. // "$ref": "Update"
  1748. // },
  1749. // "response": {
  1750. // "$ref": "Training"
  1751. // },
  1752. // "scopes": [
  1753. // "https://www.googleapis.com/auth/prediction"
  1754. // ]
  1755. // }
  1756. }