Debian Codegraph @

travelimpactmodel/v1/travelimpactmodel-gen.go

raw
1 // Copyright 2026 Google LLC.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // Code generated file. DO NOT EDIT.
6
7 // Package travelimpactmodel provides access to the Travel Impact Model API.
8 //
9 // For product documentation, see: https://developers.google.com/travel/impact-model
10 //
11 // # Library status
12 //
13 // These client libraries are officially supported by Google. However, this
14 // library is considered complete and is in maintenance mode. This means
15 // that we will address critical bugs and security issues but will not add
16 // any new features.
17 //
18 // When possible, we recommend using our newer
19 // [Cloud Client Libraries for Go](https://pkg.go.dev/cloud.google.com/go)
20 // that are still actively being worked and iterated on.
21 //
22 // # Creating a client
23 //
24 // Usage example:
25 //
26 // import "google.golang.org/api/travelimpactmodel/v1"
27 // ...
28 // ctx := context.Background()
29 // travelimpactmodelService, err := travelimpactmodel.NewService(ctx)
30 //
31 // In this example, Google Application Default Credentials are used for
32 // authentication. For information on how to create and obtain Application
33 // Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials.
34 //
35 // # Other authentication options
36 //
37 // To use an API key for authentication (note: some APIs do not support API
38 // keys), use [google.golang.org/api/option.WithAPIKey]:
39 //
40 // travelimpactmodelService, err := travelimpactmodel.NewService(ctx, option.WithAPIKey("AIza..."))
41 //
42 // To use an OAuth token (e.g., a user token obtained via a three-legged OAuth
43 // flow, use [google.golang.org/api/option.WithTokenSource]:
44 //
45 // config := &oauth2.Config{...}
46 // // ...
47 // token, err := config.Exchange(ctx, ...)
48 // travelimpactmodelService, err := travelimpactmodel.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token)))
49 //
50 // See [google.golang.org/api/option.ClientOption] for details on options.
51 package travelimpactmodel // import "google.golang.org/api/travelimpactmodel/v1"
52
53 import (
54 "bytes"
55 "context"
56 "encoding/json"
57 "errors"
58 "fmt"
59 "io"
60 "log/slog"
61 "net/http"
62 "net/url"
63 "strconv"
64 "strings"
65
66 "github.com/googleapis/gax-go/v2/internallog"
67 googleapi "google.golang.org/api/googleapi"
68 internal "google.golang.org/api/internal"
69 gensupport "google.golang.org/api/internal/gensupport"
70 option "google.golang.org/api/option"
71 internaloption "google.golang.org/api/option/internaloption"
72 htransport "google.golang.org/api/transport/http"
73 )
74
75 // Always reference these packages, just in case the auto-generated code
76 // below doesn't.
77 var _ = bytes.NewBuffer
78 var _ = strconv.Itoa
79 var _ = fmt.Sprintf
80 var _ = json.NewDecoder
81 var _ = io.Copy
82 var _ = url.Parse
83 var _ = gensupport.MarshalJSON
84 var _ = googleapi.Version
85 var _ = errors.New
86 var _ = strings.Replace
87 var _ = context.Canceled
88 var _ = internaloption.WithDefaultEndpoint
89 var _ = internal.Version
90 var _ = internallog.New
91
92 const apiId = "travelimpactmodel:v1"
93 const apiName = "travelimpactmodel"
94 const apiVersion = "v1"
95 const basePath = "https://travelimpactmodel.googleapis.com/"
96 const basePathTemplate = "https://travelimpactmodel.UNIVERSE_DOMAIN/"
97 const mtlsBasePath = "https://travelimpactmodel.mtls.googleapis.com/"
98
99 // NewService creates a new Service.
100 func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) {
101 opts = append(opts, internaloption.WithDefaultEndpoint(basePath))
102 opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate))
103 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))
104 opts = append(opts, internaloption.EnableNewAuthLibrary())
105 client, endpoint, err := htransport.NewClient(ctx, opts...)
106 if err != nil {
107 return nil, err
108 }
109 s := &Service{client: client, BasePath: basePath, logger: internaloption.GetLogger(opts)}
110 s.Flights = NewFlightsService(s)
111 if endpoint != "" {
112 s.BasePath = endpoint
113 }
114 return s, nil
115 }
116
117 // New creates a new Service. It uses the provided http.Client for requests.
118 //
119 // Deprecated: please use NewService instead.
120 // To provide a custom HTTP client, use option.WithHTTPClient.
121 // If you are using google.golang.org/api/googleapis/transport.APIKey, use option.WithAPIKey with NewService instead.
122 func New(client *http.Client) (*Service, error) {
123 if client == nil {
124 return nil, errors.New("client is nil")
125 }
126 return NewService(context.TODO(), option.WithHTTPClient(client))
127 }
128
129 type Service struct {
130 client *http.Client
131 logger *slog.Logger
132 BasePath string // API endpoint base URL
133 UserAgent string // optional additional User-Agent fragment
134
135 Flights *FlightsService
136 }
137
138 func (s *Service) userAgent() string {
139 if s.UserAgent == "" {
140 return googleapi.UserAgent
141 }
142 return googleapi.UserAgent + " " + s.UserAgent
143 }
144
145 func NewFlightsService(s *Service) *FlightsService {
146 rs := &FlightsService{s: s}
147 return rs
148 }
149
150 type FlightsService struct {
151 s *Service
152 }
153
154 // ComputeFlightEmissionsRequest: Input definition for the
155 // ComputeFlightEmissions request.
156 type ComputeFlightEmissionsRequest struct {
157 // Flights: Required. Direct flights to return emission estimates for.
158 Flights []*Flight `json:"flights,omitempty"`
159 // ForceSendFields is a list of field names (e.g. "Flights") to unconditionally
160 // include in API requests. By default, fields with empty or default values are
161 // omitted from API requests. See
162 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
163 // details.
164 ForceSendFields []string `json:"-"`
165 // NullFields is a list of field names (e.g. "Flights") to include in API
166 // requests with the JSON null value. By default, fields with empty values are
167 // omitted from API requests. See
168 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
169 NullFields []string `json:"-"`
170 }
171
172 func (s ComputeFlightEmissionsRequest) MarshalJSON() ([]byte, error) {
173 type NoMethod ComputeFlightEmissionsRequest
174 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
175 }
176
177 // ComputeFlightEmissionsResponse: Output definition for the
178 // ComputeFlightEmissions response.
179 type ComputeFlightEmissionsResponse struct {
180 // FlightEmissions: List of flight legs with emission estimates.
181 FlightEmissions []*FlightWithEmissions `json:"flightEmissions,omitempty"`
182 // ModelVersion: The model version under which emission estimates for all
183 // flights in this response were computed.
184 ModelVersion *ModelVersion `json:"modelVersion,omitempty"`
185
186 // ServerResponse contains the HTTP response code and headers from the server.
187 googleapi.ServerResponse `json:"-"`
188 // ForceSendFields is a list of field names (e.g. "FlightEmissions") to
189 // unconditionally include in API requests. By default, fields with empty or
190 // default values are omitted from API requests. See
191 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
192 // details.
193 ForceSendFields []string `json:"-"`
194 // NullFields is a list of field names (e.g. "FlightEmissions") to include in
195 // API requests with the JSON null value. By default, fields with empty values
196 // are omitted from API requests. See
197 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
198 NullFields []string `json:"-"`
199 }
200
201 func (s ComputeFlightEmissionsResponse) MarshalJSON() ([]byte, error) {
202 type NoMethod ComputeFlightEmissionsResponse
203 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
204 }
205
206 // ComputeScope3FlightEmissionsRequest: A list of flight segments to request
207 // the Scope 3 emissions for.
208 type ComputeScope3FlightEmissionsRequest struct {
209 // Flights: Required. Flights to return emission estimates for.
210 Flights []*Scope3FlightSegment `json:"flights,omitempty"`
211 // ModelVersion: Optional. The model version under which emission estimates for
212 // all flights in this request were computed.
213 ModelVersion *ModelVersion `json:"modelVersion,omitempty"`
214 // ForceSendFields is a list of field names (e.g. "Flights") to unconditionally
215 // include in API requests. By default, fields with empty or default values are
216 // omitted from API requests. See
217 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
218 // details.
219 ForceSendFields []string `json:"-"`
220 // NullFields is a list of field names (e.g. "Flights") to include in API
221 // requests with the JSON null value. By default, fields with empty values are
222 // omitted from API requests. See
223 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
224 NullFields []string `json:"-"`
225 }
226
227 func (s ComputeScope3FlightEmissionsRequest) MarshalJSON() ([]byte, error) {
228 type NoMethod ComputeScope3FlightEmissionsRequest
229 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
230 }
231
232 // ComputeScope3FlightEmissionsResponse: A list of flights with Scope 3
233 // emission estimates.
234 type ComputeScope3FlightEmissionsResponse struct {
235 // FlightEmissions: List of flight segments with emission estimates.
236 FlightEmissions []*Scope3FlightEmissions `json:"flightEmissions,omitempty"`
237 // ModelVersion: The model version under which emission estimates for all
238 // flights in this response were computed.
239 ModelVersion *ModelVersion `json:"modelVersion,omitempty"`
240
241 // ServerResponse contains the HTTP response code and headers from the server.
242 googleapi.ServerResponse `json:"-"`
243 // ForceSendFields is a list of field names (e.g. "FlightEmissions") to
244 // unconditionally include in API requests. By default, fields with empty or
245 // default values are omitted from API requests. See
246 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
247 // details.
248 ForceSendFields []string `json:"-"`
249 // NullFields is a list of field names (e.g. "FlightEmissions") to include in
250 // API requests with the JSON null value. By default, fields with empty values
251 // are omitted from API requests. See
252 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
253 NullFields []string `json:"-"`
254 }
255
256 func (s ComputeScope3FlightEmissionsResponse) MarshalJSON() ([]byte, error) {
257 type NoMethod ComputeScope3FlightEmissionsResponse
258 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
259 }
260
261 // ComputeTypicalFlightEmissionsRequest: A list of pair of airports (markets)
262 // to request the typical emissions for.
263 type ComputeTypicalFlightEmissionsRequest struct {
264 // Markets: Required. Request the typical flight emissions estimates for this
265 // market pair. A maximum of 1000 markets can be requested.
266 Markets []*Market `json:"markets,omitempty"`
267 // ForceSendFields is a list of field names (e.g. "Markets") to unconditionally
268 // include in API requests. By default, fields with empty or default values are
269 // omitted from API requests. See
270 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
271 // details.
272 ForceSendFields []string `json:"-"`
273 // NullFields is a list of field names (e.g. "Markets") to include in API
274 // requests with the JSON null value. By default, fields with empty values are
275 // omitted from API requests. See
276 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
277 NullFields []string `json:"-"`
278 }
279
280 func (s ComputeTypicalFlightEmissionsRequest) MarshalJSON() ([]byte, error) {
281 type NoMethod ComputeTypicalFlightEmissionsRequest
282 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
283 }
284
285 // ComputeTypicalFlightEmissionsResponse: The response includes the emissions
286 // but also the model version.
287 type ComputeTypicalFlightEmissionsResponse struct {
288 // ModelVersion: The model version under which typical flight emission
289 // estimates for all flights in this response were computed.
290 ModelVersion *ModelVersion `json:"modelVersion,omitempty"`
291 // TypicalFlightEmissions: Market's Typical Flight Emissions requested.
292 TypicalFlightEmissions []*TypicalFlightEmissions `json:"typicalFlightEmissions,omitempty"`
293
294 // ServerResponse contains the HTTP response code and headers from the server.
295 googleapi.ServerResponse `json:"-"`
296 // ForceSendFields is a list of field names (e.g. "ModelVersion") to
297 // unconditionally include in API requests. By default, fields with empty or
298 // default values are omitted from API requests. See
299 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
300 // details.
301 ForceSendFields []string `json:"-"`
302 // NullFields is a list of field names (e.g. "ModelVersion") to include in API
303 // requests with the JSON null value. By default, fields with empty values are
304 // omitted from API requests. See
305 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
306 NullFields []string `json:"-"`
307 }
308
309 func (s ComputeTypicalFlightEmissionsResponse) MarshalJSON() ([]byte, error) {
310 type NoMethod ComputeTypicalFlightEmissionsResponse
311 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
312 }
313
314 // Date: Represents a whole or partial calendar date, such as a birthday. The
315 // time of day and time zone are either specified elsewhere or are
316 // insignificant. The date is relative to the Gregorian Calendar. This can
317 // represent one of the following: * A full date, with non-zero year, month,
318 // and day values. * A month and day, with a zero year (for example, an
319 // anniversary). * A year on its own, with a zero month and a zero day. * A
320 // year and month, with a zero day (for example, a credit card expiration
321 // date). Related types: * google.type.TimeOfDay * google.type.DateTime *
322 // google.protobuf.Timestamp
323 type Date struct {
324 // Day: Day of a month. Must be from 1 to 31 and valid for the year and month,
325 // or 0 to specify a year by itself or a year and month where the day isn't
326 // significant.
327 Day int64 `json:"day,omitempty"`
328 // Month: Month of a year. Must be from 1 to 12, or 0 to specify a year without
329 // a month and day.
330 Month int64 `json:"month,omitempty"`
331 // Year: Year of the date. Must be from 1 to 9999, or 0 to specify a date
332 // without a year.
333 Year int64 `json:"year,omitempty"`
334 // ForceSendFields is a list of field names (e.g. "Day") to unconditionally
335 // include in API requests. By default, fields with empty or default values are
336 // omitted from API requests. See
337 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
338 // details.
339 ForceSendFields []string `json:"-"`
340 // NullFields is a list of field names (e.g. "Day") to include in API requests
341 // with the JSON null value. By default, fields with empty values are omitted
342 // from API requests. See
343 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
344 NullFields []string `json:"-"`
345 }
346
347 func (s Date) MarshalJSON() ([]byte, error) {
348 type NoMethod Date
349 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
350 }
351
352 // EasaLabelMetadata: Metadata about the EASA Flight Emissions Label.
353 type EasaLabelMetadata struct {
354 // LabelExpiryDate: The date when the label expires. The label can be displayed
355 // until the end of this date.
356 LabelExpiryDate *Date `json:"labelExpiryDate,omitempty"`
357 // LabelIssueDate: The date when the label was issued.
358 LabelIssueDate *Date `json:"labelIssueDate,omitempty"`
359 // LabelVersion: Version of the label.
360 LabelVersion string `json:"labelVersion,omitempty"`
361 // SafDiscountPercentage: Sustainable Aviation Fuel (SAF) emissions discount
362 // percentage applied to the label. It is a percentage as a decimal. The values
363 // are in the interval [0,1]. For example, 0.0021 means 0.21%. This discount
364 // and reduction in emissions are reported by the EASA label but they are not
365 // included in the CO2e estimates distributed by this API.
366 SafDiscountPercentage float64 `json:"safDiscountPercentage,omitempty"`
367 // ForceSendFields is a list of field names (e.g. "LabelExpiryDate") to
368 // unconditionally include in API requests. By default, fields with empty or
369 // default values are omitted from API requests. See
370 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
371 // details.
372 ForceSendFields []string `json:"-"`
373 // NullFields is a list of field names (e.g. "LabelExpiryDate") to include in
374 // API requests with the JSON null value. By default, fields with empty values
375 // are omitted from API requests. See
376 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
377 NullFields []string `json:"-"`
378 }
379
380 func (s EasaLabelMetadata) MarshalJSON() ([]byte, error) {
381 type NoMethod EasaLabelMetadata
382 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
383 }
384
385 func (s *EasaLabelMetadata) UnmarshalJSON(data []byte) error {
386 type NoMethod EasaLabelMetadata
387 var s1 struct {
388 SafDiscountPercentage gensupport.JSONFloat64 `json:"safDiscountPercentage"`
389 *NoMethod
390 }
391 s1.NoMethod = (*NoMethod)(s)
392 if err := json.Unmarshal(data, &s1); err != nil {
393 return err
394 }
395 s.SafDiscountPercentage = float64(s1.SafDiscountPercentage)
396 return nil
397 }
398
399 // EmissionsGramsPerPax: Grouped emissions per seating class results.
400 type EmissionsGramsPerPax struct {
401 // Business: Emissions for one passenger in business class in grams. This field
402 // is always computed and populated, regardless of whether the aircraft has
403 // business class seats or not.
404 Business int64 `json:"business,omitempty"`
405 // Economy: Emissions for one passenger in economy class in grams. This field
406 // is always computed and populated, regardless of whether the aircraft has
407 // economy class seats or not.
408 Economy int64 `json:"economy,omitempty"`
409 // First: Emissions for one passenger in first class in grams. This field is
410 // always computed and populated, regardless of whether the aircraft has first
411 // class seats or not.
412 First int64 `json:"first,omitempty"`
413 // PremiumEconomy: Emissions for one passenger in premium economy class in
414 // grams. This field is always computed and populated, regardless of whether
415 // the aircraft has premium economy class seats or not.
416 PremiumEconomy int64 `json:"premiumEconomy,omitempty"`
417 // ForceSendFields is a list of field names (e.g. "Business") to
418 // unconditionally include in API requests. By default, fields with empty or
419 // default values are omitted from API requests. See
420 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
421 // details.
422 ForceSendFields []string `json:"-"`
423 // NullFields is a list of field names (e.g. "Business") to include in API
424 // requests with the JSON null value. By default, fields with empty values are
425 // omitted from API requests. See
426 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
427 NullFields []string `json:"-"`
428 }
429
430 func (s EmissionsGramsPerPax) MarshalJSON() ([]byte, error) {
431 type NoMethod EmissionsGramsPerPax
432 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
433 }
434
435 // Flight: All details related to a single request item for a direct flight
436 // emission estimates.
437 type Flight struct {
438 // DepartureDate: Required. Date of the flight in the time zone of the origin
439 // airport. Must be a date in the present or future.
440 DepartureDate *Date `json:"departureDate,omitempty"`
441 // Destination: Required. IATA airport code for flight destination, e.g. "JFK".
442 Destination string `json:"destination,omitempty"`
443 // FlightNumber: Required. Flight number, e.g. 324.
444 FlightNumber int64 `json:"flightNumber,omitempty"`
445 // OperatingCarrierCode: Required. IATA carrier code, e.g. "AA".
446 OperatingCarrierCode string `json:"operatingCarrierCode,omitempty"`
447 // Origin: Required. IATA airport code for flight origin, e.g. "LHR".
448 Origin string `json:"origin,omitempty"`
449 // ForceSendFields is a list of field names (e.g. "DepartureDate") to
450 // unconditionally include in API requests. By default, fields with empty or
451 // default values are omitted from API requests. See
452 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
453 // details.
454 ForceSendFields []string `json:"-"`
455 // NullFields is a list of field names (e.g. "DepartureDate") to include in API
456 // requests with the JSON null value. By default, fields with empty values are
457 // omitted from API requests. See
458 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
459 NullFields []string `json:"-"`
460 }
461
462 func (s Flight) MarshalJSON() ([]byte, error) {
463 type NoMethod Flight
464 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
465 }
466
467 // FlightWithEmissions: Direct flight with emission estimates.
468 type FlightWithEmissions struct {
469 // ContrailsImpactBucket: Optional. The significance of contrails warming
470 // impact compared to the total CO2e emissions impact.
471 //
472 // Possible values:
473 // "CONTRAILS_IMPACT_UNSPECIFIED" - The contrails impact is unspecified.
474 // "CONTRAILS_IMPACT_NEGLIGIBLE" - The contrails impact is negligible
475 // compared to the total CO2e emissions.
476 // "CONTRAILS_IMPACT_MODERATE" - The contrails impact is comparable to the
477 // total CO2e emissions.
478 // "CONTRAILS_IMPACT_SEVERE" - The contrails impact is higher than the total
479 // CO2e emissions impact.
480 ContrailsImpactBucket string `json:"contrailsImpactBucket,omitempty"`
481 // EasaLabelMetadata: Optional. Metadata about the EASA Flight Emissions Label.
482 // Only set when the emissions data source is EASA.
483 EasaLabelMetadata *EasaLabelMetadata `json:"easaLabelMetadata,omitempty"`
484 // EmissionsGramsPerPax: Optional. Per-passenger emission estimate numbers.
485 // Will not be present if emissions could not be computed. For the list of
486 // reasons why emissions could not be computed, see ComputeFlightEmissions.
487 EmissionsGramsPerPax *EmissionsGramsPerPax `json:"emissionsGramsPerPax,omitempty"`
488 // Flight: Identifier. Matches the flight identifiers in the request. Note: all
489 // IATA codes are capitalized.
490 Flight *Flight `json:"flight,omitempty"`
491 // Source: Optional. The source of the emissions data.
492 //
493 // Possible values:
494 // "SOURCE_UNSPECIFIED" - The source of the emissions data is unspecified.
495 // "TIM" - The emissions data is from the Travel Impact Model.
496 // "EASA" - The emissions data is from the EASA environmental labels.
497 Source string `json:"source,omitempty"`
498 // ForceSendFields is a list of field names (e.g. "ContrailsImpactBucket") to
499 // unconditionally include in API requests. By default, fields with empty or
500 // default values are omitted from API requests. See
501 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
502 // details.
503 ForceSendFields []string `json:"-"`
504 // NullFields is a list of field names (e.g. "ContrailsImpactBucket") to
505 // include in API requests with the JSON null value. By default, fields with
506 // empty values are omitted from API requests. See
507 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
508 NullFields []string `json:"-"`
509 }
510
511 func (s FlightWithEmissions) MarshalJSON() ([]byte, error) {
512 type NoMethod FlightWithEmissions
513 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
514 }
515
516 // Market: A pair of airports.
517 type Market struct {
518 // Destination: Required. IATA airport code for flight destination, e.g. "JFK".
519 Destination string `json:"destination,omitempty"`
520 // Origin: Required. IATA airport code for flight origin, e.g. "LHR".
521 Origin string `json:"origin,omitempty"`
522 // ForceSendFields is a list of field names (e.g. "Destination") to
523 // unconditionally include in API requests. By default, fields with empty or
524 // default values are omitted from API requests. See
525 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
526 // details.
527 ForceSendFields []string `json:"-"`
528 // NullFields is a list of field names (e.g. "Destination") to include in API
529 // requests with the JSON null value. By default, fields with empty values are
530 // omitted from API requests. See
531 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
532 NullFields []string `json:"-"`
533 }
534
535 func (s Market) MarshalJSON() ([]byte, error) {
536 type NoMethod Market
537 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
538 }
539
540 // ModelVersion: Travel Impact Model version. For more information about the
541 // model versioning see GitHub
542 // (https://github.com/google/travel-impact-model/#versioning).
543 type ModelVersion struct {
544 // Dated: Dated versions: Model datasets are recreated with refreshed input
545 // data but no change to the algorithms regularly.
546 Dated string `json:"dated,omitempty"`
547 // Major: Major versions: Major changes to methodology (e.g. adding new data
548 // sources to the model that lead to major output changes). Such changes will
549 // be infrequent and announced well in advance. Might involve API version
550 // changes, which will respect Google Cloud API guidelines
551 // (https://cloud.google.com/endpoints/docs/openapi/versioning-an-api#backwards-incompatible)
552 Major int64 `json:"major,omitempty"`
553 // Minor: Minor versions: Changes to the model that, while being consistent
554 // across schema versions, change the model parameters or implementation.
555 Minor int64 `json:"minor,omitempty"`
556 // Patch: Patch versions: Implementation changes meant to address bugs or
557 // inaccuracies in the model implementation.
558 Patch int64 `json:"patch,omitempty"`
559 // ForceSendFields is a list of field names (e.g. "Dated") to unconditionally
560 // include in API requests. By default, fields with empty or default values are
561 // omitted from API requests. See
562 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
563 // details.
564 ForceSendFields []string `json:"-"`
565 // NullFields is a list of field names (e.g. "Dated") to include in API
566 // requests with the JSON null value. By default, fields with empty values are
567 // omitted from API requests. See
568 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
569 NullFields []string `json:"-"`
570 }
571
572 func (s ModelVersion) MarshalJSON() ([]byte, error) {
573 type NoMethod ModelVersion
574 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
575 }
576
577 // Scope3FlightEmissions: Scope 3 flight with emission estimates.
578 type Scope3FlightEmissions struct {
579 // Flight: Identifier. Matches the flight identifiers in the request.
580 Flight *Scope3FlightSegment `json:"flight,omitempty"`
581 // Source: Optional. The source of the emissions data.
582 //
583 // Possible values:
584 // "SCOPE3_DATA_TYPE_UNSPECIFIED" - Unspecified data type.
585 // "TIM_EMISSIONS" - TIM-based emissions given origin, destination, carrier,
586 // flight number, departure date, and year.
587 // "TYPICAL_FLIGHT_EMISSIONS" - Typical flight emissions given origin,
588 // destination, and year.
589 // "DISTANCE_BASED_EMISSIONS" - Distance-based emissions based on the
590 // distance traveled and year.
591 Source string `json:"source,omitempty"`
592 // TtwEmissionsGramsPerPax: Optional. Tank-to-wake flight emissions per
593 // passenger based on the requested info.
594 TtwEmissionsGramsPerPax int64 `json:"ttwEmissionsGramsPerPax,omitempty,string"`
595 // WttEmissionsGramsPerPax: Optional. Well-to-tank flight emissions per
596 // passenger based on the requested info.
597 WttEmissionsGramsPerPax int64 `json:"wttEmissionsGramsPerPax,omitempty,string"`
598 // WtwEmissionsGramsPerPax: Optional. Total flight emissions (sum of
599 // well-to-tank and tank-to-wake) per passenger based on the requested info.
600 // This is the total emissions and unless you have specific reasons for using
601 // TTW or WTT emissions, you should use this number.
602 WtwEmissionsGramsPerPax int64 `json:"wtwEmissionsGramsPerPax,omitempty,string"`
603 // ForceSendFields is a list of field names (e.g. "Flight") to unconditionally
604 // include in API requests. By default, fields with empty or default values are
605 // omitted from API requests. See
606 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
607 // details.
608 ForceSendFields []string `json:"-"`
609 // NullFields is a list of field names (e.g. "Flight") to include in API
610 // requests with the JSON null value. By default, fields with empty values are
611 // omitted from API requests. See
612 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
613 NullFields []string `json:"-"`
614 }
615
616 func (s Scope3FlightEmissions) MarshalJSON() ([]byte, error) {
617 type NoMethod Scope3FlightEmissions
618 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
619 }
620
621 // Scope3FlightSegment: Flight parameters with which the Scope 3 emissions are
622 // fetched.
623 type Scope3FlightSegment struct {
624 // CabinClass: Required. The cabin class of the flight.
625 //
626 // Possible values:
627 // "CABIN_CLASS_UNSPECIFIED" - Unspecified cabin class.
628 // "ECONOMY" - Economy class.
629 // "PREMIUM_ECONOMY" - Premium economy class.
630 // "BUSINESS" - Business class.
631 // "FIRST" - First class.
632 CabinClass string `json:"cabinClass,omitempty"`
633 // CarrierCode: Optional. 2-character IATA carrier code
634 // (https://www.iata.org/en/publications/directories/code-search/), e.g. `KE`.
635 // This is required if specific flight matching is desired. Otherwise, this is
636 // unused for typical flight and distance-based emissions models. This could be
637 // both operating and marketing carrier code (i.e. codeshare is covered).
638 CarrierCode string `json:"carrierCode,omitempty"`
639 // DepartureDate: Required. Date of the flight in the time zone of the origin
640 // airport. Only year is required for typical flight and distance-based
641 // emissions models (month and day values are ignored and therefore, can be
642 // either omitted, set to 0, or set to a valid date for those cases).
643 // Correspondingly, if a specific date is not provided for TIM emissions, we
644 // will fallback to typical flight (or distance-based) emissions.
645 DepartureDate *Date `json:"departureDate,omitempty"`
646 // Destination: Optional. 3-character IATA airport code
647 // (https://www.iata.org/en/publications/directories/code-search/) for flight
648 // destination, e.g. `ICN`. This is used to match specific flight if provided
649 // alongside origin, carrier, and flight number. If there is no match, we will
650 // first try to match the flight to a typical flight between the provided
651 // origin and destination airports. Otherwise, we will use the distance-based
652 // emissions model if the flight distance is provided.
653 Destination string `json:"destination,omitempty"`
654 // DistanceKm: Optional. Distance in kilometers, e.g. `2423`, from [1, 2.5e16)
655 // km. This is used to match a flight to distance-based emissions when origin
656 // and destination are not provided or there are no matching typical flights.
657 DistanceKm int64 `json:"distanceKm,omitempty,string"`
658 // FlightNumber: Optional. Up to 4-digit flight number
659 // (https://en.wikipedia.org/wiki/Flight_number), e.g. `71`, from [1, 9999].
660 // This is first used to match a specific flight if a flight number is
661 // specified alongside origin, destination, and carrier. If a flight number is
662 // not specified, we will first try to match the flight to a typical flight
663 // between the provided origin and destination airports. If that fails and/or
664 // origin & destination are not provided, we will use the distance-based
665 // emissions model based on the flight distance provided.
666 FlightNumber int64 `json:"flightNumber,omitempty"`
667 // Origin: Optional. 3-character IATA airport code
668 // (https://www.iata.org/en/publications/directories/code-search/) for flight
669 // origin, e.g. `YVR`. This is used to match specific flight if provided
670 // alongside destination, carrier, and flight number. If there is no match, we
671 // will first try to match the flight to a typical flight between the provided
672 // origin and destination airports. Otherwise, we will use the distance-based
673 // emissions model if the flight distance is provided.
674 Origin string `json:"origin,omitempty"`
675 // ForceSendFields is a list of field names (e.g. "CabinClass") to
676 // unconditionally include in API requests. By default, fields with empty or
677 // default values are omitted from API requests. See
678 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
679 // details.
680 ForceSendFields []string `json:"-"`
681 // NullFields is a list of field names (e.g. "CabinClass") to include in API
682 // requests with the JSON null value. By default, fields with empty values are
683 // omitted from API requests. See
684 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
685 NullFields []string `json:"-"`
686 }
687
688 func (s Scope3FlightSegment) MarshalJSON() ([]byte, error) {
689 type NoMethod Scope3FlightSegment
690 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
691 }
692
693 // TypicalFlightEmissions: Typical flight emission estimates for a certain
694 // market
695 type TypicalFlightEmissions struct {
696 // EmissionsGramsPerPax: Optional. Typical flight emissions per passenger for
697 // requested market. Will not be present if a typical emissions could not be
698 // computed. For the list of reasons why typical flight emissions could not be
699 // computed, see GitHub
700 // (https://github.com/google/travel-impact-model/blob/main/projects/typical_flight_emissions.md#step-7-validate-dataset).
701 EmissionsGramsPerPax *EmissionsGramsPerPax `json:"emissionsGramsPerPax,omitempty"`
702 // Market: Identifier. Matches the flight identifiers in the request. Note: all
703 // IATA codes are capitalized.
704 Market *Market `json:"market,omitempty"`
705 // ForceSendFields is a list of field names (e.g. "EmissionsGramsPerPax") to
706 // unconditionally include in API requests. By default, fields with empty or
707 // default values are omitted from API requests. See
708 // https://pkg.go.dev/google.golang.org/api#hdr-ForceSendFields for more
709 // details.
710 ForceSendFields []string `json:"-"`
711 // NullFields is a list of field names (e.g. "EmissionsGramsPerPax") to include
712 // in API requests with the JSON null value. By default, fields with empty
713 // values are omitted from API requests. See
714 // https://pkg.go.dev/google.golang.org/api#hdr-NullFields for more details.
715 NullFields []string `json:"-"`
716 }
717
718 func (s TypicalFlightEmissions) MarshalJSON() ([]byte, error) {
719 type NoMethod TypicalFlightEmissions
720 return gensupport.MarshalJSON(NoMethod(s), s.ForceSendFields, s.NullFields)
721 }
722
723 type FlightsComputeFlightEmissionsCall struct {
724 s *Service
725 computeflightemissionsrequest *ComputeFlightEmissionsRequest
726 urlParams_ gensupport.URLParams
727 ctx_ context.Context
728 header_ http.Header
729 }
730
731 // ComputeFlightEmissions: Stateless method to retrieve emission estimates.
732 // Details on how emission estimates are computed are in GitHub
733 // (https://github.com/google/travel-impact-model) The response will contain
734 // all entries that match the input flight legs, in the same order. If there
735 // are no estimates available for a certain flight leg, the response will
736 // return the flight leg object with empty emission fields. The request will
737 // still be considered successful. Reasons for missing emission estimates
738 // include: * The flight is unknown to the server. * The input flight leg is
739 // missing one or more identifiers. * The flight date is in the past. * The
740 // aircraft type is not supported by the model. * Missing seat configuration.
741 // The request can contain up to 1000 flight legs. If the request has more than
742 // 1000 direct flights, if will fail with an INVALID_ARGUMENT error.
743 func (r *FlightsService) ComputeFlightEmissions(computeflightemissionsrequest *ComputeFlightEmissionsRequest) *FlightsComputeFlightEmissionsCall {
744 c := &FlightsComputeFlightEmissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
745 c.computeflightemissionsrequest = computeflightemissionsrequest
746 return c
747 }
748
749 // Fields allows partial responses to be retrieved. See
750 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
751 // details.
752 func (c *FlightsComputeFlightEmissionsCall) Fields(s ...googleapi.Field) *FlightsComputeFlightEmissionsCall {
753 c.urlParams_.Set("fields", googleapi.CombineFields(s))
754 return c
755 }
756
757 // Context sets the context to be used in this call's Do method.
758 func (c *FlightsComputeFlightEmissionsCall) Context(ctx context.Context) *FlightsComputeFlightEmissionsCall {
759 c.ctx_ = ctx
760 return c
761 }
762
763 // Header returns a http.Header that can be modified by the caller to add
764 // headers to the request.
765 func (c *FlightsComputeFlightEmissionsCall) Header() http.Header {
766 if c.header_ == nil {
767 c.header_ = make(http.Header)
768 }
769 return c.header_
770 }
771
772 func (c *FlightsComputeFlightEmissionsCall) doRequest(alt string) (*http.Response, error) {
773 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
774 body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.computeflightemissionsrequest)
775 if err != nil {
776 return nil, err
777 }
778 c.urlParams_.Set("alt", alt)
779 c.urlParams_.Set("prettyPrint", "false")
780 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/flights:computeFlightEmissions")
781 urls += "?" + c.urlParams_.Encode()
782 req, err := http.NewRequest("POST", urls, body)
783 if err != nil {
784 return nil, err
785 }
786 req.Header = reqHeaders
787 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "travelimpactmodel.flights.computeFlightEmissions", "request", internallog.HTTPRequest(req, body.Bytes()))
788 return gensupport.SendRequest(c.ctx_, c.s.client, req)
789 }
790
791 // Do executes the "travelimpactmodel.flights.computeFlightEmissions" call.
792 // Any non-2xx status code is an error. Response headers are in either
793 // *ComputeFlightEmissionsResponse.ServerResponse.Header or (if a response was
794 // returned at all) in error.(*googleapi.Error).Header. Use
795 // googleapi.IsNotModified to check whether the returned error was because
796 // http.StatusNotModified was returned.
797 func (c *FlightsComputeFlightEmissionsCall) Do(opts ...googleapi.CallOption) (*ComputeFlightEmissionsResponse, error) {
798 gensupport.SetOptions(c.urlParams_, opts...)
799 res, err := c.doRequest("json")
800 if res != nil && res.StatusCode == http.StatusNotModified {
801 if res.Body != nil {
802 res.Body.Close()
803 }
804 return nil, gensupport.WrapError(&googleapi.Error{
805 Code: res.StatusCode,
806 Header: res.Header,
807 })
808 }
809 if err != nil {
810 return nil, err
811 }
812 defer googleapi.CloseBody(res)
813 if err := googleapi.CheckResponse(res); err != nil {
814 return nil, gensupport.WrapError(err)
815 }
816 ret := &ComputeFlightEmissionsResponse{
817 ServerResponse: googleapi.ServerResponse{
818 Header: res.Header,
819 HTTPStatusCode: res.StatusCode,
820 },
821 }
822 target := &ret
823 b, err := gensupport.DecodeResponseBytes(target, res)
824 if err != nil {
825 return nil, err
826 }
827 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "travelimpactmodel.flights.computeFlightEmissions", "response", internallog.HTTPResponse(res, b))
828 return ret, nil
829 }
830
831 type FlightsComputeScope3FlightEmissionsCall struct {
832 s *Service
833 computescope3flightemissionsrequest *ComputeScope3FlightEmissionsRequest
834 urlParams_ gensupport.URLParams
835 ctx_ context.Context
836 header_ http.Header
837 }
838
839 // ComputeScope3FlightEmissions: Stateless method to retrieve GHG emissions
840 // estimates for a set of flight segments for Scope 3 reporting. The response
841 // will contain all entries that match the input Scope3FlightSegment flight
842 // segments, in the same order provided. The estimates will be computed using
843 // the following cascading logic (using the first one that is available): 1.
844 // TIM-based emissions given origin, destination, carrier, flightNumber,
845 // departureDate, and cabinClass. 2. Typical flight emissions given origin,
846 // destination, year in departureDate, and cabinClass. 3. Distance-based
847 // emissions calculated using distanceKm, year in departureDate, and
848 // cabinClass. If there is a future flight requested in this calendar year, we
849 // do not support Tier 1 emissions and will fallback to Tier 2 or 3 emissions.
850 // If the requested future flight is in not in this calendar year, we will
851 // return an empty response. We recommend that for future flights,
852 // computeFlightEmissions API is used instead. If there are no estimates
853 // available for a certain flight with any of the three methods, the response
854 // will return a Scope3FlightEmissions object with empty emission fields. The
855 // request will still be considered successful. Generally, missing emissions
856 // estimates occur when the flight is unknown to the server (e.g. no specific
857 // flight exists, or typical flight emissions are not available for the
858 // requested pair). The request will fail with an `INVALID_ARGUMENT` error if:
859 // * The request contains more than 1,000 flight legs. * The input flight leg
860 // is missing one or more identifiers. For example, missing origin/destination
861 // without a valid distance for TIM_EMISSIONS or TYPICAL_FLIGHT_EMISSIONS type
862 // matching, or missing distance for a DISTANCE_BASED_EMISSIONS type matching
863 // (if you want to fallback to distance-based emissions or want a
864 // distance-based emissions estimate, you need to specify a distance). * The
865 // flight date is before 2019 (Scope 3 data is only available for 2019 and
866 // after). * The flight distance is 0 or lower. * Missing cabin class. Because
867 // the request is processed with fallback logic, it is possible that
868 // misconfigured requests return valid emissions estimates using fallback
869 // methods. For example, if a request has the wrong flight number but specifies
870 // the origin and destination, the request will still succeed, but the returned
871 // emissions will be based solely on the typical flight emissions. Similarly,
872 // if a request is missing the origin for a typical flight emissions request,
873 // but specifies a valid distance, the request could succeed based solely on
874 // the distance-based emissions. Consequently, one should check the source of
875 // the returned emissions (source) to confirm the results are as expected.
876 func (r *FlightsService) ComputeScope3FlightEmissions(computescope3flightemissionsrequest *ComputeScope3FlightEmissionsRequest) *FlightsComputeScope3FlightEmissionsCall {
877 c := &FlightsComputeScope3FlightEmissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
878 c.computescope3flightemissionsrequest = computescope3flightemissionsrequest
879 return c
880 }
881
882 // Fields allows partial responses to be retrieved. See
883 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
884 // details.
885 func (c *FlightsComputeScope3FlightEmissionsCall) Fields(s ...googleapi.Field) *FlightsComputeScope3FlightEmissionsCall {
886 c.urlParams_.Set("fields", googleapi.CombineFields(s))
887 return c
888 }
889
890 // Context sets the context to be used in this call's Do method.
891 func (c *FlightsComputeScope3FlightEmissionsCall) Context(ctx context.Context) *FlightsComputeScope3FlightEmissionsCall {
892 c.ctx_ = ctx
893 return c
894 }
895
896 // Header returns a http.Header that can be modified by the caller to add
897 // headers to the request.
898 func (c *FlightsComputeScope3FlightEmissionsCall) Header() http.Header {
899 if c.header_ == nil {
900 c.header_ = make(http.Header)
901 }
902 return c.header_
903 }
904
905 func (c *FlightsComputeScope3FlightEmissionsCall) doRequest(alt string) (*http.Response, error) {
906 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
907 body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.computescope3flightemissionsrequest)
908 if err != nil {
909 return nil, err
910 }
911 c.urlParams_.Set("alt", alt)
912 c.urlParams_.Set("prettyPrint", "false")
913 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/flights:computeScope3FlightEmissions")
914 urls += "?" + c.urlParams_.Encode()
915 req, err := http.NewRequest("POST", urls, body)
916 if err != nil {
917 return nil, err
918 }
919 req.Header = reqHeaders
920 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "travelimpactmodel.flights.computeScope3FlightEmissions", "request", internallog.HTTPRequest(req, body.Bytes()))
921 return gensupport.SendRequest(c.ctx_, c.s.client, req)
922 }
923
924 // Do executes the "travelimpactmodel.flights.computeScope3FlightEmissions" call.
925 // Any non-2xx status code is an error. Response headers are in either
926 // *ComputeScope3FlightEmissionsResponse.ServerResponse.Header or (if a
927 // response was returned at all) in error.(*googleapi.Error).Header. Use
928 // googleapi.IsNotModified to check whether the returned error was because
929 // http.StatusNotModified was returned.
930 func (c *FlightsComputeScope3FlightEmissionsCall) Do(opts ...googleapi.CallOption) (*ComputeScope3FlightEmissionsResponse, error) {
931 gensupport.SetOptions(c.urlParams_, opts...)
932 res, err := c.doRequest("json")
933 if res != nil && res.StatusCode == http.StatusNotModified {
934 if res.Body != nil {
935 res.Body.Close()
936 }
937 return nil, gensupport.WrapError(&googleapi.Error{
938 Code: res.StatusCode,
939 Header: res.Header,
940 })
941 }
942 if err != nil {
943 return nil, err
944 }
945 defer googleapi.CloseBody(res)
946 if err := googleapi.CheckResponse(res); err != nil {
947 return nil, gensupport.WrapError(err)
948 }
949 ret := &ComputeScope3FlightEmissionsResponse{
950 ServerResponse: googleapi.ServerResponse{
951 Header: res.Header,
952 HTTPStatusCode: res.StatusCode,
953 },
954 }
955 target := &ret
956 b, err := gensupport.DecodeResponseBytes(target, res)
957 if err != nil {
958 return nil, err
959 }
960 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "travelimpactmodel.flights.computeScope3FlightEmissions", "response", internallog.HTTPResponse(res, b))
961 return ret, nil
962 }
963
964 type FlightsComputeTypicalFlightEmissionsCall struct {
965 s *Service
966 computetypicalflightemissionsrequest *ComputeTypicalFlightEmissionsRequest
967 urlParams_ gensupport.URLParams
968 ctx_ context.Context
969 header_ http.Header
970 }
971
972 // ComputeTypicalFlightEmissions: Retrieves typical flight emissions estimates
973 // between two airports, also known as a market. If there are no estimates
974 // available for a certain market, the response will return the market object
975 // with empty emission fields. The request will still be considered successful.
976 // Details on how the typical emissions estimates are computed are on GitHub
977 // (https://github.com/google/travel-impact-model/blob/main/projects/typical_flight_emissions.md).
978 // The request can contain up to 1000 markets. If the request has more than
979 // 1000 markets, it will fail with an INVALID_ARGUMENT error.
980 func (r *FlightsService) ComputeTypicalFlightEmissions(computetypicalflightemissionsrequest *ComputeTypicalFlightEmissionsRequest) *FlightsComputeTypicalFlightEmissionsCall {
981 c := &FlightsComputeTypicalFlightEmissionsCall{s: r.s, urlParams_: make(gensupport.URLParams)}
982 c.computetypicalflightemissionsrequest = computetypicalflightemissionsrequest
983 return c
984 }
985
986 // Fields allows partial responses to be retrieved. See
987 // https://developers.google.com/gdata/docs/2.0/basics#PartialResponse for more
988 // details.
989 func (c *FlightsComputeTypicalFlightEmissionsCall) Fields(s ...googleapi.Field) *FlightsComputeTypicalFlightEmissionsCall {
990 c.urlParams_.Set("fields", googleapi.CombineFields(s))
991 return c
992 }
993
994 // Context sets the context to be used in this call's Do method.
995 func (c *FlightsComputeTypicalFlightEmissionsCall) Context(ctx context.Context) *FlightsComputeTypicalFlightEmissionsCall {
996 c.ctx_ = ctx
997 return c
998 }
999
1000 // Header returns a http.Header that can be modified by the caller to add
1001 // headers to the request.
1002 func (c *FlightsComputeTypicalFlightEmissionsCall) Header() http.Header {
1003 if c.header_ == nil {
1004 c.header_ = make(http.Header)
1005 }
1006 return c.header_
1007 }
1008
1009 func (c *FlightsComputeTypicalFlightEmissionsCall) doRequest(alt string) (*http.Response, error) {
1010 reqHeaders := gensupport.SetHeaders(c.s.userAgent(), "application/json", c.header_)
1011 body, err := googleapi.WithoutDataWrapper.JSONBuffer(c.computetypicalflightemissionsrequest)
1012 if err != nil {
1013 return nil, err
1014 }
1015 c.urlParams_.Set("alt", alt)
1016 c.urlParams_.Set("prettyPrint", "false")
1017 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/flights:computeTypicalFlightEmissions")
1018 urls += "?" + c.urlParams_.Encode()
1019 req, err := http.NewRequest("POST", urls, body)
1020 if err != nil {
1021 return nil, err
1022 }
1023 req.Header = reqHeaders
1024 c.s.logger.DebugContext(c.ctx_, "api request", "serviceName", apiName, "rpcName", "travelimpactmodel.flights.computeTypicalFlightEmissions", "request", internallog.HTTPRequest(req, body.Bytes()))
1025 return gensupport.SendRequest(c.ctx_, c.s.client, req)
1026 }
1027
1028 // Do executes the "travelimpactmodel.flights.computeTypicalFlightEmissions" call.
1029 // Any non-2xx status code is an error. Response headers are in either
1030 // *ComputeTypicalFlightEmissionsResponse.ServerResponse.Header or (if a
1031 // response was returned at all) in error.(*googleapi.Error).Header. Use
1032 // googleapi.IsNotModified to check whether the returned error was because
1033 // http.StatusNotModified was returned.
1034 func (c *FlightsComputeTypicalFlightEmissionsCall) Do(opts ...googleapi.CallOption) (*ComputeTypicalFlightEmissionsResponse, error) {
1035 gensupport.SetOptions(c.urlParams_, opts...)
1036 res, err := c.doRequest("json")
1037 if res != nil && res.StatusCode == http.StatusNotModified {
1038 if res.Body != nil {
1039 res.Body.Close()
1040 }
1041 return nil, gensupport.WrapError(&googleapi.Error{
1042 Code: res.StatusCode,
1043 Header: res.Header,
1044 })
1045 }
1046 if err != nil {
1047 return nil, err
1048 }
1049 defer googleapi.CloseBody(res)
1050 if err := googleapi.CheckResponse(res); err != nil {
1051 return nil, gensupport.WrapError(err)
1052 }
1053 ret := &ComputeTypicalFlightEmissionsResponse{
1054 ServerResponse: googleapi.ServerResponse{
1055 Header: res.Header,
1056 HTTPStatusCode: res.StatusCode,
1057 },
1058 }
1059 target := &ret
1060 b, err := gensupport.DecodeResponseBytes(target, res)
1061 if err != nil {
1062 return nil, err
1063 }
1064 c.s.logger.DebugContext(c.ctx_, "api response", "serviceName", apiName, "rpcName", "travelimpactmodel.flights.computeTypicalFlightEmissions", "response", internallog.HTTPResponse(res, b))
1065 return ret, nil
1066 }