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.
 
 
 

293 lines
9.0 KiB

  1. // Copyright YEAR Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Code generated file. DO NOT EDIT.
  5. // Package tshealth provides access to the .
  6. //
  7. // Creating a client
  8. //
  9. // Usage example:
  10. //
  11. // import "google.golang.org/api/tshealth/"
  12. // ...
  13. // ctx := context.Background()
  14. // tshealthService, err := tshealth.NewService(ctx)
  15. //
  16. // In this example, Google Application Default Credentials are used for authentication.
  17. //
  18. // For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
  19. //
  20. // Other authentication options
  21. //
  22. // To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey:
  23. //
  24. // tshealthService, err := tshealth.NewService(ctx, option.WithAPIKey("AIza..."))
  25. //
  26. // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource:
  27. //
  28. // config := &oauth2.Config{...}
  29. // // ...
  30. // token, err := config.Exchange(ctx, ...)
  31. // tshealthService, err := tshealth.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
  32. //
  33. // See https://godoc.org/google.golang.org/api/option/ for details on options.
  34. package tshealth // import "google.golang.org/api/tshealth/"
  35. import (
  36. "bytes"
  37. "context"
  38. "encoding/json"
  39. "errors"
  40. "fmt"
  41. "io"
  42. "net/http"
  43. "net/url"
  44. "strconv"
  45. "strings"
  46. gensupport "google.golang.org/api/gensupport"
  47. googleapi "google.golang.org/api/googleapi"
  48. option "google.golang.org/api/option"
  49. htransport "google.golang.org/api/transport/http"
  50. )
  51. // Always reference these packages, just in case the auto-generated code
  52. // below doesn't.
  53. var _ = bytes.NewBuffer
  54. var _ = strconv.Itoa
  55. var _ = fmt.Sprintf
  56. var _ = json.NewDecoder
  57. var _ = io.Copy
  58. var _ = url.Parse
  59. var _ = gensupport.MarshalJSON
  60. var _ = googleapi.Version
  61. var _ = errors.New
  62. var _ = strings.Replace
  63. var _ = context.Canceled
  64. const apiId = "tshealth:v1"
  65. const apiName = "tshealth"
  66. const apiVersion = ""
  67. const basePath = "https://www.googleapis.com/_ah/api/tshealth/v1/"
  68. // NewService creates a new Service.
  69. func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
  70. client, endpoint, err := htransport.NewClient(ctx, opts...)
  71. if err != nil {
  72. return nil, err
  73. }
  74. s, err := New(client)
  75. if err != nil {
  76. return nil, err
  77. }
  78. if endpoint != "" {
  79. s.BasePath = endpoint
  80. }
  81. return s, nil
  82. }
  83. // New creates a new Service. It uses the provided http.Client for requests.
  84. //
  85. // Deprecated: please use NewService instead.
  86. // To provide a custom HTTP client, use option.WithHTTPClient.
  87. // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
  88. func New(client *http.Client) (*Service, error) {
  89. if client == nil {
  90. return nil, errors.New("client is nil")
  91. }
  92. s := &Service{client: client, BasePath: basePath}
  93. s.Techs = NewTechsService(s)
  94. return s, nil
  95. }
  96. type Service struct {
  97. client *http.Client
  98. BasePath string // API endpoint base URL
  99. UserAgent string // optional additional User-Agent fragment
  100. Techs *TechsService
  101. }
  102. func (s *Service) userAgent() string {
  103. if s.UserAgent == "" {
  104. return googleapi.UserAgent
  105. }
  106. return googleapi.UserAgent + " " + s.UserAgent
  107. }
  108. func NewTechsService(s *Service) *TechsService {
  109. rs := &TechsService{s: s}
  110. return rs
  111. }
  112. type TechsService struct {
  113. s *Service
  114. }
  115. // Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResp
  116. // onse: Response for a tech count request.
  117. type Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse struct {
  118. Count int64 `json:"count,omitempty,string"`
  119. // ServerResponse contains the HTTP response code and headers from the
  120. // server.
  121. googleapi.ServerResponse `json:"-"`
  122. // ForceSendFields is a list of field names (e.g. "Count") to
  123. // unconditionally include in API requests. By default, fields with
  124. // empty values are omitted from API requests. However, any non-pointer,
  125. // non-interface field appearing in ForceSendFields will be sent to the
  126. // server regardless of whether the field is empty or not. This may be
  127. // used to include empty fields in Patch requests.
  128. ForceSendFields []string `json:"-"`
  129. // NullFields is a list of field names (e.g. "Count") to include in API
  130. // requests with the JSON null value. By default, fields with empty
  131. // values are omitted from API requests. However, any field with an
  132. // empty value appearing in NullFields will be sent to the server as
  133. // null. It is an error if a field in this list has a non-empty value.
  134. // This may be used to include null fields in Patch requests.
  135. NullFields []string `json:"-"`
  136. }
  137. func (s *Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse) MarshalJSON() ([]byte, error) {
  138. type NoMethod Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse
  139. raw := NoMethod(*s)
  140. return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields)
  141. }
  142. // method id "tshealth.techs.count":
  143. type TechsCountCall struct {
  144. s *Service
  145. urlParams_ gensupport.URLParams
  146. ifNoneMatch_ string
  147. ctx_ context.Context
  148. header_ http.Header
  149. }
  150. // Count: Counts the number of techs matching the constraints.
  151. func (r *TechsService) Count(manager string) *TechsCountCall {
  152. c := &TechsCountCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  153. c.urlParams_.Set("manager", manager)
  154. return c
  155. }
  156. // Fields allows partial responses to be retrieved. See
  157. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  158. // for more information.
  159. func (c *TechsCountCall) Fields(s ...googleapi.Field) *TechsCountCall {
  160. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  161. return c
  162. }
  163. // IfNoneMatch sets the optional parameter which makes the operation
  164. // fail if the object's ETag matches the given value. This is useful for
  165. // getting updates only after the object has changed since the last
  166. // request. Use googleapi.IsNotModified to check whether the response
  167. // error from Do is the result of In-None-Match.
  168. func (c *TechsCountCall) IfNoneMatch(entityTag string) *TechsCountCall {
  169. c.ifNoneMatch_ = entityTag
  170. return c
  171. }
  172. // Context sets the context to be used in this call's Do method. Any
  173. // pending HTTP request will be aborted if the provided context is
  174. // canceled.
  175. func (c *TechsCountCall) Context(ctx context.Context) *TechsCountCall {
  176. c.ctx_ = ctx
  177. return c
  178. }
  179. // Header returns an http.Header that can be modified by the caller to
  180. // add HTTP headers to the request.
  181. func (c *TechsCountCall) Header() http.Header {
  182. if c.header_ == nil {
  183. c.header_ = make(http.Header)
  184. }
  185. return c.header_
  186. }
  187. func (c *TechsCountCall) doRequest(alt string) (*http.Response, error) {
  188. reqHeaders := make(http.Header)
  189. for k, v := range c.header_ {
  190. reqHeaders[k] = v
  191. }
  192. reqHeaders.Set("User-Agent", c.s.userAgent())
  193. if c.ifNoneMatch_ != "" {
  194. reqHeaders.Set("If-None-Match", c.ifNoneMatch_)
  195. }
  196. var body io.Reader = nil
  197. c.urlParams_.Set("alt", alt)
  198. c.urlParams_.Set("prettyPrint", "false")
  199. urls := googleapi.ResolveRelative(c.s.BasePath, "techs/count")
  200. urls += "?" + c.urlParams_.Encode()
  201. req, err := http.NewRequest("GET", urls, body)
  202. if err != nil {
  203. return nil, err
  204. }
  205. req.Header = reqHeaders
  206. return gensupport.SendRequest(c.ctx_, c.s.client, req)
  207. }
  208. // Do executes the "tshealth.techs.count" call.
  209. // Exactly one of
  210. // *Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountRes
  211. // ponse or error will be non-nil. Any non-2xx status code is an error.
  212. // Response headers are in either
  213. // *Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountRes
  214. // ponse.ServerResponse.Header or (if a response was returned at all) in
  215. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  216. // whether the returned error was because http.StatusNotModified was
  217. // returned.
  218. func (c *TechsCountCall) Do(opts ...googleapi.CallOption) (*Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse, error) {
  219. gensupport.SetOptions(c.urlParams_, opts...)
  220. res, err := c.doRequest("json")
  221. if res != nil && res.StatusCode == http.StatusNotModified {
  222. if res.Body != nil {
  223. res.Body.Close()
  224. }
  225. return nil, &googleapi.Error{
  226. Code: res.StatusCode,
  227. Header: res.Header,
  228. }
  229. }
  230. if err != nil {
  231. return nil, err
  232. }
  233. defer googleapi.CloseBody(res)
  234. if err := googleapi.CheckResponse(res); err != nil {
  235. return nil, err
  236. }
  237. ret := &Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse{
  238. ServerResponse: googleapi.ServerResponse{
  239. Header: res.Header,
  240. HTTPStatusCode: res.StatusCode,
  241. },
  242. }
  243. target := &ret
  244. if err := gensupport.DecodeResponse(target, res); err != nil {
  245. return nil, err
  246. }
  247. return ret, nil
  248. // {
  249. // "description": "Counts the number of techs matching the constraints.",
  250. // "httpMethod": "GET",
  251. // "id": "tshealth.techs.count",
  252. // "parameters": {
  253. // "manager": {
  254. // "location": "query",
  255. // "required": true,
  256. // "type": "string"
  257. // }
  258. // },
  259. // "path": "techs/count",
  260. // "response": {
  261. // "$ref": "Google3CorpSupportToolsTshealthServiceApiV1TechsMessagesTechsCountResponse"
  262. // }
  263. // }
  264. }