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.

prediction-gen.go 68 KiB

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