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.
 
 
 

374 lines
10 KiB

  1. // Package paramrename provides access to the Example API.
  2. //
  3. // Usage example:
  4. //
  5. // import "google.golang.org/api/paramrename/v1"
  6. // ...
  7. // paramrenameService, err := paramrename.New(oauthHttpClient)
  8. package paramrename // import "google.golang.org/api/paramrename/v1"
  9. import (
  10. "bytes"
  11. "encoding/json"
  12. "errors"
  13. "fmt"
  14. context "golang.org/x/net/context"
  15. ctxhttp "golang.org/x/net/context/ctxhttp"
  16. gensupport "google.golang.org/api/gensupport"
  17. googleapi "google.golang.org/api/googleapi"
  18. "io"
  19. "net/http"
  20. "net/url"
  21. "strconv"
  22. "strings"
  23. )
  24. // Always reference these packages, just in case the auto-generated code
  25. // below doesn't.
  26. var _ = bytes.NewBuffer
  27. var _ = strconv.Itoa
  28. var _ = fmt.Sprintf
  29. var _ = json.NewDecoder
  30. var _ = io.Copy
  31. var _ = url.Parse
  32. var _ = gensupport.MarshalJSON
  33. var _ = googleapi.Version
  34. var _ = errors.New
  35. var _ = strings.Replace
  36. var _ = context.Canceled
  37. var _ = ctxhttp.Do
  38. const apiId = "paramrename:v1"
  39. const apiName = "paramrename"
  40. const apiVersion = "v1"
  41. const basePath = "https://www.googleapis.com/discovery/v1/apis"
  42. func New(client *http.Client) (*Service, error) {
  43. if client == nil {
  44. return nil, errors.New("client is nil")
  45. }
  46. s := &Service{client: client, BasePath: basePath}
  47. s.Events = NewEventsService(s)
  48. s.Reports = NewReportsService(s)
  49. return s, nil
  50. }
  51. type Service struct {
  52. client *http.Client
  53. BasePath string // API endpoint base URL
  54. UserAgent string // optional additional User-Agent fragment
  55. Events *EventsService
  56. Reports *ReportsService
  57. }
  58. func (s *Service) userAgent() string {
  59. if s.UserAgent == "" {
  60. return googleapi.UserAgent
  61. }
  62. return googleapi.UserAgent + " " + s.UserAgent
  63. }
  64. func NewEventsService(s *Service) *EventsService {
  65. rs := &EventsService{s: s}
  66. return rs
  67. }
  68. type EventsService struct {
  69. s *Service
  70. }
  71. func NewReportsService(s *Service) *ReportsService {
  72. rs := &ReportsService{s: s}
  73. return rs
  74. }
  75. type ReportsService struct {
  76. s *Service
  77. }
  78. type Event string
  79. type ResultTable string
  80. // method id "calendar.events.move":
  81. type EventsMoveCall struct {
  82. s *Service
  83. rightString string
  84. urlParams_ gensupport.URLParams
  85. ctx_ context.Context
  86. header_ http.Header
  87. }
  88. // Move: Moves an event to another calendar, i.e. changes an event's
  89. // organizer.
  90. func (r *EventsService) Move(destinationid string, rightString string) *EventsMoveCall {
  91. c := &EventsMoveCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  92. c.urlParams_.Set("destination", destinationid)
  93. c.rightString = rightString
  94. return c
  95. }
  96. // SourceParam sets the optional parameter "source-param": Some
  97. // parameter.
  98. func (c *EventsMoveCall) SourceParam(sourceParam string) *EventsMoveCall {
  99. c.urlParams_.Set("source-param", sourceParam)
  100. return c
  101. }
  102. // Fields allows partial responses to be retrieved. See
  103. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  104. // for more information.
  105. func (c *EventsMoveCall) Fields(s ...googleapi.Field) *EventsMoveCall {
  106. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  107. return c
  108. }
  109. // Context sets the context to be used in this call's Do method. Any
  110. // pending HTTP request will be aborted if the provided context is
  111. // canceled.
  112. func (c *EventsMoveCall) Context(ctx context.Context) *EventsMoveCall {
  113. c.ctx_ = ctx
  114. return c
  115. }
  116. // Header returns an http.Header that can be modified by the caller to
  117. // add HTTP headers to the request.
  118. func (c *EventsMoveCall) Header() http.Header {
  119. if c.header_ == nil {
  120. c.header_ = make(http.Header)
  121. }
  122. return c.header_
  123. }
  124. func (c *EventsMoveCall) doRequest(alt string) (*http.Response, error) {
  125. reqHeaders := make(http.Header)
  126. for k, v := range c.header_ {
  127. reqHeaders[k] = v
  128. }
  129. reqHeaders.Set("User-Agent", c.s.userAgent())
  130. var body io.Reader = nil
  131. c.urlParams_.Set("alt", alt)
  132. urls := googleapi.ResolveRelative(c.s.BasePath, "calendars/{calendarId}/events/{eventId}/move")
  133. urls += "?" + c.urlParams_.Encode()
  134. req, _ := http.NewRequest("POST", urls, body)
  135. req.Header = reqHeaders
  136. googleapi.Expand(req.URL, map[string]string{
  137. "right-string": c.rightString,
  138. })
  139. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  140. }
  141. // Do executes the "calendar.events.move" call.
  142. // Exactly one of *Event or error will be non-nil. Any non-2xx status
  143. // code is an error. Response headers are in either
  144. // *Event.ServerResponse.Header or (if a response was returned at all)
  145. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  146. // check whether the returned error was because http.StatusNotModified
  147. // was returned.
  148. func (c *EventsMoveCall) Do(opts ...googleapi.CallOption) (*Event, error) {
  149. gensupport.SetOptions(c.urlParams_, opts...)
  150. res, err := c.doRequest("json")
  151. if res != nil && res.StatusCode == http.StatusNotModified {
  152. if res.Body != nil {
  153. res.Body.Close()
  154. }
  155. return nil, &googleapi.Error{
  156. Code: res.StatusCode,
  157. Header: res.Header,
  158. }
  159. }
  160. if err != nil {
  161. return nil, err
  162. }
  163. defer googleapi.CloseBody(res)
  164. if err := googleapi.CheckResponse(res); err != nil {
  165. return nil, err
  166. }
  167. ret := &Event{
  168. ServerResponse: googleapi.ServerResponse{
  169. Header: res.Header,
  170. HTTPStatusCode: res.StatusCode,
  171. },
  172. }
  173. target := &ret
  174. if err := gensupport.DecodeResponse(target, res); err != nil {
  175. return nil, err
  176. }
  177. return ret, nil
  178. // {
  179. // "description": "Moves an event to another calendar, i.e. changes an event's organizer.",
  180. // "httpMethod": "POST",
  181. // "id": "calendar.events.move",
  182. // "parameterOrder": [
  183. // "destination",
  184. // "right-string"
  185. // ],
  186. // "parameters": {
  187. // "destination": {
  188. // "description": "Calendar identifier of the target calendar where the event is to be moved to.",
  189. // "location": "query",
  190. // "required": true,
  191. // "type": "string"
  192. // },
  193. // "right-string": {
  194. // "description": "Yet another parameter.",
  195. // "location": "path",
  196. // "required": true,
  197. // "type": "string"
  198. // },
  199. // "source-param": {
  200. // "description": "Some parameter.",
  201. // "location": "query",
  202. // "required": false,
  203. // "type": "string"
  204. // }
  205. // },
  206. // "path": "calendars/{calendarId}/events/{eventId}/move",
  207. // "response": {
  208. // "$ref": "Event"
  209. // },
  210. // "scopes": [
  211. // "https://www.googleapis.com/auth/calendar"
  212. // ]
  213. // }
  214. }
  215. // method id "youtubeAnalytics.reports.query":
  216. type ReportsQueryCall struct {
  217. s *Service
  218. urlParams_ gensupport.URLParams
  219. ifNoneMatch_ string
  220. ctx_ context.Context
  221. header_ http.Header
  222. }
  223. // Query: Retrieve your YouTube Analytics reports.
  224. func (r *ReportsService) Query(startDate string) *ReportsQueryCall {
  225. c := &ReportsQueryCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  226. c.urlParams_.Set("start-date", startDate)
  227. return c
  228. }
  229. // Fields allows partial responses to be retrieved. See
  230. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  231. // for more information.
  232. func (c *ReportsQueryCall) Fields(s ...googleapi.Field) *ReportsQueryCall {
  233. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  234. return c
  235. }
  236. // IfNoneMatch sets the optional parameter which makes the operation
  237. // fail if the object's ETag matches the given value. This is useful for
  238. // getting updates only after the object has changed since the last
  239. // request. Use googleapi.IsNotModified to check whether the response
  240. // error from Do is the result of In-None-Match.
  241. func (c *ReportsQueryCall) IfNoneMatch(entityTag string) *ReportsQueryCall {
  242. c.ifNoneMatch_ = entityTag
  243. return c
  244. }
  245. // Context sets the context to be used in this call's Do method. Any
  246. // pending HTTP request will be aborted if the provided context is
  247. // canceled.
  248. func (c *ReportsQueryCall) Context(ctx context.Context) *ReportsQueryCall {
  249. c.ctx_ = ctx
  250. return c
  251. }
  252. // Header returns an http.Header that can be modified by the caller to
  253. // add HTTP headers to the request.
  254. func (c *ReportsQueryCall) Header() http.Header {
  255. if c.header_ == nil {
  256. c.header_ = make(http.Header)
  257. }
  258. return c.header_
  259. }
  260. func (c *ReportsQueryCall) doRequest(alt string) (*http.Response, error) {
  261. reqHeaders := make(http.Header)
  262. for k, v := range c.header_ {
  263. reqHeaders[k] = v
  264. }
  265. reqHeaders.Set("User-Agent", c.s.userAgent())
  266. if c.ifNoneMatch_ != "" {
  267. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  268. }
  269. var body io.Reader = nil
  270. c.urlParams_.Set("alt", alt)
  271. urls := googleapi.ResolveRelative(c.s.BasePath, "reports")
  272. urls += "?" + c.urlParams_.Encode()
  273. req, _ := http.NewRequest("GET", urls, body)
  274. req.Header = reqHeaders
  275. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  276. }
  277. // Do executes the "youtubeAnalytics.reports.query" call.
  278. // Exactly one of *ResultTable or error will be non-nil. Any non-2xx
  279. // status code is an error. Response headers are in either
  280. // *ResultTable.ServerResponse.Header or (if a response was returned at
  281. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  282. // to check whether the returned error was because
  283. // http.StatusNotModified was returned.
  284. func (c *ReportsQueryCall) Do(opts ...googleapi.CallOption) (*ResultTable, error) {
  285. gensupport.SetOptions(c.urlParams_, opts...)
  286. res, err := c.doRequest("json")
  287. if res != nil && res.StatusCode == http.StatusNotModified {
  288. if res.Body != nil {
  289. res.Body.Close()
  290. }
  291. return nil, &googleapi.Error{
  292. Code: res.StatusCode,
  293. Header: res.Header,
  294. }
  295. }
  296. if err != nil {
  297. return nil, err
  298. }
  299. defer googleapi.CloseBody(res)
  300. if err := googleapi.CheckResponse(res); err != nil {
  301. return nil, err
  302. }
  303. ret := &ResultTable{
  304. ServerResponse: googleapi.ServerResponse{
  305. Header: res.Header,
  306. HTTPStatusCode: res.StatusCode,
  307. },
  308. }
  309. target := &ret
  310. if err := gensupport.DecodeResponse(target, res); err != nil {
  311. return nil, err
  312. }
  313. return ret, nil
  314. // {
  315. // "description": "Retrieve your YouTube Analytics reports.",
  316. // "httpMethod": "GET",
  317. // "id": "youtubeAnalytics.reports.query",
  318. // "parameterOrder": [
  319. // "start-date"
  320. // ],
  321. // "parameters": {
  322. // "start-date": {
  323. // "description": "The start date for fetching YouTube Analytics data. The value should be in YYYY-MM-DD format.",
  324. // "location": "query",
  325. // "pattern": "[0-9]{4}-[0-9]{2}-[0-9]{2}",
  326. // "required": true,
  327. // "type": "string"
  328. // }
  329. // },
  330. // "path": "reports",
  331. // "response": {
  332. // "$ref": "ResultTable"
  333. // },
  334. // "scopes": [
  335. // "https://www.googleapis.com/auth/yt-analytics-monetary.readonly",
  336. // "https://www.googleapis.com/auth/yt-analytics.readonly"
  337. // ]
  338. // }
  339. }