logging-gen.go 97 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835
  1. // Package logging provides access to the Google Cloud Logging API.
  2. //
  3. // See https://cloud.google.com/logging/docs/
  4. //
  5. // Usage example:
  6. //
  7. // import "google.golang.org/api/logging/v2beta1"
  8. // ...
  9. // loggingService, err := logging.New(oauthHttpClient)
  10. package logging // import "google.golang.org/api/logging/v2beta1"
  11. import (
  12. "bytes"
  13. "encoding/json"
  14. "errors"
  15. "fmt"
  16. context "golang.org/x/net/context"
  17. ctxhttp "golang.org/x/net/context/ctxhttp"
  18. gensupport "google.golang.org/api/gensupport"
  19. googleapi "google.golang.org/api/googleapi"
  20. "io"
  21. "net/http"
  22. "net/url"
  23. "strconv"
  24. "strings"
  25. )
  26. // Always reference these packages, just in case the auto-generated code
  27. // below doesn't.
  28. var _ = bytes.NewBuffer
  29. var _ = strconv.Itoa
  30. var _ = fmt.Sprintf
  31. var _ = json.NewDecoder
  32. var _ = io.Copy
  33. var _ = url.Parse
  34. var _ = gensupport.MarshalJSON
  35. var _ = googleapi.Version
  36. var _ = errors.New
  37. var _ = strings.Replace
  38. var _ = context.Canceled
  39. var _ = ctxhttp.Do
  40. const apiId = "logging:v2beta1"
  41. const apiName = "logging"
  42. const apiVersion = "v2beta1"
  43. const basePath = "https://logging.googleapis.com/"
  44. // OAuth2 scopes used by this API.
  45. const (
  46. // View and manage your data across Google Cloud Platform services
  47. CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform"
  48. // View your data across Google Cloud Platform services
  49. CloudPlatformReadOnlyScope = "https://www.googleapis.com/auth/cloud-platform.read-only"
  50. // Administrate log data for your projects
  51. LoggingAdminScope = "https://www.googleapis.com/auth/logging.admin"
  52. // View log data for your projects
  53. LoggingReadScope = "https://www.googleapis.com/auth/logging.read"
  54. // Submit log data for your projects
  55. LoggingWriteScope = "https://www.googleapis.com/auth/logging.write"
  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.Entries = NewEntriesService(s)
  63. s.MonitoredResourceDescriptors = NewMonitoredResourceDescriptorsService(s)
  64. s.Projects = NewProjectsService(s)
  65. return s, nil
  66. }
  67. type Service struct {
  68. client *http.Client
  69. BasePath string // API endpoint base URL
  70. UserAgent string // optional additional User-Agent fragment
  71. Entries *EntriesService
  72. MonitoredResourceDescriptors *MonitoredResourceDescriptorsService
  73. Projects *ProjectsService
  74. }
  75. func (s *Service) userAgent() string {
  76. if s.UserAgent == "" {
  77. return googleapi.UserAgent
  78. }
  79. return googleapi.UserAgent + " " + s.UserAgent
  80. }
  81. func NewEntriesService(s *Service) *EntriesService {
  82. rs := &EntriesService{s: s}
  83. return rs
  84. }
  85. type EntriesService struct {
  86. s *Service
  87. }
  88. func NewMonitoredResourceDescriptorsService(s *Service) *MonitoredResourceDescriptorsService {
  89. rs := &MonitoredResourceDescriptorsService{s: s}
  90. return rs
  91. }
  92. type MonitoredResourceDescriptorsService struct {
  93. s *Service
  94. }
  95. func NewProjectsService(s *Service) *ProjectsService {
  96. rs := &ProjectsService{s: s}
  97. rs.Logs = NewProjectsLogsService(s)
  98. rs.Metrics = NewProjectsMetricsService(s)
  99. rs.Sinks = NewProjectsSinksService(s)
  100. return rs
  101. }
  102. type ProjectsService struct {
  103. s *Service
  104. Logs *ProjectsLogsService
  105. Metrics *ProjectsMetricsService
  106. Sinks *ProjectsSinksService
  107. }
  108. func NewProjectsLogsService(s *Service) *ProjectsLogsService {
  109. rs := &ProjectsLogsService{s: s}
  110. return rs
  111. }
  112. type ProjectsLogsService struct {
  113. s *Service
  114. }
  115. func NewProjectsMetricsService(s *Service) *ProjectsMetricsService {
  116. rs := &ProjectsMetricsService{s: s}
  117. return rs
  118. }
  119. type ProjectsMetricsService struct {
  120. s *Service
  121. }
  122. func NewProjectsSinksService(s *Service) *ProjectsSinksService {
  123. rs := &ProjectsSinksService{s: s}
  124. return rs
  125. }
  126. type ProjectsSinksService struct {
  127. s *Service
  128. }
  129. // Empty: A generic empty message that you can re-use to avoid defining
  130. // duplicated empty messages in your APIs. A typical example is to use
  131. // it as the request or the response type of an API method. For
  132. // instance: service Foo { rpc Bar(google.protobuf.Empty) returns
  133. // (google.protobuf.Empty); } The JSON representation for `Empty` is
  134. // empty JSON object `{}`.
  135. type Empty struct {
  136. // ServerResponse contains the HTTP response code and headers from the
  137. // server.
  138. googleapi.ServerResponse `json:"-"`
  139. }
  140. // HttpRequest: A common proto for logging HTTP requests.
  141. type HttpRequest struct {
  142. // CacheHit: Whether or not an entity was served from cache (with or
  143. // without validation).
  144. CacheHit bool `json:"cacheHit,omitempty"`
  145. // Referer: The referer URL of the request, as defined in [HTTP/1.1
  146. // Header Field
  147. // Definitions](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html).
  148. Referer string `json:"referer,omitempty"`
  149. // RemoteIp: The IP address (IPv4 or IPv6) of the client that issued the
  150. // HTTP request. Examples: "192.168.1.1",
  151. // "FE80::0202:B3FF:FE1E:8329".
  152. RemoteIp string `json:"remoteIp,omitempty"`
  153. // RequestMethod: The request method. Examples: "GET", "HEAD",
  154. // "PUT", "POST".
  155. RequestMethod string `json:"requestMethod,omitempty"`
  156. // RequestSize: The size of the HTTP request message in bytes, including
  157. // the request headers and the request body.
  158. RequestSize int64 `json:"requestSize,omitempty,string"`
  159. // RequestUrl: The scheme (http, https), the host name, the path and the
  160. // query portion of the URL that was requested. Example:
  161. // "http://example.com/some/info?color=red".
  162. RequestUrl string `json:"requestUrl,omitempty"`
  163. // ResponseSize: The size of the HTTP response message sent back to the
  164. // client, in bytes, including the response headers and the response
  165. // body.
  166. ResponseSize int64 `json:"responseSize,omitempty,string"`
  167. // Status: The response code indicating the status of response.
  168. // Examples: 200, 404.
  169. Status int64 `json:"status,omitempty"`
  170. // UserAgent: The user agent sent by the client. Example: "Mozilla/4.0
  171. // (compatible; MSIE 6.0; Windows 98; Q312461; .NET CLR 1.0.3705)".
  172. UserAgent string `json:"userAgent,omitempty"`
  173. // ValidatedWithOriginServer: Whether or not the response was validated
  174. // with the origin server before being served from cache. This field is
  175. // only meaningful if `cache_hit` is True.
  176. ValidatedWithOriginServer bool `json:"validatedWithOriginServer,omitempty"`
  177. // ForceSendFields is a list of field names (e.g. "CacheHit") to
  178. // unconditionally include in API requests. By default, fields with
  179. // empty values are omitted from API requests. However, any non-pointer,
  180. // non-interface field appearing in ForceSendFields will be sent to the
  181. // server regardless of whether the field is empty or not. This may be
  182. // used to include empty fields in Patch requests.
  183. ForceSendFields []string `json:"-"`
  184. }
  185. func (s *HttpRequest) MarshalJSON() ([]byte, error) {
  186. type noMethod HttpRequest
  187. raw := noMethod(*s)
  188. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  189. }
  190. // LabelDescriptor: A description of a label.
  191. type LabelDescriptor struct {
  192. // Description: A human-readable description for the label.
  193. Description string `json:"description,omitempty"`
  194. // Key: The label key.
  195. Key string `json:"key,omitempty"`
  196. // ValueType: The type of data that can be assigned to the label.
  197. //
  198. // Possible values:
  199. // "STRING"
  200. // "BOOL"
  201. // "INT64"
  202. ValueType string `json:"valueType,omitempty"`
  203. // ForceSendFields is a list of field names (e.g. "Description") to
  204. // unconditionally include in API requests. By default, fields with
  205. // empty values are omitted from API requests. However, any non-pointer,
  206. // non-interface field appearing in ForceSendFields will be sent to the
  207. // server regardless of whether the field is empty or not. This may be
  208. // used to include empty fields in Patch requests.
  209. ForceSendFields []string `json:"-"`
  210. }
  211. func (s *LabelDescriptor) MarshalJSON() ([]byte, error) {
  212. type noMethod LabelDescriptor
  213. raw := noMethod(*s)
  214. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  215. }
  216. // ListLogEntriesRequest: The parameters to `ListLogEntries`.
  217. type ListLogEntriesRequest struct {
  218. // Filter: Optional. An [advanced logs
  219. // filter](/logging/docs/view/advanced_filters). The filter is compared
  220. // against all log entries in the projects specified by `projectIds`.
  221. // Only entries that match the filter are retrieved. An empty filter
  222. // matches all log entries.
  223. Filter string `json:"filter,omitempty"`
  224. // OrderBy: Optional. How the results should be sorted. Presently, the
  225. // only permitted values are "timestamp" (default) and "timestamp
  226. // desc". The first option returns entries in order of increasing
  227. // values of `LogEntry.timestamp` (oldest first), and the second option
  228. // returns entries in order of decreasing timestamps (newest first).
  229. // Entries with equal timestamps are returned in order of
  230. // `LogEntry.insertId`.
  231. OrderBy string `json:"orderBy,omitempty"`
  232. // PageSize: Optional. The maximum number of results to return from this
  233. // request. Fewer results might be returned. You must check for the
  234. // `nextPageToken` result to determine if additional results are
  235. // available, which you can retrieve by passing the `nextPageToken`
  236. // value in the `pageToken` parameter to the next request.
  237. PageSize int64 `json:"pageSize,omitempty"`
  238. // PageToken: Optional. If the `pageToken` request parameter is
  239. // supplied, then the next page of results in the set are retrieved. The
  240. // `pageToken` parameter must be set with the value of the
  241. // `nextPageToken` result parameter from the previous request. The
  242. // values of `projectIds`, `filter`, and `orderBy` must be the same as
  243. // in the previous request.
  244. PageToken string `json:"pageToken,omitempty"`
  245. // ProjectIds: Required. One or more project IDs or project numbers from
  246. // which to retrieve log entries. Examples of a project ID:
  247. // "my-project-1A", "1234567890".
  248. ProjectIds []string `json:"projectIds,omitempty"`
  249. // ForceSendFields is a list of field names (e.g. "Filter") to
  250. // unconditionally include in API requests. By default, fields with
  251. // empty values are omitted from API requests. However, any non-pointer,
  252. // non-interface field appearing in ForceSendFields will be sent to the
  253. // server regardless of whether the field is empty or not. This may be
  254. // used to include empty fields in Patch requests.
  255. ForceSendFields []string `json:"-"`
  256. }
  257. func (s *ListLogEntriesRequest) MarshalJSON() ([]byte, error) {
  258. type noMethod ListLogEntriesRequest
  259. raw := noMethod(*s)
  260. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  261. }
  262. // ListLogEntriesResponse: Result returned from `ListLogEntries`.
  263. type ListLogEntriesResponse struct {
  264. // Entries: A list of log entries.
  265. Entries []*LogEntry `json:"entries,omitempty"`
  266. // NextPageToken: If there are more results than were returned, then
  267. // `nextPageToken` is given a value in the response. To get the next
  268. // batch of results, call this method again using the value of
  269. // `nextPageToken` as `pageToken`.
  270. NextPageToken string `json:"nextPageToken,omitempty"`
  271. // ServerResponse contains the HTTP response code and headers from the
  272. // server.
  273. googleapi.ServerResponse `json:"-"`
  274. // ForceSendFields is a list of field names (e.g. "Entries") to
  275. // unconditionally include in API requests. By default, fields with
  276. // empty values are omitted from API requests. However, any non-pointer,
  277. // non-interface field appearing in ForceSendFields will be sent to the
  278. // server regardless of whether the field is empty or not. This may be
  279. // used to include empty fields in Patch requests.
  280. ForceSendFields []string `json:"-"`
  281. }
  282. func (s *ListLogEntriesResponse) MarshalJSON() ([]byte, error) {
  283. type noMethod ListLogEntriesResponse
  284. raw := noMethod(*s)
  285. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  286. }
  287. // ListLogMetricsResponse: Result returned from ListLogMetrics.
  288. type ListLogMetricsResponse struct {
  289. // Metrics: A list of logs-based metrics.
  290. Metrics []*LogMetric `json:"metrics,omitempty"`
  291. // NextPageToken: If there are more results than were returned, then
  292. // `nextPageToken` is given a value in the response. To get the next
  293. // batch of results, call this method again using the value of
  294. // `nextPageToken` as `pageToken`.
  295. NextPageToken string `json:"nextPageToken,omitempty"`
  296. // ServerResponse contains the HTTP response code and headers from the
  297. // server.
  298. googleapi.ServerResponse `json:"-"`
  299. // ForceSendFields is a list of field names (e.g. "Metrics") to
  300. // unconditionally include in API requests. By default, fields with
  301. // empty values are omitted from API requests. However, any non-pointer,
  302. // non-interface field appearing in ForceSendFields will be sent to the
  303. // server regardless of whether the field is empty or not. This may be
  304. // used to include empty fields in Patch requests.
  305. ForceSendFields []string `json:"-"`
  306. }
  307. func (s *ListLogMetricsResponse) MarshalJSON() ([]byte, error) {
  308. type noMethod ListLogMetricsResponse
  309. raw := noMethod(*s)
  310. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  311. }
  312. // ListMonitoredResourceDescriptorsResponse: Result returned from
  313. // ListMonitoredResourceDescriptors.
  314. type ListMonitoredResourceDescriptorsResponse struct {
  315. // NextPageToken: If there are more results than were returned, then
  316. // `nextPageToken` is returned in the response. To get the next batch of
  317. // results, call this method again using the value of `nextPageToken` as
  318. // `pageToken`.
  319. NextPageToken string `json:"nextPageToken,omitempty"`
  320. // ResourceDescriptors: A list of resource descriptors.
  321. ResourceDescriptors []*MonitoredResourceDescriptor `json:"resourceDescriptors,omitempty"`
  322. // ServerResponse contains the HTTP response code and headers from the
  323. // server.
  324. googleapi.ServerResponse `json:"-"`
  325. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  326. // unconditionally include in API requests. By default, fields with
  327. // empty values are omitted from API requests. However, any non-pointer,
  328. // non-interface field appearing in ForceSendFields will be sent to the
  329. // server regardless of whether the field is empty or not. This may be
  330. // used to include empty fields in Patch requests.
  331. ForceSendFields []string `json:"-"`
  332. }
  333. func (s *ListMonitoredResourceDescriptorsResponse) MarshalJSON() ([]byte, error) {
  334. type noMethod ListMonitoredResourceDescriptorsResponse
  335. raw := noMethod(*s)
  336. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  337. }
  338. // ListSinksResponse: Result returned from `ListSinks`.
  339. type ListSinksResponse struct {
  340. // NextPageToken: If there are more results than were returned, then
  341. // `nextPageToken` is given a value in the response. To get the next
  342. // batch of results, call this method again using the value of
  343. // `nextPageToken` as `pageToken`.
  344. NextPageToken string `json:"nextPageToken,omitempty"`
  345. // Sinks: A list of sinks.
  346. Sinks []*LogSink `json:"sinks,omitempty"`
  347. // ServerResponse contains the HTTP response code and headers from the
  348. // server.
  349. googleapi.ServerResponse `json:"-"`
  350. // ForceSendFields is a list of field names (e.g. "NextPageToken") to
  351. // unconditionally include in API requests. By default, fields with
  352. // empty values are omitted from API requests. However, any non-pointer,
  353. // non-interface field appearing in ForceSendFields will be sent to the
  354. // server regardless of whether the field is empty or not. This may be
  355. // used to include empty fields in Patch requests.
  356. ForceSendFields []string `json:"-"`
  357. }
  358. func (s *ListSinksResponse) MarshalJSON() ([]byte, error) {
  359. type noMethod ListSinksResponse
  360. raw := noMethod(*s)
  361. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  362. }
  363. // LogEntry: An individual entry in a log.
  364. type LogEntry struct {
  365. // HttpRequest: Optional. Information about the HTTP request associated
  366. // with this log entry, if applicable.
  367. HttpRequest *HttpRequest `json:"httpRequest,omitempty"`
  368. // InsertId: Optional. A unique ID for the log entry. If you provide
  369. // this field, the logging service considers other log entries in the
  370. // same log with the same ID as duplicates which can be removed. If
  371. // omitted, Cloud Logging will generate a unique ID for this log entry.
  372. InsertId string `json:"insertId,omitempty"`
  373. // JsonPayload: The log entry payload, represented as a structure that
  374. // is expressed as a JSON object.
  375. JsonPayload LogEntryJsonPayload `json:"jsonPayload,omitempty"`
  376. // Labels: Optional. A set of user-defined (key, value) data that
  377. // provides additional information about the log entry.
  378. Labels map[string]string `json:"labels,omitempty"`
  379. // LogName: Required. The resource name of the log to which this log
  380. // entry belongs. The format of the name is
  381. // `projects/<project-id>/logs/<log-id%gt;`. Examples:
  382. // "projects/my-projectid/logs/syslog",
  383. // "projects/1234567890/logs/library.googleapis.com%2Fbook_log". The
  384. // log ID part of resource name must be less than 512 characters long
  385. // and can only include the following characters: upper and lower case
  386. // alphanumeric characters: [A-Za-z0-9]; and punctuation characters:
  387. // forward-slash, underscore, hyphen, and period. Forward-slash (`/`)
  388. // characters in the log ID must be URL-encoded.
  389. LogName string `json:"logName,omitempty"`
  390. // Operation: Optional. Information about an operation associated with
  391. // the log entry, if applicable.
  392. Operation *LogEntryOperation `json:"operation,omitempty"`
  393. // ProtoPayload: The log entry payload, represented as a protocol
  394. // buffer. You can only use `protoPayload` values that belong to a set
  395. // of approved types.
  396. ProtoPayload LogEntryProtoPayload `json:"protoPayload,omitempty"`
  397. // Resource: Required. The monitored resource associated with this log
  398. // entry. Example: a log entry that reports a database error would be
  399. // associated with the monitored resource designating the particular
  400. // database that reported the error.
  401. Resource *MonitoredResource `json:"resource,omitempty"`
  402. // Severity: Optional. The severity of the log entry. The default value
  403. // is `LogSeverity.DEFAULT`.
  404. //
  405. // Possible values:
  406. // "DEFAULT"
  407. // "DEBUG"
  408. // "INFO"
  409. // "NOTICE"
  410. // "WARNING"
  411. // "ERROR"
  412. // "CRITICAL"
  413. // "ALERT"
  414. // "EMERGENCY"
  415. Severity string `json:"severity,omitempty"`
  416. // TextPayload: The log entry payload, represented as a Unicode string
  417. // (UTF-8).
  418. TextPayload string `json:"textPayload,omitempty"`
  419. // Timestamp: Optional. The time the event described by the log entry
  420. // occurred. If omitted, Cloud Logging will use the time the log entry
  421. // is written.
  422. Timestamp string `json:"timestamp,omitempty"`
  423. // ForceSendFields is a list of field names (e.g. "HttpRequest") to
  424. // unconditionally include in API requests. By default, fields with
  425. // empty values are omitted from API requests. However, any non-pointer,
  426. // non-interface field appearing in ForceSendFields will be sent to the
  427. // server regardless of whether the field is empty or not. This may be
  428. // used to include empty fields in Patch requests.
  429. ForceSendFields []string `json:"-"`
  430. }
  431. func (s *LogEntry) MarshalJSON() ([]byte, error) {
  432. type noMethod LogEntry
  433. raw := noMethod(*s)
  434. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  435. }
  436. type LogEntryJsonPayload interface{}
  437. type LogEntryProtoPayload interface{}
  438. // LogEntryOperation: Additional information about a potentially
  439. // long-running operation with which a log entry is associated.
  440. type LogEntryOperation struct {
  441. // First: Optional. Set this to True if this is the first log entry in
  442. // the operation.
  443. First bool `json:"first,omitempty"`
  444. // Id: Required. An arbitrary operation identifier. Log entries with the
  445. // same identifier are assumed to be part of the same operation.
  446. Id string `json:"id,omitempty"`
  447. // Last: Optional. Set this to True if this is the last log entry in the
  448. // operation.
  449. Last bool `json:"last,omitempty"`
  450. // Producer: Required. An arbitrary producer identifier. The combination
  451. // of `id` and `producer` must be globally unique. Examples for
  452. // `producer`: "MyDivision.MyBigCompany.com",
  453. // "github.com/MyProject/MyApplication".
  454. Producer string `json:"producer,omitempty"`
  455. // ForceSendFields is a list of field names (e.g. "First") to
  456. // unconditionally include in API requests. By default, fields with
  457. // empty values are omitted from API requests. However, any non-pointer,
  458. // non-interface field appearing in ForceSendFields will be sent to the
  459. // server regardless of whether the field is empty or not. This may be
  460. // used to include empty fields in Patch requests.
  461. ForceSendFields []string `json:"-"`
  462. }
  463. func (s *LogEntryOperation) MarshalJSON() ([]byte, error) {
  464. type noMethod LogEntryOperation
  465. raw := noMethod(*s)
  466. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  467. }
  468. // LogLine: Application log line emitted while processing a request.
  469. type LogLine struct {
  470. // LogMessage: App-provided log message.
  471. LogMessage string `json:"logMessage,omitempty"`
  472. // Severity: Severity of this log entry.
  473. //
  474. // Possible values:
  475. // "DEFAULT"
  476. // "DEBUG"
  477. // "INFO"
  478. // "NOTICE"
  479. // "WARNING"
  480. // "ERROR"
  481. // "CRITICAL"
  482. // "ALERT"
  483. // "EMERGENCY"
  484. Severity string `json:"severity,omitempty"`
  485. // SourceLocation: Where in the source code this log message was
  486. // written.
  487. SourceLocation *SourceLocation `json:"sourceLocation,omitempty"`
  488. // Time: Approximate time when this log entry was made.
  489. Time string `json:"time,omitempty"`
  490. // ForceSendFields is a list of field names (e.g. "LogMessage") to
  491. // unconditionally include in API requests. By default, fields with
  492. // empty values are omitted from API requests. However, any non-pointer,
  493. // non-interface field appearing in ForceSendFields will be sent to the
  494. // server regardless of whether the field is empty or not. This may be
  495. // used to include empty fields in Patch requests.
  496. ForceSendFields []string `json:"-"`
  497. }
  498. func (s *LogLine) MarshalJSON() ([]byte, error) {
  499. type noMethod LogLine
  500. raw := noMethod(*s)
  501. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  502. }
  503. // LogMetric: Describes a logs-based metric. The value of the metric is
  504. // the number of log entries that match a logs filter.
  505. type LogMetric struct {
  506. // Description: A description of this metric, which is used in
  507. // documentation.
  508. Description string `json:"description,omitempty"`
  509. // Filter: An [advanced logs
  510. // filter](/logging/docs/view/advanced_filters). Example:
  511. // "logName:syslog AND severity>=ERROR".
  512. Filter string `json:"filter,omitempty"`
  513. // Name: Required. The client-assigned metric identifier. Example:
  514. // "severe_errors". Metric identifiers are limited to 1000 characters
  515. // and can include only the following characters: `A-Z`, `a-z`, `0-9`,
  516. // and the special characters `_-.,+!*',()%/\`. The forward-slash
  517. // character (`/`) denotes a hierarchy of name pieces, and it cannot be
  518. // the first character of the name.
  519. Name string `json:"name,omitempty"`
  520. // ServerResponse contains the HTTP response code and headers from the
  521. // server.
  522. googleapi.ServerResponse `json:"-"`
  523. // ForceSendFields is a list of field names (e.g. "Description") to
  524. // unconditionally include in API requests. By default, fields with
  525. // empty values are omitted from API requests. However, any non-pointer,
  526. // non-interface field appearing in ForceSendFields will be sent to the
  527. // server regardless of whether the field is empty or not. This may be
  528. // used to include empty fields in Patch requests.
  529. ForceSendFields []string `json:"-"`
  530. }
  531. func (s *LogMetric) MarshalJSON() ([]byte, error) {
  532. type noMethod LogMetric
  533. raw := noMethod(*s)
  534. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  535. }
  536. // LogSink: Describes a sink used to export log entries outside Cloud
  537. // Logging.
  538. type LogSink struct {
  539. // Destination: The export destination. See [Exporting Logs With
  540. // Sinks](/logging/docs/api/tasks/exporting-logs). Examples:
  541. // "storage.googleapis.com/a-bucket",
  542. // "bigquery.googleapis.com/projects/a-project-id/datasets/a-dataset".
  543. Destination string `json:"destination,omitempty"`
  544. // Filter: An [advanced logs
  545. // filter](/logging/docs/view/advanced_filters) that defines the log
  546. // entries to be exported. The filter must be consistent with the log
  547. // entry format designed by the `outputVersionFormat` parameter,
  548. // regardless of the format of the log entry that was originally written
  549. // to Cloud Logging. Example: "logName:syslog AND severity>=ERROR".
  550. Filter string `json:"filter,omitempty"`
  551. // Name: Required. The client-assigned sink identifier. Example:
  552. // "my-severe-errors-to-pubsub". Sink identifiers are limited to 1000
  553. // characters and can include only the following characters: `A-Z`,
  554. // `a-z`, `0-9`, and the special characters `_-.`.
  555. Name string `json:"name,omitempty"`
  556. // OutputVersionFormat: The log entry version used when exporting log
  557. // entries from this sink. This version does not have to correspond to
  558. // the version of the log entry when it was written to Cloud Logging.
  559. //
  560. // Possible values:
  561. // "VERSION_FORMAT_UNSPECIFIED"
  562. // "V2"
  563. // "V1"
  564. OutputVersionFormat string `json:"outputVersionFormat,omitempty"`
  565. // ServerResponse contains the HTTP response code and headers from the
  566. // server.
  567. googleapi.ServerResponse `json:"-"`
  568. // ForceSendFields is a list of field names (e.g. "Destination") to
  569. // unconditionally include in API requests. By default, fields with
  570. // empty values are omitted from API requests. However, any non-pointer,
  571. // non-interface field appearing in ForceSendFields will be sent to the
  572. // server regardless of whether the field is empty or not. This may be
  573. // used to include empty fields in Patch requests.
  574. ForceSendFields []string `json:"-"`
  575. }
  576. func (s *LogSink) MarshalJSON() ([]byte, error) {
  577. type noMethod LogSink
  578. raw := noMethod(*s)
  579. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  580. }
  581. // MonitoredResource: A specific monitored resource or a group of
  582. // monitored resources.
  583. type MonitoredResource struct {
  584. // Labels: Values for some or all of the labels listed in the associated
  585. // monitored resource descriptor. For example, specify a specific Cloud
  586. // SQL database by supplying values for both the "database_id" and
  587. // "zone" labels. Specify the set of all Cloud SQL databases in a
  588. // particular location by supplying a value for only the "zone" label.
  589. Labels map[string]string `json:"labels,omitempty"`
  590. // Type: The type of monitored resource. This field must match the value
  591. // of the `type` field in a MonitoredResourceDescriptor object. For
  592. // example, "cloudsql_database" represents Cloud SQL databases.
  593. Type string `json:"type,omitempty"`
  594. // ForceSendFields is a list of field names (e.g. "Labels") to
  595. // unconditionally include in API requests. By default, fields with
  596. // empty values are omitted from API requests. However, any non-pointer,
  597. // non-interface field appearing in ForceSendFields will be sent to the
  598. // server regardless of whether the field is empty or not. This may be
  599. // used to include empty fields in Patch requests.
  600. ForceSendFields []string `json:"-"`
  601. }
  602. func (s *MonitoredResource) MarshalJSON() ([]byte, error) {
  603. type noMethod MonitoredResource
  604. raw := noMethod(*s)
  605. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  606. }
  607. // MonitoredResourceDescriptor: A description of a type of monitored
  608. // resource.
  609. type MonitoredResourceDescriptor struct {
  610. // Description: A detailed description of the monitored resource type,
  611. // which is used in documentation.
  612. Description string `json:"description,omitempty"`
  613. // DisplayName: A concise name for the monitored resource type, which is
  614. // displayed in user interfaces. For example, "Cloud SQL Database".
  615. DisplayName string `json:"displayName,omitempty"`
  616. // Labels: A set of labels that can be used to describe instances of
  617. // this monitored resource type. For example, Cloud SQL databases can be
  618. // labeled with their "database_id" and their "zone".
  619. Labels []*LabelDescriptor `json:"labels,omitempty"`
  620. // Type: The monitored resource type. For example, the type
  621. // "cloudsql_database" represents databases in Google Cloud SQL.
  622. Type string `json:"type,omitempty"`
  623. // ForceSendFields is a list of field names (e.g. "Description") to
  624. // unconditionally include in API requests. By default, fields with
  625. // empty values are omitted from API requests. However, any non-pointer,
  626. // non-interface field appearing in ForceSendFields will be sent to the
  627. // server regardless of whether the field is empty or not. This may be
  628. // used to include empty fields in Patch requests.
  629. ForceSendFields []string `json:"-"`
  630. }
  631. func (s *MonitoredResourceDescriptor) MarshalJSON() ([]byte, error) {
  632. type noMethod MonitoredResourceDescriptor
  633. raw := noMethod(*s)
  634. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  635. }
  636. // RequestLog: Complete log information about a single HTTP request to
  637. // an App Engine application.
  638. type RequestLog struct {
  639. // AppEngineRelease: App Engine release version.
  640. AppEngineRelease string `json:"appEngineRelease,omitempty"`
  641. // AppId: Application that handled this request.
  642. AppId string `json:"appId,omitempty"`
  643. // Cost: An indication of the relative cost of serving this request.
  644. Cost float64 `json:"cost,omitempty"`
  645. // EndTime: Time when the request finished.
  646. EndTime string `json:"endTime,omitempty"`
  647. // Finished: Whether this request is finished or active.
  648. Finished bool `json:"finished,omitempty"`
  649. // Host: Internet host and port number of the resource being requested.
  650. Host string `json:"host,omitempty"`
  651. // HttpVersion: HTTP version of request. Example: "HTTP/1.1".
  652. HttpVersion string `json:"httpVersion,omitempty"`
  653. // InstanceId: An identifier for the instance that handled the request.
  654. InstanceId string `json:"instanceId,omitempty"`
  655. // InstanceIndex: If the instance processing this request belongs to a
  656. // manually scaled module, then this is the 0-based index of the
  657. // instance. Otherwise, this value is -1.
  658. InstanceIndex int64 `json:"instanceIndex,omitempty"`
  659. // Ip: Origin IP address.
  660. Ip string `json:"ip,omitempty"`
  661. // Latency: Latency of the request.
  662. Latency string `json:"latency,omitempty"`
  663. // Line: A list of log lines emitted by the application while serving
  664. // this request.
  665. Line []*LogLine `json:"line,omitempty"`
  666. // MegaCycles: Number of CPU megacycles used to process request.
  667. MegaCycles int64 `json:"megaCycles,omitempty,string"`
  668. // Method: Request method. Example: "GET", "HEAD", "PUT",
  669. // "POST", "DELETE".
  670. Method string `json:"method,omitempty"`
  671. // ModuleId: Module of the application that handled this request.
  672. ModuleId string `json:"moduleId,omitempty"`
  673. // Nickname: The logged-in user who made the request. Most likely, this
  674. // is the part of the user's email before the `@` sign. The field value
  675. // is the same for different requests from the same user, but different
  676. // users can have similar names. This information is also available to
  677. // the application via the App Engine Users API. This field will be
  678. // populated starting with App Engine 1.9.21.
  679. Nickname string `json:"nickname,omitempty"`
  680. // PendingTime: Time this request spent in the pending request queue.
  681. PendingTime string `json:"pendingTime,omitempty"`
  682. // Referrer: Referrer URL of request.
  683. Referrer string `json:"referrer,omitempty"`
  684. // RequestId: Globally unique identifier for a request, which is based
  685. // on the request start time. Request IDs for requests which started
  686. // later will compare greater as strings than those for requests which
  687. // started earlier.
  688. RequestId string `json:"requestId,omitempty"`
  689. // Resource: Contains the path and query portion of the URL that was
  690. // requested. For example, if the URL was
  691. // "http://example.com/app?name=val", the resource would be
  692. // "/app?name=val". The fragment identifier, which is identified by the
  693. // `#` character, is not included.
  694. Resource string `json:"resource,omitempty"`
  695. // ResponseSize: Size in bytes sent back to client by request.
  696. ResponseSize int64 `json:"responseSize,omitempty,string"`
  697. // SourceReference: Source code for the application that handled this
  698. // request. There can be more than one source reference per deployed
  699. // application if source code is distributed among multiple
  700. // repositories.
  701. SourceReference []*SourceReference `json:"sourceReference,omitempty"`
  702. // StartTime: Time when the request started.
  703. StartTime string `json:"startTime,omitempty"`
  704. // Status: HTTP response status code. Example: 200, 404.
  705. Status int64 `json:"status,omitempty"`
  706. // TaskName: Task name of the request, in the case of an offline
  707. // request.
  708. TaskName string `json:"taskName,omitempty"`
  709. // TaskQueueName: Queue name of the request, in the case of an offline
  710. // request.
  711. TaskQueueName string `json:"taskQueueName,omitempty"`
  712. // TraceId: Cloud Trace identifier for this request.
  713. TraceId string `json:"traceId,omitempty"`
  714. // UrlMapEntry: File or class that handled the request.
  715. UrlMapEntry string `json:"urlMapEntry,omitempty"`
  716. // UserAgent: User agent that made the request.
  717. UserAgent string `json:"userAgent,omitempty"`
  718. // VersionId: Version of the application that handled this request.
  719. VersionId string `json:"versionId,omitempty"`
  720. // WasLoadingRequest: Whether this was a loading request for the
  721. // instance.
  722. WasLoadingRequest bool `json:"wasLoadingRequest,omitempty"`
  723. // ForceSendFields is a list of field names (e.g. "AppEngineRelease") to
  724. // unconditionally include in API requests. By default, fields with
  725. // empty values are omitted from API requests. However, any non-pointer,
  726. // non-interface field appearing in ForceSendFields will be sent to the
  727. // server regardless of whether the field is empty or not. This may be
  728. // used to include empty fields in Patch requests.
  729. ForceSendFields []string `json:"-"`
  730. }
  731. func (s *RequestLog) MarshalJSON() ([]byte, error) {
  732. type noMethod RequestLog
  733. raw := noMethod(*s)
  734. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  735. }
  736. // SourceLocation: Specifies a location in a source code file.
  737. type SourceLocation struct {
  738. // File: Source file name. Depending on the runtime environment, this
  739. // might be a simple name or a fully-qualified name.
  740. File string `json:"file,omitempty"`
  741. // FunctionName: Human-readable name of the function or method being
  742. // invoked, with optional context such as the class or package name.
  743. // This information is used in contexts such as the logs viewer, where a
  744. // file and line number are less meaningful. The format can vary by
  745. // language. For example: `qual.if.ied.Class.method` (Java),
  746. // `dir/package.func` (Go), `function` (Python).
  747. FunctionName string `json:"functionName,omitempty"`
  748. // Line: Line within the source file.
  749. Line int64 `json:"line,omitempty,string"`
  750. // ForceSendFields is a list of field names (e.g. "File") to
  751. // unconditionally include in API requests. By default, fields with
  752. // empty values are omitted from API requests. However, any non-pointer,
  753. // non-interface field appearing in ForceSendFields will be sent to the
  754. // server regardless of whether the field is empty or not. This may be
  755. // used to include empty fields in Patch requests.
  756. ForceSendFields []string `json:"-"`
  757. }
  758. func (s *SourceLocation) MarshalJSON() ([]byte, error) {
  759. type noMethod SourceLocation
  760. raw := noMethod(*s)
  761. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  762. }
  763. // SourceReference: A reference to a particular snapshot of the source
  764. // tree used to build and deploy an application.
  765. type SourceReference struct {
  766. // Repository: Optional. A URI string identifying the repository.
  767. // Example: "https://github.com/GoogleCloudPlatform/kubernetes.git"
  768. Repository string `json:"repository,omitempty"`
  769. // RevisionId: The canonical and persistent identifier of the deployed
  770. // revision. Example (git): "0035781c50ec7aa23385dc841529ce8a4b70db1b"
  771. RevisionId string `json:"revisionId,omitempty"`
  772. // ForceSendFields is a list of field names (e.g. "Repository") to
  773. // unconditionally include in API requests. By default, fields with
  774. // empty values are omitted from API requests. However, any non-pointer,
  775. // non-interface field appearing in ForceSendFields will be sent to the
  776. // server regardless of whether the field is empty or not. This may be
  777. // used to include empty fields in Patch requests.
  778. ForceSendFields []string `json:"-"`
  779. }
  780. func (s *SourceReference) MarshalJSON() ([]byte, error) {
  781. type noMethod SourceReference
  782. raw := noMethod(*s)
  783. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  784. }
  785. // WriteLogEntriesRequest: The parameters to WriteLogEntries.
  786. type WriteLogEntriesRequest struct {
  787. // Entries: Required. The log entries to write. The log entries must
  788. // have values for all required fields.
  789. Entries []*LogEntry `json:"entries,omitempty"`
  790. // Labels: Optional. User-defined `key:value` items that are added to
  791. // the `labels` field of each log entry in `entries`, except when a log
  792. // entry specifies its own `key:value` item with the same key. Example:
  793. // `{ "size": "large", "color":"red" }`
  794. Labels map[string]string `json:"labels,omitempty"`
  795. // LogName: Optional. A default log resource name for those log entries
  796. // in `entries` that do not specify their own `logName`. Example:
  797. // "projects/my-project/logs/syslog". See LogEntry.
  798. LogName string `json:"logName,omitempty"`
  799. // Resource: Optional. A default monitored resource for those log
  800. // entries in `entries` that do not specify their own `resource`.
  801. Resource *MonitoredResource `json:"resource,omitempty"`
  802. // ForceSendFields is a list of field names (e.g. "Entries") to
  803. // unconditionally include in API requests. By default, fields with
  804. // empty values are omitted from API requests. However, any non-pointer,
  805. // non-interface field appearing in ForceSendFields will be sent to the
  806. // server regardless of whether the field is empty or not. This may be
  807. // used to include empty fields in Patch requests.
  808. ForceSendFields []string `json:"-"`
  809. }
  810. func (s *WriteLogEntriesRequest) MarshalJSON() ([]byte, error) {
  811. type noMethod WriteLogEntriesRequest
  812. raw := noMethod(*s)
  813. return gensupport.MarshalJSON(raw, s.ForceSendFields)
  814. }
  815. // WriteLogEntriesResponse: Result returned from WriteLogEntries. empty
  816. type WriteLogEntriesResponse struct {
  817. // ServerResponse contains the HTTP response code and headers from the
  818. // server.
  819. googleapi.ServerResponse `json:"-"`
  820. }
  821. // method id "logging.entries.list":
  822. type EntriesListCall struct {
  823. s *Service
  824. listlogentriesrequest *ListLogEntriesRequest
  825. urlParams_ gensupport.URLParams
  826. ctx_ context.Context
  827. }
  828. // List: Lists log entries. Use this method to retrieve log entries from
  829. // Cloud Logging. For ways to export log entries, see [Exporting
  830. // Logs](/logging/docs/export).
  831. func (r *EntriesService) List(listlogentriesrequest *ListLogEntriesRequest) *EntriesListCall {
  832. c := &EntriesListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  833. c.listlogentriesrequest = listlogentriesrequest
  834. return c
  835. }
  836. // Fields allows partial responses to be retrieved. See
  837. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  838. // for more information.
  839. func (c *EntriesListCall) Fields(s ...googleapi.Field) *EntriesListCall {
  840. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  841. return c
  842. }
  843. // Context sets the context to be used in this call's Do method. Any
  844. // pending HTTP request will be aborted if the provided context is
  845. // canceled.
  846. func (c *EntriesListCall) Context(ctx context.Context) *EntriesListCall {
  847. c.ctx_ = ctx
  848. return c
  849. }
  850. func (c *EntriesListCall) doRequest(alt string) (*http.Response, error) {
  851. var body io.Reader = nil
  852. body, err := googleapi.WithoutDataWrapper.JSONReader(c.listlogentriesrequest)
  853. if err != nil {
  854. return nil, err
  855. }
  856. ctype := "application/json"
  857. c.urlParams_.Set("alt", alt)
  858. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/entries:list")
  859. urls += "?" + c.urlParams_.Encode()
  860. req, _ := http.NewRequest("POST", urls, body)
  861. googleapi.SetOpaque(req.URL)
  862. req.Header.Set("Content-Type", ctype)
  863. req.Header.Set("User-Agent", c.s.userAgent())
  864. if c.ctx_ != nil {
  865. return ctxhttp.Do(c.ctx_, c.s.client, req)
  866. }
  867. return c.s.client.Do(req)
  868. }
  869. // Do executes the "logging.entries.list" call.
  870. // Exactly one of *ListLogEntriesResponse or error will be non-nil. Any
  871. // non-2xx status code is an error. Response headers are in either
  872. // *ListLogEntriesResponse.ServerResponse.Header or (if a response was
  873. // returned at all) in error.(*googleapi.Error).Header. Use
  874. // googleapi.IsNotModified to check whether the returned error was
  875. // because http.StatusNotModified was returned.
  876. func (c *EntriesListCall) Do(opts ...googleapi.CallOption) (*ListLogEntriesResponse, error) {
  877. gensupport.SetOptions(c.urlParams_, opts...)
  878. res, err := c.doRequest("json")
  879. if res != nil && res.StatusCode == http.StatusNotModified {
  880. if res.Body != nil {
  881. res.Body.Close()
  882. }
  883. return nil, &googleapi.Error{
  884. Code: res.StatusCode,
  885. Header: res.Header,
  886. }
  887. }
  888. if err != nil {
  889. return nil, err
  890. }
  891. defer googleapi.CloseBody(res)
  892. if err := googleapi.CheckResponse(res); err != nil {
  893. return nil, err
  894. }
  895. ret := &ListLogEntriesResponse{
  896. ServerResponse: googleapi.ServerResponse{
  897. Header: res.Header,
  898. HTTPStatusCode: res.StatusCode,
  899. },
  900. }
  901. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  902. return nil, err
  903. }
  904. return ret, nil
  905. // {
  906. // "description": "Lists log entries. Use this method to retrieve log entries from Cloud Logging. For ways to export log entries, see [Exporting Logs](/logging/docs/export).",
  907. // "httpMethod": "POST",
  908. // "id": "logging.entries.list",
  909. // "path": "v2beta1/entries:list",
  910. // "request": {
  911. // "$ref": "ListLogEntriesRequest"
  912. // },
  913. // "response": {
  914. // "$ref": "ListLogEntriesResponse"
  915. // },
  916. // "scopes": [
  917. // "https://www.googleapis.com/auth/cloud-platform",
  918. // "https://www.googleapis.com/auth/cloud-platform.read-only",
  919. // "https://www.googleapis.com/auth/logging.admin",
  920. // "https://www.googleapis.com/auth/logging.read"
  921. // ]
  922. // }
  923. }
  924. // method id "logging.entries.write":
  925. type EntriesWriteCall struct {
  926. s *Service
  927. writelogentriesrequest *WriteLogEntriesRequest
  928. urlParams_ gensupport.URLParams
  929. ctx_ context.Context
  930. }
  931. // Write: Writes log entries to Cloud Logging. All log entries in Cloud
  932. // Logging are written by this method.
  933. func (r *EntriesService) Write(writelogentriesrequest *WriteLogEntriesRequest) *EntriesWriteCall {
  934. c := &EntriesWriteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  935. c.writelogentriesrequest = writelogentriesrequest
  936. return c
  937. }
  938. // Fields allows partial responses to be retrieved. See
  939. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  940. // for more information.
  941. func (c *EntriesWriteCall) Fields(s ...googleapi.Field) *EntriesWriteCall {
  942. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  943. return c
  944. }
  945. // Context sets the context to be used in this call's Do method. Any
  946. // pending HTTP request will be aborted if the provided context is
  947. // canceled.
  948. func (c *EntriesWriteCall) Context(ctx context.Context) *EntriesWriteCall {
  949. c.ctx_ = ctx
  950. return c
  951. }
  952. func (c *EntriesWriteCall) doRequest(alt string) (*http.Response, error) {
  953. var body io.Reader = nil
  954. body, err := googleapi.WithoutDataWrapper.JSONReader(c.writelogentriesrequest)
  955. if err != nil {
  956. return nil, err
  957. }
  958. ctype := "application/json"
  959. c.urlParams_.Set("alt", alt)
  960. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/entries:write")
  961. urls += "?" + c.urlParams_.Encode()
  962. req, _ := http.NewRequest("POST", urls, body)
  963. googleapi.SetOpaque(req.URL)
  964. req.Header.Set("Content-Type", ctype)
  965. req.Header.Set("User-Agent", c.s.userAgent())
  966. if c.ctx_ != nil {
  967. return ctxhttp.Do(c.ctx_, c.s.client, req)
  968. }
  969. return c.s.client.Do(req)
  970. }
  971. // Do executes the "logging.entries.write" call.
  972. // Exactly one of *WriteLogEntriesResponse or error will be non-nil. Any
  973. // non-2xx status code is an error. Response headers are in either
  974. // *WriteLogEntriesResponse.ServerResponse.Header or (if a response was
  975. // returned at all) in error.(*googleapi.Error).Header. Use
  976. // googleapi.IsNotModified to check whether the returned error was
  977. // because http.StatusNotModified was returned.
  978. func (c *EntriesWriteCall) Do(opts ...googleapi.CallOption) (*WriteLogEntriesResponse, error) {
  979. gensupport.SetOptions(c.urlParams_, opts...)
  980. res, err := c.doRequest("json")
  981. if res != nil && res.StatusCode == http.StatusNotModified {
  982. if res.Body != nil {
  983. res.Body.Close()
  984. }
  985. return nil, &googleapi.Error{
  986. Code: res.StatusCode,
  987. Header: res.Header,
  988. }
  989. }
  990. if err != nil {
  991. return nil, err
  992. }
  993. defer googleapi.CloseBody(res)
  994. if err := googleapi.CheckResponse(res); err != nil {
  995. return nil, err
  996. }
  997. ret := &WriteLogEntriesResponse{
  998. ServerResponse: googleapi.ServerResponse{
  999. Header: res.Header,
  1000. HTTPStatusCode: res.StatusCode,
  1001. },
  1002. }
  1003. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1004. return nil, err
  1005. }
  1006. return ret, nil
  1007. // {
  1008. // "description": "Writes log entries to Cloud Logging. All log entries in Cloud Logging are written by this method.",
  1009. // "httpMethod": "POST",
  1010. // "id": "logging.entries.write",
  1011. // "path": "v2beta1/entries:write",
  1012. // "request": {
  1013. // "$ref": "WriteLogEntriesRequest"
  1014. // },
  1015. // "response": {
  1016. // "$ref": "WriteLogEntriesResponse"
  1017. // },
  1018. // "scopes": [
  1019. // "https://www.googleapis.com/auth/cloud-platform",
  1020. // "https://www.googleapis.com/auth/logging.admin",
  1021. // "https://www.googleapis.com/auth/logging.write"
  1022. // ]
  1023. // }
  1024. }
  1025. // method id "logging.monitoredResourceDescriptors.list":
  1026. type MonitoredResourceDescriptorsListCall struct {
  1027. s *Service
  1028. urlParams_ gensupport.URLParams
  1029. ifNoneMatch_ string
  1030. ctx_ context.Context
  1031. }
  1032. // List: Lists monitored resource descriptors that are used by Cloud
  1033. // Logging.
  1034. func (r *MonitoredResourceDescriptorsService) List() *MonitoredResourceDescriptorsListCall {
  1035. c := &MonitoredResourceDescriptorsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1036. return c
  1037. }
  1038. // PageSize sets the optional parameter "pageSize": The maximum number
  1039. // of results to return from this request. Fewer results might be
  1040. // returned. You must check for the `nextPageToken` result to determine
  1041. // if additional results are available, which you can retrieve by
  1042. // passing the `nextPageToken` value in the `pageToken` parameter to the
  1043. // next request.
  1044. func (c *MonitoredResourceDescriptorsListCall) PageSize(pageSize int64) *MonitoredResourceDescriptorsListCall {
  1045. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1046. return c
  1047. }
  1048. // PageToken sets the optional parameter "pageToken": If the `pageToken`
  1049. // request parameter is supplied, then the next page of results in the
  1050. // set are retrieved. The `pageToken` parameter must be set with the
  1051. // value of the `nextPageToken` result parameter from the previous
  1052. // request.
  1053. func (c *MonitoredResourceDescriptorsListCall) PageToken(pageToken string) *MonitoredResourceDescriptorsListCall {
  1054. c.urlParams_.Set("pageToken", pageToken)
  1055. return c
  1056. }
  1057. // Fields allows partial responses to be retrieved. See
  1058. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1059. // for more information.
  1060. func (c *MonitoredResourceDescriptorsListCall) Fields(s ...googleapi.Field) *MonitoredResourceDescriptorsListCall {
  1061. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1062. return c
  1063. }
  1064. // IfNoneMatch sets the optional parameter which makes the operation
  1065. // fail if the object's ETag matches the given value. This is useful for
  1066. // getting updates only after the object has changed since the last
  1067. // request. Use googleapi.IsNotModified to check whether the response
  1068. // error from Do is the result of In-None-Match.
  1069. func (c *MonitoredResourceDescriptorsListCall) IfNoneMatch(entityTag string) *MonitoredResourceDescriptorsListCall {
  1070. c.ifNoneMatch_ = entityTag
  1071. return c
  1072. }
  1073. // Context sets the context to be used in this call's Do method. Any
  1074. // pending HTTP request will be aborted if the provided context is
  1075. // canceled.
  1076. func (c *MonitoredResourceDescriptorsListCall) Context(ctx context.Context) *MonitoredResourceDescriptorsListCall {
  1077. c.ctx_ = ctx
  1078. return c
  1079. }
  1080. func (c *MonitoredResourceDescriptorsListCall) doRequest(alt string) (*http.Response, error) {
  1081. var body io.Reader = nil
  1082. c.urlParams_.Set("alt", alt)
  1083. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/monitoredResourceDescriptors")
  1084. urls += "?" + c.urlParams_.Encode()
  1085. req, _ := http.NewRequest("GET", urls, body)
  1086. googleapi.SetOpaque(req.URL)
  1087. req.Header.Set("User-Agent", c.s.userAgent())
  1088. if c.ifNoneMatch_ != "" {
  1089. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1090. }
  1091. if c.ctx_ != nil {
  1092. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1093. }
  1094. return c.s.client.Do(req)
  1095. }
  1096. // Do executes the "logging.monitoredResourceDescriptors.list" call.
  1097. // Exactly one of *ListMonitoredResourceDescriptorsResponse or error
  1098. // will be non-nil. Any non-2xx status code is an error. Response
  1099. // headers are in either
  1100. // *ListMonitoredResourceDescriptorsResponse.ServerResponse.Header or
  1101. // (if a response was returned at all) in
  1102. // error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check
  1103. // whether the returned error was because http.StatusNotModified was
  1104. // returned.
  1105. func (c *MonitoredResourceDescriptorsListCall) Do(opts ...googleapi.CallOption) (*ListMonitoredResourceDescriptorsResponse, error) {
  1106. gensupport.SetOptions(c.urlParams_, opts...)
  1107. res, err := c.doRequest("json")
  1108. if res != nil && res.StatusCode == http.StatusNotModified {
  1109. if res.Body != nil {
  1110. res.Body.Close()
  1111. }
  1112. return nil, &googleapi.Error{
  1113. Code: res.StatusCode,
  1114. Header: res.Header,
  1115. }
  1116. }
  1117. if err != nil {
  1118. return nil, err
  1119. }
  1120. defer googleapi.CloseBody(res)
  1121. if err := googleapi.CheckResponse(res); err != nil {
  1122. return nil, err
  1123. }
  1124. ret := &ListMonitoredResourceDescriptorsResponse{
  1125. ServerResponse: googleapi.ServerResponse{
  1126. Header: res.Header,
  1127. HTTPStatusCode: res.StatusCode,
  1128. },
  1129. }
  1130. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1131. return nil, err
  1132. }
  1133. return ret, nil
  1134. // {
  1135. // "description": "Lists monitored resource descriptors that are used by Cloud Logging.",
  1136. // "httpMethod": "GET",
  1137. // "id": "logging.monitoredResourceDescriptors.list",
  1138. // "parameters": {
  1139. // "pageSize": {
  1140. // "description": "Optional. The maximum number of results to return from this request. Fewer results might be returned. You must check for the `nextPageToken` result to determine if additional results are available, which you can retrieve by passing the `nextPageToken` value in the `pageToken` parameter to the next request.",
  1141. // "format": "int32",
  1142. // "location": "query",
  1143. // "type": "integer"
  1144. // },
  1145. // "pageToken": {
  1146. // "description": "Optional. If the `pageToken` request parameter is supplied, then the next page of results in the set are retrieved. The `pageToken` parameter must be set with the value of the `nextPageToken` result parameter from the previous request.",
  1147. // "location": "query",
  1148. // "type": "string"
  1149. // }
  1150. // },
  1151. // "path": "v2beta1/monitoredResourceDescriptors",
  1152. // "response": {
  1153. // "$ref": "ListMonitoredResourceDescriptorsResponse"
  1154. // },
  1155. // "scopes": [
  1156. // "https://www.googleapis.com/auth/cloud-platform",
  1157. // "https://www.googleapis.com/auth/cloud-platform.read-only",
  1158. // "https://www.googleapis.com/auth/logging.admin",
  1159. // "https://www.googleapis.com/auth/logging.read"
  1160. // ]
  1161. // }
  1162. }
  1163. // Pages invokes f for each page of results.
  1164. // A non-nil error returned from f will halt the iteration.
  1165. // The provided context supersedes any context provided to the Context method.
  1166. func (c *MonitoredResourceDescriptorsListCall) Pages(ctx context.Context, f func(*ListMonitoredResourceDescriptorsResponse) error) error {
  1167. c.ctx_ = ctx
  1168. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1169. for {
  1170. x, err := c.Do()
  1171. if err != nil {
  1172. return err
  1173. }
  1174. if err := f(x); err != nil {
  1175. return err
  1176. }
  1177. if x.NextPageToken == "" {
  1178. return nil
  1179. }
  1180. c.PageToken(x.NextPageToken)
  1181. }
  1182. }
  1183. // method id "logging.projects.logs.delete":
  1184. type ProjectsLogsDeleteCall struct {
  1185. s *Service
  1186. logName string
  1187. urlParams_ gensupport.URLParams
  1188. ctx_ context.Context
  1189. }
  1190. // Delete: Deletes a log and all its log entries. The log will reappear
  1191. // if it receives new entries.
  1192. func (r *ProjectsLogsService) Delete(logName string) *ProjectsLogsDeleteCall {
  1193. c := &ProjectsLogsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1194. c.logName = logName
  1195. return c
  1196. }
  1197. // Fields allows partial responses to be retrieved. See
  1198. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1199. // for more information.
  1200. func (c *ProjectsLogsDeleteCall) Fields(s ...googleapi.Field) *ProjectsLogsDeleteCall {
  1201. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1202. return c
  1203. }
  1204. // Context sets the context to be used in this call's Do method. Any
  1205. // pending HTTP request will be aborted if the provided context is
  1206. // canceled.
  1207. func (c *ProjectsLogsDeleteCall) Context(ctx context.Context) *ProjectsLogsDeleteCall {
  1208. c.ctx_ = ctx
  1209. return c
  1210. }
  1211. func (c *ProjectsLogsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1212. var body io.Reader = nil
  1213. c.urlParams_.Set("alt", alt)
  1214. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+logName}")
  1215. urls += "?" + c.urlParams_.Encode()
  1216. req, _ := http.NewRequest("DELETE", urls, body)
  1217. googleapi.Expand(req.URL, map[string]string{
  1218. "logName": c.logName,
  1219. })
  1220. req.Header.Set("User-Agent", c.s.userAgent())
  1221. if c.ctx_ != nil {
  1222. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1223. }
  1224. return c.s.client.Do(req)
  1225. }
  1226. // Do executes the "logging.projects.logs.delete" call.
  1227. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1228. // code is an error. Response headers are in either
  1229. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1230. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1231. // check whether the returned error was because http.StatusNotModified
  1232. // was returned.
  1233. func (c *ProjectsLogsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1234. gensupport.SetOptions(c.urlParams_, opts...)
  1235. res, err := c.doRequest("json")
  1236. if res != nil && res.StatusCode == http.StatusNotModified {
  1237. if res.Body != nil {
  1238. res.Body.Close()
  1239. }
  1240. return nil, &googleapi.Error{
  1241. Code: res.StatusCode,
  1242. Header: res.Header,
  1243. }
  1244. }
  1245. if err != nil {
  1246. return nil, err
  1247. }
  1248. defer googleapi.CloseBody(res)
  1249. if err := googleapi.CheckResponse(res); err != nil {
  1250. return nil, err
  1251. }
  1252. ret := &Empty{
  1253. ServerResponse: googleapi.ServerResponse{
  1254. Header: res.Header,
  1255. HTTPStatusCode: res.StatusCode,
  1256. },
  1257. }
  1258. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1259. return nil, err
  1260. }
  1261. return ret, nil
  1262. // {
  1263. // "description": "Deletes a log and all its log entries. The log will reappear if it receives new entries.",
  1264. // "httpMethod": "DELETE",
  1265. // "id": "logging.projects.logs.delete",
  1266. // "parameterOrder": [
  1267. // "logName"
  1268. // ],
  1269. // "parameters": {
  1270. // "logName": {
  1271. // "description": "Required. The resource name of the log to delete. Example: `\"projects/my-project/logs/syslog\"`.",
  1272. // "location": "path",
  1273. // "pattern": "^projects/[^/]*/logs/[^/]*$",
  1274. // "required": true,
  1275. // "type": "string"
  1276. // }
  1277. // },
  1278. // "path": "v2beta1/{+logName}",
  1279. // "response": {
  1280. // "$ref": "Empty"
  1281. // },
  1282. // "scopes": [
  1283. // "https://www.googleapis.com/auth/cloud-platform",
  1284. // "https://www.googleapis.com/auth/logging.admin"
  1285. // ]
  1286. // }
  1287. }
  1288. // method id "logging.projects.metrics.create":
  1289. type ProjectsMetricsCreateCall struct {
  1290. s *Service
  1291. projectName string
  1292. logmetric *LogMetric
  1293. urlParams_ gensupport.URLParams
  1294. ctx_ context.Context
  1295. }
  1296. // Create: Creates a logs-based metric.
  1297. func (r *ProjectsMetricsService) Create(projectName string, logmetric *LogMetric) *ProjectsMetricsCreateCall {
  1298. c := &ProjectsMetricsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1299. c.projectName = projectName
  1300. c.logmetric = logmetric
  1301. return c
  1302. }
  1303. // Fields allows partial responses to be retrieved. See
  1304. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1305. // for more information.
  1306. func (c *ProjectsMetricsCreateCall) Fields(s ...googleapi.Field) *ProjectsMetricsCreateCall {
  1307. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1308. return c
  1309. }
  1310. // Context sets the context to be used in this call's Do method. Any
  1311. // pending HTTP request will be aborted if the provided context is
  1312. // canceled.
  1313. func (c *ProjectsMetricsCreateCall) Context(ctx context.Context) *ProjectsMetricsCreateCall {
  1314. c.ctx_ = ctx
  1315. return c
  1316. }
  1317. func (c *ProjectsMetricsCreateCall) doRequest(alt string) (*http.Response, error) {
  1318. var body io.Reader = nil
  1319. body, err := googleapi.WithoutDataWrapper.JSONReader(c.logmetric)
  1320. if err != nil {
  1321. return nil, err
  1322. }
  1323. ctype := "application/json"
  1324. c.urlParams_.Set("alt", alt)
  1325. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+projectName}/metrics")
  1326. urls += "?" + c.urlParams_.Encode()
  1327. req, _ := http.NewRequest("POST", urls, body)
  1328. googleapi.Expand(req.URL, map[string]string{
  1329. "projectName": c.projectName,
  1330. })
  1331. req.Header.Set("Content-Type", ctype)
  1332. req.Header.Set("User-Agent", c.s.userAgent())
  1333. if c.ctx_ != nil {
  1334. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1335. }
  1336. return c.s.client.Do(req)
  1337. }
  1338. // Do executes the "logging.projects.metrics.create" call.
  1339. // Exactly one of *LogMetric or error will be non-nil. Any non-2xx
  1340. // status code is an error. Response headers are in either
  1341. // *LogMetric.ServerResponse.Header or (if a response was returned at
  1342. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1343. // to check whether the returned error was because
  1344. // http.StatusNotModified was returned.
  1345. func (c *ProjectsMetricsCreateCall) Do(opts ...googleapi.CallOption) (*LogMetric, error) {
  1346. gensupport.SetOptions(c.urlParams_, opts...)
  1347. res, err := c.doRequest("json")
  1348. if res != nil && res.StatusCode == http.StatusNotModified {
  1349. if res.Body != nil {
  1350. res.Body.Close()
  1351. }
  1352. return nil, &googleapi.Error{
  1353. Code: res.StatusCode,
  1354. Header: res.Header,
  1355. }
  1356. }
  1357. if err != nil {
  1358. return nil, err
  1359. }
  1360. defer googleapi.CloseBody(res)
  1361. if err := googleapi.CheckResponse(res); err != nil {
  1362. return nil, err
  1363. }
  1364. ret := &LogMetric{
  1365. ServerResponse: googleapi.ServerResponse{
  1366. Header: res.Header,
  1367. HTTPStatusCode: res.StatusCode,
  1368. },
  1369. }
  1370. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1371. return nil, err
  1372. }
  1373. return ret, nil
  1374. // {
  1375. // "description": "Creates a logs-based metric.",
  1376. // "httpMethod": "POST",
  1377. // "id": "logging.projects.metrics.create",
  1378. // "parameterOrder": [
  1379. // "projectName"
  1380. // ],
  1381. // "parameters": {
  1382. // "projectName": {
  1383. // "description": "The resource name of the project in which to create the metric. Example: `\"projects/my-project-id\"`. The new metric must be provided in the request.",
  1384. // "location": "path",
  1385. // "pattern": "^projects/[^/]*$",
  1386. // "required": true,
  1387. // "type": "string"
  1388. // }
  1389. // },
  1390. // "path": "v2beta1/{+projectName}/metrics",
  1391. // "request": {
  1392. // "$ref": "LogMetric"
  1393. // },
  1394. // "response": {
  1395. // "$ref": "LogMetric"
  1396. // },
  1397. // "scopes": [
  1398. // "https://www.googleapis.com/auth/cloud-platform",
  1399. // "https://www.googleapis.com/auth/logging.admin",
  1400. // "https://www.googleapis.com/auth/logging.write"
  1401. // ]
  1402. // }
  1403. }
  1404. // method id "logging.projects.metrics.delete":
  1405. type ProjectsMetricsDeleteCall struct {
  1406. s *Service
  1407. metricName string
  1408. urlParams_ gensupport.URLParams
  1409. ctx_ context.Context
  1410. }
  1411. // Delete: Deletes a logs-based metric.
  1412. func (r *ProjectsMetricsService) Delete(metricName string) *ProjectsMetricsDeleteCall {
  1413. c := &ProjectsMetricsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1414. c.metricName = metricName
  1415. return c
  1416. }
  1417. // Fields allows partial responses to be retrieved. See
  1418. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1419. // for more information.
  1420. func (c *ProjectsMetricsDeleteCall) Fields(s ...googleapi.Field) *ProjectsMetricsDeleteCall {
  1421. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1422. return c
  1423. }
  1424. // Context sets the context to be used in this call's Do method. Any
  1425. // pending HTTP request will be aborted if the provided context is
  1426. // canceled.
  1427. func (c *ProjectsMetricsDeleteCall) Context(ctx context.Context) *ProjectsMetricsDeleteCall {
  1428. c.ctx_ = ctx
  1429. return c
  1430. }
  1431. func (c *ProjectsMetricsDeleteCall) doRequest(alt string) (*http.Response, error) {
  1432. var body io.Reader = nil
  1433. c.urlParams_.Set("alt", alt)
  1434. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+metricName}")
  1435. urls += "?" + c.urlParams_.Encode()
  1436. req, _ := http.NewRequest("DELETE", urls, body)
  1437. googleapi.Expand(req.URL, map[string]string{
  1438. "metricName": c.metricName,
  1439. })
  1440. req.Header.Set("User-Agent", c.s.userAgent())
  1441. if c.ctx_ != nil {
  1442. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1443. }
  1444. return c.s.client.Do(req)
  1445. }
  1446. // Do executes the "logging.projects.metrics.delete" call.
  1447. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  1448. // code is an error. Response headers are in either
  1449. // *Empty.ServerResponse.Header or (if a response was returned at all)
  1450. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1451. // check whether the returned error was because http.StatusNotModified
  1452. // was returned.
  1453. func (c *ProjectsMetricsDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  1454. gensupport.SetOptions(c.urlParams_, opts...)
  1455. res, err := c.doRequest("json")
  1456. if res != nil && res.StatusCode == http.StatusNotModified {
  1457. if res.Body != nil {
  1458. res.Body.Close()
  1459. }
  1460. return nil, &googleapi.Error{
  1461. Code: res.StatusCode,
  1462. Header: res.Header,
  1463. }
  1464. }
  1465. if err != nil {
  1466. return nil, err
  1467. }
  1468. defer googleapi.CloseBody(res)
  1469. if err := googleapi.CheckResponse(res); err != nil {
  1470. return nil, err
  1471. }
  1472. ret := &Empty{
  1473. ServerResponse: googleapi.ServerResponse{
  1474. Header: res.Header,
  1475. HTTPStatusCode: res.StatusCode,
  1476. },
  1477. }
  1478. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1479. return nil, err
  1480. }
  1481. return ret, nil
  1482. // {
  1483. // "description": "Deletes a logs-based metric.",
  1484. // "httpMethod": "DELETE",
  1485. // "id": "logging.projects.metrics.delete",
  1486. // "parameterOrder": [
  1487. // "metricName"
  1488. // ],
  1489. // "parameters": {
  1490. // "metricName": {
  1491. // "description": "The resource name of the metric to delete. Example: `\"projects/my-project-id/metrics/my-metric-id\"`.",
  1492. // "location": "path",
  1493. // "pattern": "^projects/[^/]*/metrics/[^/]*$",
  1494. // "required": true,
  1495. // "type": "string"
  1496. // }
  1497. // },
  1498. // "path": "v2beta1/{+metricName}",
  1499. // "response": {
  1500. // "$ref": "Empty"
  1501. // },
  1502. // "scopes": [
  1503. // "https://www.googleapis.com/auth/cloud-platform",
  1504. // "https://www.googleapis.com/auth/logging.admin",
  1505. // "https://www.googleapis.com/auth/logging.write"
  1506. // ]
  1507. // }
  1508. }
  1509. // method id "logging.projects.metrics.get":
  1510. type ProjectsMetricsGetCall struct {
  1511. s *Service
  1512. metricName string
  1513. urlParams_ gensupport.URLParams
  1514. ifNoneMatch_ string
  1515. ctx_ context.Context
  1516. }
  1517. // Get: Gets a logs-based metric.
  1518. func (r *ProjectsMetricsService) Get(metricName string) *ProjectsMetricsGetCall {
  1519. c := &ProjectsMetricsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1520. c.metricName = metricName
  1521. return c
  1522. }
  1523. // Fields allows partial responses to be retrieved. See
  1524. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1525. // for more information.
  1526. func (c *ProjectsMetricsGetCall) Fields(s ...googleapi.Field) *ProjectsMetricsGetCall {
  1527. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1528. return c
  1529. }
  1530. // IfNoneMatch sets the optional parameter which makes the operation
  1531. // fail if the object's ETag matches the given value. This is useful for
  1532. // getting updates only after the object has changed since the last
  1533. // request. Use googleapi.IsNotModified to check whether the response
  1534. // error from Do is the result of In-None-Match.
  1535. func (c *ProjectsMetricsGetCall) IfNoneMatch(entityTag string) *ProjectsMetricsGetCall {
  1536. c.ifNoneMatch_ = entityTag
  1537. return c
  1538. }
  1539. // Context sets the context to be used in this call's Do method. Any
  1540. // pending HTTP request will be aborted if the provided context is
  1541. // canceled.
  1542. func (c *ProjectsMetricsGetCall) Context(ctx context.Context) *ProjectsMetricsGetCall {
  1543. c.ctx_ = ctx
  1544. return c
  1545. }
  1546. func (c *ProjectsMetricsGetCall) doRequest(alt string) (*http.Response, error) {
  1547. var body io.Reader = nil
  1548. c.urlParams_.Set("alt", alt)
  1549. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+metricName}")
  1550. urls += "?" + c.urlParams_.Encode()
  1551. req, _ := http.NewRequest("GET", urls, body)
  1552. googleapi.Expand(req.URL, map[string]string{
  1553. "metricName": c.metricName,
  1554. })
  1555. req.Header.Set("User-Agent", c.s.userAgent())
  1556. if c.ifNoneMatch_ != "" {
  1557. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1558. }
  1559. if c.ctx_ != nil {
  1560. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1561. }
  1562. return c.s.client.Do(req)
  1563. }
  1564. // Do executes the "logging.projects.metrics.get" call.
  1565. // Exactly one of *LogMetric or error will be non-nil. Any non-2xx
  1566. // status code is an error. Response headers are in either
  1567. // *LogMetric.ServerResponse.Header or (if a response was returned at
  1568. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1569. // to check whether the returned error was because
  1570. // http.StatusNotModified was returned.
  1571. func (c *ProjectsMetricsGetCall) Do(opts ...googleapi.CallOption) (*LogMetric, error) {
  1572. gensupport.SetOptions(c.urlParams_, opts...)
  1573. res, err := c.doRequest("json")
  1574. if res != nil && res.StatusCode == http.StatusNotModified {
  1575. if res.Body != nil {
  1576. res.Body.Close()
  1577. }
  1578. return nil, &googleapi.Error{
  1579. Code: res.StatusCode,
  1580. Header: res.Header,
  1581. }
  1582. }
  1583. if err != nil {
  1584. return nil, err
  1585. }
  1586. defer googleapi.CloseBody(res)
  1587. if err := googleapi.CheckResponse(res); err != nil {
  1588. return nil, err
  1589. }
  1590. ret := &LogMetric{
  1591. ServerResponse: googleapi.ServerResponse{
  1592. Header: res.Header,
  1593. HTTPStatusCode: res.StatusCode,
  1594. },
  1595. }
  1596. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1597. return nil, err
  1598. }
  1599. return ret, nil
  1600. // {
  1601. // "description": "Gets a logs-based metric.",
  1602. // "httpMethod": "GET",
  1603. // "id": "logging.projects.metrics.get",
  1604. // "parameterOrder": [
  1605. // "metricName"
  1606. // ],
  1607. // "parameters": {
  1608. // "metricName": {
  1609. // "description": "The resource name of the desired metric. Example: `\"projects/my-project-id/metrics/my-metric-id\"`.",
  1610. // "location": "path",
  1611. // "pattern": "^projects/[^/]*/metrics/[^/]*$",
  1612. // "required": true,
  1613. // "type": "string"
  1614. // }
  1615. // },
  1616. // "path": "v2beta1/{+metricName}",
  1617. // "response": {
  1618. // "$ref": "LogMetric"
  1619. // },
  1620. // "scopes": [
  1621. // "https://www.googleapis.com/auth/cloud-platform",
  1622. // "https://www.googleapis.com/auth/cloud-platform.read-only",
  1623. // "https://www.googleapis.com/auth/logging.admin",
  1624. // "https://www.googleapis.com/auth/logging.read"
  1625. // ]
  1626. // }
  1627. }
  1628. // method id "logging.projects.metrics.list":
  1629. type ProjectsMetricsListCall struct {
  1630. s *Service
  1631. projectName string
  1632. urlParams_ gensupport.URLParams
  1633. ifNoneMatch_ string
  1634. ctx_ context.Context
  1635. }
  1636. // List: Lists logs-based metrics.
  1637. func (r *ProjectsMetricsService) List(projectName string) *ProjectsMetricsListCall {
  1638. c := &ProjectsMetricsListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1639. c.projectName = projectName
  1640. return c
  1641. }
  1642. // PageSize sets the optional parameter "pageSize": The maximum number
  1643. // of results to return from this request. Fewer results might be
  1644. // returned. You must check for the `nextPageToken` result to determine
  1645. // if additional results are available, which you can retrieve by
  1646. // passing the `nextPageToken` value in the `pageToken` parameter to the
  1647. // next request.
  1648. func (c *ProjectsMetricsListCall) PageSize(pageSize int64) *ProjectsMetricsListCall {
  1649. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  1650. return c
  1651. }
  1652. // PageToken sets the optional parameter "pageToken": If the `pageToken`
  1653. // request parameter is supplied, then the next page of results in the
  1654. // set are retrieved. The `pageToken` parameter must be set with the
  1655. // value of the `nextPageToken` result parameter from the previous
  1656. // request. The value of `projectName` must be the same as in the
  1657. // previous request.
  1658. func (c *ProjectsMetricsListCall) PageToken(pageToken string) *ProjectsMetricsListCall {
  1659. c.urlParams_.Set("pageToken", pageToken)
  1660. return c
  1661. }
  1662. // Fields allows partial responses to be retrieved. See
  1663. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1664. // for more information.
  1665. func (c *ProjectsMetricsListCall) Fields(s ...googleapi.Field) *ProjectsMetricsListCall {
  1666. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1667. return c
  1668. }
  1669. // IfNoneMatch sets the optional parameter which makes the operation
  1670. // fail if the object's ETag matches the given value. This is useful for
  1671. // getting updates only after the object has changed since the last
  1672. // request. Use googleapi.IsNotModified to check whether the response
  1673. // error from Do is the result of In-None-Match.
  1674. func (c *ProjectsMetricsListCall) IfNoneMatch(entityTag string) *ProjectsMetricsListCall {
  1675. c.ifNoneMatch_ = entityTag
  1676. return c
  1677. }
  1678. // Context sets the context to be used in this call's Do method. Any
  1679. // pending HTTP request will be aborted if the provided context is
  1680. // canceled.
  1681. func (c *ProjectsMetricsListCall) Context(ctx context.Context) *ProjectsMetricsListCall {
  1682. c.ctx_ = ctx
  1683. return c
  1684. }
  1685. func (c *ProjectsMetricsListCall) doRequest(alt string) (*http.Response, error) {
  1686. var body io.Reader = nil
  1687. c.urlParams_.Set("alt", alt)
  1688. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+projectName}/metrics")
  1689. urls += "?" + c.urlParams_.Encode()
  1690. req, _ := http.NewRequest("GET", urls, body)
  1691. googleapi.Expand(req.URL, map[string]string{
  1692. "projectName": c.projectName,
  1693. })
  1694. req.Header.Set("User-Agent", c.s.userAgent())
  1695. if c.ifNoneMatch_ != "" {
  1696. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  1697. }
  1698. if c.ctx_ != nil {
  1699. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1700. }
  1701. return c.s.client.Do(req)
  1702. }
  1703. // Do executes the "logging.projects.metrics.list" call.
  1704. // Exactly one of *ListLogMetricsResponse or error will be non-nil. Any
  1705. // non-2xx status code is an error. Response headers are in either
  1706. // *ListLogMetricsResponse.ServerResponse.Header or (if a response was
  1707. // returned at all) in error.(*googleapi.Error).Header. Use
  1708. // googleapi.IsNotModified to check whether the returned error was
  1709. // because http.StatusNotModified was returned.
  1710. func (c *ProjectsMetricsListCall) Do(opts ...googleapi.CallOption) (*ListLogMetricsResponse, error) {
  1711. gensupport.SetOptions(c.urlParams_, opts...)
  1712. res, err := c.doRequest("json")
  1713. if res != nil && res.StatusCode == http.StatusNotModified {
  1714. if res.Body != nil {
  1715. res.Body.Close()
  1716. }
  1717. return nil, &googleapi.Error{
  1718. Code: res.StatusCode,
  1719. Header: res.Header,
  1720. }
  1721. }
  1722. if err != nil {
  1723. return nil, err
  1724. }
  1725. defer googleapi.CloseBody(res)
  1726. if err := googleapi.CheckResponse(res); err != nil {
  1727. return nil, err
  1728. }
  1729. ret := &ListLogMetricsResponse{
  1730. ServerResponse: googleapi.ServerResponse{
  1731. Header: res.Header,
  1732. HTTPStatusCode: res.StatusCode,
  1733. },
  1734. }
  1735. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1736. return nil, err
  1737. }
  1738. return ret, nil
  1739. // {
  1740. // "description": "Lists logs-based metrics.",
  1741. // "httpMethod": "GET",
  1742. // "id": "logging.projects.metrics.list",
  1743. // "parameterOrder": [
  1744. // "projectName"
  1745. // ],
  1746. // "parameters": {
  1747. // "pageSize": {
  1748. // "description": "Optional. The maximum number of results to return from this request. Fewer results might be returned. You must check for the `nextPageToken` result to determine if additional results are available, which you can retrieve by passing the `nextPageToken` value in the `pageToken` parameter to the next request.",
  1749. // "format": "int32",
  1750. // "location": "query",
  1751. // "type": "integer"
  1752. // },
  1753. // "pageToken": {
  1754. // "description": "Optional. If the `pageToken` request parameter is supplied, then the next page of results in the set are retrieved. The `pageToken` parameter must be set with the value of the `nextPageToken` result parameter from the previous request. The value of `projectName` must be the same as in the previous request.",
  1755. // "location": "query",
  1756. // "type": "string"
  1757. // },
  1758. // "projectName": {
  1759. // "description": "Required. The resource name of the project containing the metrics. Example: `\"projects/my-project-id\"`.",
  1760. // "location": "path",
  1761. // "pattern": "^projects/[^/]*$",
  1762. // "required": true,
  1763. // "type": "string"
  1764. // }
  1765. // },
  1766. // "path": "v2beta1/{+projectName}/metrics",
  1767. // "response": {
  1768. // "$ref": "ListLogMetricsResponse"
  1769. // },
  1770. // "scopes": [
  1771. // "https://www.googleapis.com/auth/cloud-platform",
  1772. // "https://www.googleapis.com/auth/cloud-platform.read-only",
  1773. // "https://www.googleapis.com/auth/logging.admin",
  1774. // "https://www.googleapis.com/auth/logging.read"
  1775. // ]
  1776. // }
  1777. }
  1778. // Pages invokes f for each page of results.
  1779. // A non-nil error returned from f will halt the iteration.
  1780. // The provided context supersedes any context provided to the Context method.
  1781. func (c *ProjectsMetricsListCall) Pages(ctx context.Context, f func(*ListLogMetricsResponse) error) error {
  1782. c.ctx_ = ctx
  1783. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  1784. for {
  1785. x, err := c.Do()
  1786. if err != nil {
  1787. return err
  1788. }
  1789. if err := f(x); err != nil {
  1790. return err
  1791. }
  1792. if x.NextPageToken == "" {
  1793. return nil
  1794. }
  1795. c.PageToken(x.NextPageToken)
  1796. }
  1797. }
  1798. // method id "logging.projects.metrics.update":
  1799. type ProjectsMetricsUpdateCall struct {
  1800. s *Service
  1801. metricNameid string
  1802. logmetric *LogMetric
  1803. urlParams_ gensupport.URLParams
  1804. ctx_ context.Context
  1805. }
  1806. // Update: Creates or updates a logs-based metric.
  1807. func (r *ProjectsMetricsService) Update(metricNameid string, logmetric *LogMetric) *ProjectsMetricsUpdateCall {
  1808. c := &ProjectsMetricsUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1809. c.metricNameid = metricNameid
  1810. c.logmetric = logmetric
  1811. return c
  1812. }
  1813. // Fields allows partial responses to be retrieved. See
  1814. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1815. // for more information.
  1816. func (c *ProjectsMetricsUpdateCall) Fields(s ...googleapi.Field) *ProjectsMetricsUpdateCall {
  1817. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1818. return c
  1819. }
  1820. // Context sets the context to be used in this call's Do method. Any
  1821. // pending HTTP request will be aborted if the provided context is
  1822. // canceled.
  1823. func (c *ProjectsMetricsUpdateCall) Context(ctx context.Context) *ProjectsMetricsUpdateCall {
  1824. c.ctx_ = ctx
  1825. return c
  1826. }
  1827. func (c *ProjectsMetricsUpdateCall) doRequest(alt string) (*http.Response, error) {
  1828. var body io.Reader = nil
  1829. body, err := googleapi.WithoutDataWrapper.JSONReader(c.logmetric)
  1830. if err != nil {
  1831. return nil, err
  1832. }
  1833. ctype := "application/json"
  1834. c.urlParams_.Set("alt", alt)
  1835. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+metricName}")
  1836. urls += "?" + c.urlParams_.Encode()
  1837. req, _ := http.NewRequest("PUT", urls, body)
  1838. googleapi.Expand(req.URL, map[string]string{
  1839. "metricName": c.metricNameid,
  1840. })
  1841. req.Header.Set("Content-Type", ctype)
  1842. req.Header.Set("User-Agent", c.s.userAgent())
  1843. if c.ctx_ != nil {
  1844. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1845. }
  1846. return c.s.client.Do(req)
  1847. }
  1848. // Do executes the "logging.projects.metrics.update" call.
  1849. // Exactly one of *LogMetric or error will be non-nil. Any non-2xx
  1850. // status code is an error. Response headers are in either
  1851. // *LogMetric.ServerResponse.Header or (if a response was returned at
  1852. // all) in error.(*googleapi.Error).Header. Use googleapi.IsNotModified
  1853. // to check whether the returned error was because
  1854. // http.StatusNotModified was returned.
  1855. func (c *ProjectsMetricsUpdateCall) Do(opts ...googleapi.CallOption) (*LogMetric, error) {
  1856. gensupport.SetOptions(c.urlParams_, opts...)
  1857. res, err := c.doRequest("json")
  1858. if res != nil && res.StatusCode == http.StatusNotModified {
  1859. if res.Body != nil {
  1860. res.Body.Close()
  1861. }
  1862. return nil, &googleapi.Error{
  1863. Code: res.StatusCode,
  1864. Header: res.Header,
  1865. }
  1866. }
  1867. if err != nil {
  1868. return nil, err
  1869. }
  1870. defer googleapi.CloseBody(res)
  1871. if err := googleapi.CheckResponse(res); err != nil {
  1872. return nil, err
  1873. }
  1874. ret := &LogMetric{
  1875. ServerResponse: googleapi.ServerResponse{
  1876. Header: res.Header,
  1877. HTTPStatusCode: res.StatusCode,
  1878. },
  1879. }
  1880. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1881. return nil, err
  1882. }
  1883. return ret, nil
  1884. // {
  1885. // "description": "Creates or updates a logs-based metric.",
  1886. // "httpMethod": "PUT",
  1887. // "id": "logging.projects.metrics.update",
  1888. // "parameterOrder": [
  1889. // "metricName"
  1890. // ],
  1891. // "parameters": {
  1892. // "metricName": {
  1893. // "description": "The resource name of the metric to update. Example: `\"projects/my-project-id/metrics/my-metric-id\"`. The updated metric must be provided in the request and have the same identifier that is specified in `metricName`. If the metric does not exist, it is created.",
  1894. // "location": "path",
  1895. // "pattern": "^projects/[^/]*/metrics/[^/]*$",
  1896. // "required": true,
  1897. // "type": "string"
  1898. // }
  1899. // },
  1900. // "path": "v2beta1/{+metricName}",
  1901. // "request": {
  1902. // "$ref": "LogMetric"
  1903. // },
  1904. // "response": {
  1905. // "$ref": "LogMetric"
  1906. // },
  1907. // "scopes": [
  1908. // "https://www.googleapis.com/auth/cloud-platform",
  1909. // "https://www.googleapis.com/auth/logging.admin",
  1910. // "https://www.googleapis.com/auth/logging.write"
  1911. // ]
  1912. // }
  1913. }
  1914. // method id "logging.projects.sinks.create":
  1915. type ProjectsSinksCreateCall struct {
  1916. s *Service
  1917. projectName string
  1918. logsink *LogSink
  1919. urlParams_ gensupport.URLParams
  1920. ctx_ context.Context
  1921. }
  1922. // Create: Creates a sink.
  1923. func (r *ProjectsSinksService) Create(projectName string, logsink *LogSink) *ProjectsSinksCreateCall {
  1924. c := &ProjectsSinksCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  1925. c.projectName = projectName
  1926. c.logsink = logsink
  1927. return c
  1928. }
  1929. // Fields allows partial responses to be retrieved. See
  1930. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  1931. // for more information.
  1932. func (c *ProjectsSinksCreateCall) Fields(s ...googleapi.Field) *ProjectsSinksCreateCall {
  1933. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  1934. return c
  1935. }
  1936. // Context sets the context to be used in this call's Do method. Any
  1937. // pending HTTP request will be aborted if the provided context is
  1938. // canceled.
  1939. func (c *ProjectsSinksCreateCall) Context(ctx context.Context) *ProjectsSinksCreateCall {
  1940. c.ctx_ = ctx
  1941. return c
  1942. }
  1943. func (c *ProjectsSinksCreateCall) doRequest(alt string) (*http.Response, error) {
  1944. var body io.Reader = nil
  1945. body, err := googleapi.WithoutDataWrapper.JSONReader(c.logsink)
  1946. if err != nil {
  1947. return nil, err
  1948. }
  1949. ctype := "application/json"
  1950. c.urlParams_.Set("alt", alt)
  1951. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+projectName}/sinks")
  1952. urls += "?" + c.urlParams_.Encode()
  1953. req, _ := http.NewRequest("POST", urls, body)
  1954. googleapi.Expand(req.URL, map[string]string{
  1955. "projectName": c.projectName,
  1956. })
  1957. req.Header.Set("Content-Type", ctype)
  1958. req.Header.Set("User-Agent", c.s.userAgent())
  1959. if c.ctx_ != nil {
  1960. return ctxhttp.Do(c.ctx_, c.s.client, req)
  1961. }
  1962. return c.s.client.Do(req)
  1963. }
  1964. // Do executes the "logging.projects.sinks.create" call.
  1965. // Exactly one of *LogSink or error will be non-nil. Any non-2xx status
  1966. // code is an error. Response headers are in either
  1967. // *LogSink.ServerResponse.Header or (if a response was returned at all)
  1968. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  1969. // check whether the returned error was because http.StatusNotModified
  1970. // was returned.
  1971. func (c *ProjectsSinksCreateCall) Do(opts ...googleapi.CallOption) (*LogSink, error) {
  1972. gensupport.SetOptions(c.urlParams_, opts...)
  1973. res, err := c.doRequest("json")
  1974. if res != nil && res.StatusCode == http.StatusNotModified {
  1975. if res.Body != nil {
  1976. res.Body.Close()
  1977. }
  1978. return nil, &googleapi.Error{
  1979. Code: res.StatusCode,
  1980. Header: res.Header,
  1981. }
  1982. }
  1983. if err != nil {
  1984. return nil, err
  1985. }
  1986. defer googleapi.CloseBody(res)
  1987. if err := googleapi.CheckResponse(res); err != nil {
  1988. return nil, err
  1989. }
  1990. ret := &LogSink{
  1991. ServerResponse: googleapi.ServerResponse{
  1992. Header: res.Header,
  1993. HTTPStatusCode: res.StatusCode,
  1994. },
  1995. }
  1996. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  1997. return nil, err
  1998. }
  1999. return ret, nil
  2000. // {
  2001. // "description": "Creates a sink.",
  2002. // "httpMethod": "POST",
  2003. // "id": "logging.projects.sinks.create",
  2004. // "parameterOrder": [
  2005. // "projectName"
  2006. // ],
  2007. // "parameters": {
  2008. // "projectName": {
  2009. // "description": "The resource name of the project in which to create the sink. Example: `\"projects/my-project-id\"`. The new sink must be provided in the request.",
  2010. // "location": "path",
  2011. // "pattern": "^projects/[^/]*$",
  2012. // "required": true,
  2013. // "type": "string"
  2014. // }
  2015. // },
  2016. // "path": "v2beta1/{+projectName}/sinks",
  2017. // "request": {
  2018. // "$ref": "LogSink"
  2019. // },
  2020. // "response": {
  2021. // "$ref": "LogSink"
  2022. // },
  2023. // "scopes": [
  2024. // "https://www.googleapis.com/auth/cloud-platform",
  2025. // "https://www.googleapis.com/auth/logging.admin"
  2026. // ]
  2027. // }
  2028. }
  2029. // method id "logging.projects.sinks.delete":
  2030. type ProjectsSinksDeleteCall struct {
  2031. s *Service
  2032. sinkName string
  2033. urlParams_ gensupport.URLParams
  2034. ctx_ context.Context
  2035. }
  2036. // Delete: Deletes a sink.
  2037. func (r *ProjectsSinksService) Delete(sinkName string) *ProjectsSinksDeleteCall {
  2038. c := &ProjectsSinksDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2039. c.sinkName = sinkName
  2040. return c
  2041. }
  2042. // Fields allows partial responses to be retrieved. See
  2043. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2044. // for more information.
  2045. func (c *ProjectsSinksDeleteCall) Fields(s ...googleapi.Field) *ProjectsSinksDeleteCall {
  2046. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2047. return c
  2048. }
  2049. // Context sets the context to be used in this call's Do method. Any
  2050. // pending HTTP request will be aborted if the provided context is
  2051. // canceled.
  2052. func (c *ProjectsSinksDeleteCall) Context(ctx context.Context) *ProjectsSinksDeleteCall {
  2053. c.ctx_ = ctx
  2054. return c
  2055. }
  2056. func (c *ProjectsSinksDeleteCall) doRequest(alt string) (*http.Response, error) {
  2057. var body io.Reader = nil
  2058. c.urlParams_.Set("alt", alt)
  2059. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+sinkName}")
  2060. urls += "?" + c.urlParams_.Encode()
  2061. req, _ := http.NewRequest("DELETE", urls, body)
  2062. googleapi.Expand(req.URL, map[string]string{
  2063. "sinkName": c.sinkName,
  2064. })
  2065. req.Header.Set("User-Agent", c.s.userAgent())
  2066. if c.ctx_ != nil {
  2067. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2068. }
  2069. return c.s.client.Do(req)
  2070. }
  2071. // Do executes the "logging.projects.sinks.delete" call.
  2072. // Exactly one of *Empty or error will be non-nil. Any non-2xx status
  2073. // code is an error. Response headers are in either
  2074. // *Empty.ServerResponse.Header or (if a response was returned at all)
  2075. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2076. // check whether the returned error was because http.StatusNotModified
  2077. // was returned.
  2078. func (c *ProjectsSinksDeleteCall) Do(opts ...googleapi.CallOption) (*Empty, error) {
  2079. gensupport.SetOptions(c.urlParams_, opts...)
  2080. res, err := c.doRequest("json")
  2081. if res != nil && res.StatusCode == http.StatusNotModified {
  2082. if res.Body != nil {
  2083. res.Body.Close()
  2084. }
  2085. return nil, &googleapi.Error{
  2086. Code: res.StatusCode,
  2087. Header: res.Header,
  2088. }
  2089. }
  2090. if err != nil {
  2091. return nil, err
  2092. }
  2093. defer googleapi.CloseBody(res)
  2094. if err := googleapi.CheckResponse(res); err != nil {
  2095. return nil, err
  2096. }
  2097. ret := &Empty{
  2098. ServerResponse: googleapi.ServerResponse{
  2099. Header: res.Header,
  2100. HTTPStatusCode: res.StatusCode,
  2101. },
  2102. }
  2103. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2104. return nil, err
  2105. }
  2106. return ret, nil
  2107. // {
  2108. // "description": "Deletes a sink.",
  2109. // "httpMethod": "DELETE",
  2110. // "id": "logging.projects.sinks.delete",
  2111. // "parameterOrder": [
  2112. // "sinkName"
  2113. // ],
  2114. // "parameters": {
  2115. // "sinkName": {
  2116. // "description": "The resource name of the sink to delete. Example: `\"projects/my-project-id/sinks/my-sink-id\"`.",
  2117. // "location": "path",
  2118. // "pattern": "^projects/[^/]*/sinks/[^/]*$",
  2119. // "required": true,
  2120. // "type": "string"
  2121. // }
  2122. // },
  2123. // "path": "v2beta1/{+sinkName}",
  2124. // "response": {
  2125. // "$ref": "Empty"
  2126. // },
  2127. // "scopes": [
  2128. // "https://www.googleapis.com/auth/cloud-platform",
  2129. // "https://www.googleapis.com/auth/logging.admin"
  2130. // ]
  2131. // }
  2132. }
  2133. // method id "logging.projects.sinks.get":
  2134. type ProjectsSinksGetCall struct {
  2135. s *Service
  2136. sinkName string
  2137. urlParams_ gensupport.URLParams
  2138. ifNoneMatch_ string
  2139. ctx_ context.Context
  2140. }
  2141. // Get: Gets a sink.
  2142. func (r *ProjectsSinksService) Get(sinkName string) *ProjectsSinksGetCall {
  2143. c := &ProjectsSinksGetCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2144. c.sinkName = sinkName
  2145. return c
  2146. }
  2147. // Fields allows partial responses to be retrieved. See
  2148. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2149. // for more information.
  2150. func (c *ProjectsSinksGetCall) Fields(s ...googleapi.Field) *ProjectsSinksGetCall {
  2151. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2152. return c
  2153. }
  2154. // IfNoneMatch sets the optional parameter which makes the operation
  2155. // fail if the object's ETag matches the given value. This is useful for
  2156. // getting updates only after the object has changed since the last
  2157. // request. Use googleapi.IsNotModified to check whether the response
  2158. // error from Do is the result of In-None-Match.
  2159. func (c *ProjectsSinksGetCall) IfNoneMatch(entityTag string) *ProjectsSinksGetCall {
  2160. c.ifNoneMatch_ = entityTag
  2161. return c
  2162. }
  2163. // Context sets the context to be used in this call's Do method. Any
  2164. // pending HTTP request will be aborted if the provided context is
  2165. // canceled.
  2166. func (c *ProjectsSinksGetCall) Context(ctx context.Context) *ProjectsSinksGetCall {
  2167. c.ctx_ = ctx
  2168. return c
  2169. }
  2170. func (c *ProjectsSinksGetCall) doRequest(alt string) (*http.Response, error) {
  2171. var body io.Reader = nil
  2172. c.urlParams_.Set("alt", alt)
  2173. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+sinkName}")
  2174. urls += "?" + c.urlParams_.Encode()
  2175. req, _ := http.NewRequest("GET", urls, body)
  2176. googleapi.Expand(req.URL, map[string]string{
  2177. "sinkName": c.sinkName,
  2178. })
  2179. req.Header.Set("User-Agent", c.s.userAgent())
  2180. if c.ifNoneMatch_ != "" {
  2181. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2182. }
  2183. if c.ctx_ != nil {
  2184. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2185. }
  2186. return c.s.client.Do(req)
  2187. }
  2188. // Do executes the "logging.projects.sinks.get" call.
  2189. // Exactly one of *LogSink or error will be non-nil. Any non-2xx status
  2190. // code is an error. Response headers are in either
  2191. // *LogSink.ServerResponse.Header or (if a response was returned at all)
  2192. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2193. // check whether the returned error was because http.StatusNotModified
  2194. // was returned.
  2195. func (c *ProjectsSinksGetCall) Do(opts ...googleapi.CallOption) (*LogSink, error) {
  2196. gensupport.SetOptions(c.urlParams_, opts...)
  2197. res, err := c.doRequest("json")
  2198. if res != nil && res.StatusCode == http.StatusNotModified {
  2199. if res.Body != nil {
  2200. res.Body.Close()
  2201. }
  2202. return nil, &googleapi.Error{
  2203. Code: res.StatusCode,
  2204. Header: res.Header,
  2205. }
  2206. }
  2207. if err != nil {
  2208. return nil, err
  2209. }
  2210. defer googleapi.CloseBody(res)
  2211. if err := googleapi.CheckResponse(res); err != nil {
  2212. return nil, err
  2213. }
  2214. ret := &LogSink{
  2215. ServerResponse: googleapi.ServerResponse{
  2216. Header: res.Header,
  2217. HTTPStatusCode: res.StatusCode,
  2218. },
  2219. }
  2220. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2221. return nil, err
  2222. }
  2223. return ret, nil
  2224. // {
  2225. // "description": "Gets a sink.",
  2226. // "httpMethod": "GET",
  2227. // "id": "logging.projects.sinks.get",
  2228. // "parameterOrder": [
  2229. // "sinkName"
  2230. // ],
  2231. // "parameters": {
  2232. // "sinkName": {
  2233. // "description": "The resource name of the sink to return. Example: `\"projects/my-project-id/sinks/my-sink-id\"`.",
  2234. // "location": "path",
  2235. // "pattern": "^projects/[^/]*/sinks/[^/]*$",
  2236. // "required": true,
  2237. // "type": "string"
  2238. // }
  2239. // },
  2240. // "path": "v2beta1/{+sinkName}",
  2241. // "response": {
  2242. // "$ref": "LogSink"
  2243. // },
  2244. // "scopes": [
  2245. // "https://www.googleapis.com/auth/cloud-platform",
  2246. // "https://www.googleapis.com/auth/cloud-platform.read-only",
  2247. // "https://www.googleapis.com/auth/logging.admin",
  2248. // "https://www.googleapis.com/auth/logging.read"
  2249. // ]
  2250. // }
  2251. }
  2252. // method id "logging.projects.sinks.list":
  2253. type ProjectsSinksListCall struct {
  2254. s *Service
  2255. projectName string
  2256. urlParams_ gensupport.URLParams
  2257. ifNoneMatch_ string
  2258. ctx_ context.Context
  2259. }
  2260. // List: Lists sinks.
  2261. func (r *ProjectsSinksService) List(projectName string) *ProjectsSinksListCall {
  2262. c := &ProjectsSinksListCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2263. c.projectName = projectName
  2264. return c
  2265. }
  2266. // PageSize sets the optional parameter "pageSize": The maximum number
  2267. // of results to return from this request. Fewer results might be
  2268. // returned. You must check for the `nextPageToken` result to determine
  2269. // if additional results are available, which you can retrieve by
  2270. // passing the `nextPageToken` value in the `pageToken` parameter to the
  2271. // next request.
  2272. func (c *ProjectsSinksListCall) PageSize(pageSize int64) *ProjectsSinksListCall {
  2273. c.urlParams_.Set("pageSize", fmt.Sprint(pageSize))
  2274. return c
  2275. }
  2276. // PageToken sets the optional parameter "pageToken": If the `pageToken`
  2277. // request parameter is supplied, then the next page of results in the
  2278. // set are retrieved. The `pageToken` parameter must be set with the
  2279. // value of the `nextPageToken` result parameter from the previous
  2280. // request. The value of `projectName` must be the same as in the
  2281. // previous request.
  2282. func (c *ProjectsSinksListCall) PageToken(pageToken string) *ProjectsSinksListCall {
  2283. c.urlParams_.Set("pageToken", pageToken)
  2284. return c
  2285. }
  2286. // Fields allows partial responses to be retrieved. See
  2287. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2288. // for more information.
  2289. func (c *ProjectsSinksListCall) Fields(s ...googleapi.Field) *ProjectsSinksListCall {
  2290. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2291. return c
  2292. }
  2293. // IfNoneMatch sets the optional parameter which makes the operation
  2294. // fail if the object's ETag matches the given value. This is useful for
  2295. // getting updates only after the object has changed since the last
  2296. // request. Use googleapi.IsNotModified to check whether the response
  2297. // error from Do is the result of In-None-Match.
  2298. func (c *ProjectsSinksListCall) IfNoneMatch(entityTag string) *ProjectsSinksListCall {
  2299. c.ifNoneMatch_ = entityTag
  2300. return c
  2301. }
  2302. // Context sets the context to be used in this call's Do method. Any
  2303. // pending HTTP request will be aborted if the provided context is
  2304. // canceled.
  2305. func (c *ProjectsSinksListCall) Context(ctx context.Context) *ProjectsSinksListCall {
  2306. c.ctx_ = ctx
  2307. return c
  2308. }
  2309. func (c *ProjectsSinksListCall) doRequest(alt string) (*http.Response, error) {
  2310. var body io.Reader = nil
  2311. c.urlParams_.Set("alt", alt)
  2312. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+projectName}/sinks")
  2313. urls += "?" + c.urlParams_.Encode()
  2314. req, _ := http.NewRequest("GET", urls, body)
  2315. googleapi.Expand(req.URL, map[string]string{
  2316. "projectName": c.projectName,
  2317. })
  2318. req.Header.Set("User-Agent", c.s.userAgent())
  2319. if c.ifNoneMatch_ != "" {
  2320. req.Header.Set("If-None-Match", c.ifNoneMatch_)
  2321. }
  2322. if c.ctx_ != nil {
  2323. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2324. }
  2325. return c.s.client.Do(req)
  2326. }
  2327. // Do executes the "logging.projects.sinks.list" call.
  2328. // Exactly one of *ListSinksResponse or error will be non-nil. Any
  2329. // non-2xx status code is an error. Response headers are in either
  2330. // *ListSinksResponse.ServerResponse.Header or (if a response was
  2331. // returned at all) in error.(*googleapi.Error).Header. Use
  2332. // googleapi.IsNotModified to check whether the returned error was
  2333. // because http.StatusNotModified was returned.
  2334. func (c *ProjectsSinksListCall) Do(opts ...googleapi.CallOption) (*ListSinksResponse, error) {
  2335. gensupport.SetOptions(c.urlParams_, opts...)
  2336. res, err := c.doRequest("json")
  2337. if res != nil && res.StatusCode == http.StatusNotModified {
  2338. if res.Body != nil {
  2339. res.Body.Close()
  2340. }
  2341. return nil, &googleapi.Error{
  2342. Code: res.StatusCode,
  2343. Header: res.Header,
  2344. }
  2345. }
  2346. if err != nil {
  2347. return nil, err
  2348. }
  2349. defer googleapi.CloseBody(res)
  2350. if err := googleapi.CheckResponse(res); err != nil {
  2351. return nil, err
  2352. }
  2353. ret := &ListSinksResponse{
  2354. ServerResponse: googleapi.ServerResponse{
  2355. Header: res.Header,
  2356. HTTPStatusCode: res.StatusCode,
  2357. },
  2358. }
  2359. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2360. return nil, err
  2361. }
  2362. return ret, nil
  2363. // {
  2364. // "description": "Lists sinks.",
  2365. // "httpMethod": "GET",
  2366. // "id": "logging.projects.sinks.list",
  2367. // "parameterOrder": [
  2368. // "projectName"
  2369. // ],
  2370. // "parameters": {
  2371. // "pageSize": {
  2372. // "description": "Optional. The maximum number of results to return from this request. Fewer results might be returned. You must check for the `nextPageToken` result to determine if additional results are available, which you can retrieve by passing the `nextPageToken` value in the `pageToken` parameter to the next request.",
  2373. // "format": "int32",
  2374. // "location": "query",
  2375. // "type": "integer"
  2376. // },
  2377. // "pageToken": {
  2378. // "description": "Optional. If the `pageToken` request parameter is supplied, then the next page of results in the set are retrieved. The `pageToken` parameter must be set with the value of the `nextPageToken` result parameter from the previous request. The value of `projectName` must be the same as in the previous request.",
  2379. // "location": "query",
  2380. // "type": "string"
  2381. // },
  2382. // "projectName": {
  2383. // "description": "Required. The resource name of the project containing the sinks. Example: `\"projects/my-logging-project\"`, `\"projects/01234567890\"`.",
  2384. // "location": "path",
  2385. // "pattern": "^projects/[^/]*$",
  2386. // "required": true,
  2387. // "type": "string"
  2388. // }
  2389. // },
  2390. // "path": "v2beta1/{+projectName}/sinks",
  2391. // "response": {
  2392. // "$ref": "ListSinksResponse"
  2393. // },
  2394. // "scopes": [
  2395. // "https://www.googleapis.com/auth/cloud-platform",
  2396. // "https://www.googleapis.com/auth/cloud-platform.read-only",
  2397. // "https://www.googleapis.com/auth/logging.admin",
  2398. // "https://www.googleapis.com/auth/logging.read"
  2399. // ]
  2400. // }
  2401. }
  2402. // Pages invokes f for each page of results.
  2403. // A non-nil error returned from f will halt the iteration.
  2404. // The provided context supersedes any context provided to the Context method.
  2405. func (c *ProjectsSinksListCall) Pages(ctx context.Context, f func(*ListSinksResponse) error) error {
  2406. c.ctx_ = ctx
  2407. defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point
  2408. for {
  2409. x, err := c.Do()
  2410. if err != nil {
  2411. return err
  2412. }
  2413. if err := f(x); err != nil {
  2414. return err
  2415. }
  2416. if x.NextPageToken == "" {
  2417. return nil
  2418. }
  2419. c.PageToken(x.NextPageToken)
  2420. }
  2421. }
  2422. // method id "logging.projects.sinks.update":
  2423. type ProjectsSinksUpdateCall struct {
  2424. s *Service
  2425. sinkName string
  2426. logsink *LogSink
  2427. urlParams_ gensupport.URLParams
  2428. ctx_ context.Context
  2429. }
  2430. // Update: Creates or updates a sink.
  2431. func (r *ProjectsSinksService) Update(sinkName string, logsink *LogSink) *ProjectsSinksUpdateCall {
  2432. c := &ProjectsSinksUpdateCall{s: r.s, urlParams_: make(gensupport.URLParams)}
  2433. c.sinkName = sinkName
  2434. c.logsink = logsink
  2435. return c
  2436. }
  2437. // Fields allows partial responses to be retrieved. See
  2438. // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse
  2439. // for more information.
  2440. func (c *ProjectsSinksUpdateCall) Fields(s ...googleapi.Field) *ProjectsSinksUpdateCall {
  2441. c.urlParams_.Set("fields", googleapi.CombineFields(s))
  2442. return c
  2443. }
  2444. // Context sets the context to be used in this call's Do method. Any
  2445. // pending HTTP request will be aborted if the provided context is
  2446. // canceled.
  2447. func (c *ProjectsSinksUpdateCall) Context(ctx context.Context) *ProjectsSinksUpdateCall {
  2448. c.ctx_ = ctx
  2449. return c
  2450. }
  2451. func (c *ProjectsSinksUpdateCall) doRequest(alt string) (*http.Response, error) {
  2452. var body io.Reader = nil
  2453. body, err := googleapi.WithoutDataWrapper.JSONReader(c.logsink)
  2454. if err != nil {
  2455. return nil, err
  2456. }
  2457. ctype := "application/json"
  2458. c.urlParams_.Set("alt", alt)
  2459. urls := googleapi.ResolveRelative(c.s.BasePath, "v2beta1/{+sinkName}")
  2460. urls += "?" + c.urlParams_.Encode()
  2461. req, _ := http.NewRequest("PUT", urls, body)
  2462. googleapi.Expand(req.URL, map[string]string{
  2463. "sinkName": c.sinkName,
  2464. })
  2465. req.Header.Set("Content-Type", ctype)
  2466. req.Header.Set("User-Agent", c.s.userAgent())
  2467. if c.ctx_ != nil {
  2468. return ctxhttp.Do(c.ctx_, c.s.client, req)
  2469. }
  2470. return c.s.client.Do(req)
  2471. }
  2472. // Do executes the "logging.projects.sinks.update" call.
  2473. // Exactly one of *LogSink or error will be non-nil. Any non-2xx status
  2474. // code is an error. Response headers are in either
  2475. // *LogSink.ServerResponse.Header or (if a response was returned at all)
  2476. // in error.(*googleapi.Error).Header. Use googleapi.IsNotModified to
  2477. // check whether the returned error was because http.StatusNotModified
  2478. // was returned.
  2479. func (c *ProjectsSinksUpdateCall) Do(opts ...googleapi.CallOption) (*LogSink, error) {
  2480. gensupport.SetOptions(c.urlParams_, opts...)
  2481. res, err := c.doRequest("json")
  2482. if res != nil && res.StatusCode == http.StatusNotModified {
  2483. if res.Body != nil {
  2484. res.Body.Close()
  2485. }
  2486. return nil, &googleapi.Error{
  2487. Code: res.StatusCode,
  2488. Header: res.Header,
  2489. }
  2490. }
  2491. if err != nil {
  2492. return nil, err
  2493. }
  2494. defer googleapi.CloseBody(res)
  2495. if err := googleapi.CheckResponse(res); err != nil {
  2496. return nil, err
  2497. }
  2498. ret := &LogSink{
  2499. ServerResponse: googleapi.ServerResponse{
  2500. Header: res.Header,
  2501. HTTPStatusCode: res.StatusCode,
  2502. },
  2503. }
  2504. if err := json.NewDecoder(res.Body).Decode(&ret); err != nil {
  2505. return nil, err
  2506. }
  2507. return ret, nil
  2508. // {
  2509. // "description": "Creates or updates a sink.",
  2510. // "httpMethod": "PUT",
  2511. // "id": "logging.projects.sinks.update",
  2512. // "parameterOrder": [
  2513. // "sinkName"
  2514. // ],
  2515. // "parameters": {
  2516. // "sinkName": {
  2517. // "description": "The resource name of the sink to update. Example: `\"projects/my-project-id/sinks/my-sink-id\"`. The updated sink must be provided in the request and have the same name that is specified in `sinkName`. If the sink does not exist, it is created.",
  2518. // "location": "path",
  2519. // "pattern": "^projects/[^/]*/sinks/[^/]*$",
  2520. // "required": true,
  2521. // "type": "string"
  2522. // }
  2523. // },
  2524. // "path": "v2beta1/{+sinkName}",
  2525. // "request": {
  2526. // "$ref": "LogSink"
  2527. // },
  2528. // "response": {
  2529. // "$ref": "LogSink"
  2530. // },
  2531. // "scopes": [
  2532. // "https://www.googleapis.com/auth/cloud-platform",
  2533. // "https://www.googleapis.com/auth/logging.admin"
  2534. // ]
  2535. // }
  2536. }