1// Copyright 2021 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 billingbudgets provides access to the Cloud Billing Budget API. 8// 9// For product documentation, see: https://cloud.google.com/billing/docs/how-to/budget-api-overview 10// 11// Creating a client 12// 13// Usage example: 14// 15// import "google.golang.org/api/billingbudgets/v1" 16// ... 17// ctx := context.Background() 18// billingbudgetsService, err := billingbudgets.NewService(ctx) 19// 20// In this example, Google Application Default Credentials are used for authentication. 21// 22// For information on how to create and obtain Application Default Credentials, see https://developers.google.com/identity/protocols/application-default-credentials. 23// 24// Other authentication options 25// 26// By default, all available scopes (see "Constants") are used to authenticate. To restrict scopes, use option.WithScopes: 27// 28// billingbudgetsService, err := billingbudgets.NewService(ctx, option.WithScopes(billingbudgets.CloudPlatformScope)) 29// 30// To use an API key for authentication (note: some APIs do not support API keys), use option.WithAPIKey: 31// 32// billingbudgetsService, err := billingbudgets.NewService(ctx, option.WithAPIKey("AIza...")) 33// 34// To use an OAuth token (e.g., a user token obtained via a three-legged OAuth flow), use option.WithTokenSource: 35// 36// config := &oauth2.Config{...} 37// // ... 38// token, err := config.Exchange(ctx, ...) 39// billingbudgetsService, err := billingbudgets.NewService(ctx, option.WithTokenSource(config.TokenSource(ctx, token))) 40// 41// See https://godoc.org/google.golang.org/api/option/ for details on options. 42package billingbudgets // import "google.golang.org/api/billingbudgets/v1" 43 44import ( 45 "bytes" 46 "context" 47 "encoding/json" 48 "errors" 49 "fmt" 50 "io" 51 "net/http" 52 "net/url" 53 "strconv" 54 "strings" 55 56 googleapi "google.golang.org/api/googleapi" 57 gensupport "google.golang.org/api/internal/gensupport" 58 option "google.golang.org/api/option" 59 internaloption "google.golang.org/api/option/internaloption" 60 htransport "google.golang.org/api/transport/http" 61) 62 63// Always reference these packages, just in case the auto-generated code 64// below doesn't. 65var _ = bytes.NewBuffer 66var _ = strconv.Itoa 67var _ = fmt.Sprintf 68var _ = json.NewDecoder 69var _ = io.Copy 70var _ = url.Parse 71var _ = gensupport.MarshalJSON 72var _ = googleapi.Version 73var _ = errors.New 74var _ = strings.Replace 75var _ = context.Canceled 76var _ = internaloption.WithDefaultEndpoint 77 78const apiId = "billingbudgets:v1" 79const apiName = "billingbudgets" 80const apiVersion = "v1" 81const basePath = "https://billingbudgets.googleapis.com/" 82const mtlsBasePath = "https://billingbudgets.mtls.googleapis.com/" 83 84// OAuth2 scopes used by this API. 85const ( 86 // View and manage your Google Cloud Platform billing accounts 87 CloudBillingScope = "https://www.googleapis.com/auth/cloud-billing" 88 89 // See, edit, configure, and delete your Google Cloud Platform data 90 CloudPlatformScope = "https://www.googleapis.com/auth/cloud-platform" 91) 92 93// NewService creates a new Service. 94func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, error) { 95 scopesOption := option.WithScopes( 96 "https://www.googleapis.com/auth/cloud-billing", 97 "https://www.googleapis.com/auth/cloud-platform", 98 ) 99 // NOTE: prepend, so we don't override user-specified scopes. 100 opts = append([]option.ClientOption{scopesOption}, opts...) 101 opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) 102 opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) 103 client, endpoint, err := htransport.NewClient(ctx, opts...) 104 if err != nil { 105 return nil, err 106 } 107 s, err := New(client) 108 if err != nil { 109 return nil, err 110 } 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. 122func New(client *http.Client) (*Service, error) { 123 if client == nil { 124 return nil, errors.New("client is nil") 125 } 126 s := &Service{client: client, BasePath: basePath} 127 s.BillingAccounts = NewBillingAccountsService(s) 128 return s, nil 129} 130 131type Service struct { 132 client *http.Client 133 BasePath string // API endpoint base URL 134 UserAgent string // optional additional User-Agent fragment 135 136 BillingAccounts *BillingAccountsService 137} 138 139func (s *Service) userAgent() string { 140 if s.UserAgent == "" { 141 return googleapi.UserAgent 142 } 143 return googleapi.UserAgent + " " + s.UserAgent 144} 145 146func NewBillingAccountsService(s *Service) *BillingAccountsService { 147 rs := &BillingAccountsService{s: s} 148 rs.Budgets = NewBillingAccountsBudgetsService(s) 149 return rs 150} 151 152type BillingAccountsService struct { 153 s *Service 154 155 Budgets *BillingAccountsBudgetsService 156} 157 158func NewBillingAccountsBudgetsService(s *Service) *BillingAccountsBudgetsService { 159 rs := &BillingAccountsBudgetsService{s: s} 160 return rs 161} 162 163type BillingAccountsBudgetsService struct { 164 s *Service 165} 166 167// GoogleCloudBillingBudgetsV1Budget: A budget is a plan that describes 168// what you expect to spend on Cloud projects, plus the rules to execute 169// as spend is tracked against that plan, (for example, send an alert 170// when 90% of the target spend is met). The budget time period is 171// configurable, with options such as month (default), quarter, year, or 172// custom time period. 173type GoogleCloudBillingBudgetsV1Budget struct { 174 // Amount: Required. Budgeted amount. 175 Amount *GoogleCloudBillingBudgetsV1BudgetAmount `json:"amount,omitempty"` 176 177 // BudgetFilter: Optional. Filters that define which resources are used 178 // to compute the actual spend against the budget amount, such as 179 // projects, services, and the budget's time period, as well as other 180 // filters. 181 BudgetFilter *GoogleCloudBillingBudgetsV1Filter `json:"budgetFilter,omitempty"` 182 183 // DisplayName: User data for display name in UI. The name must be less 184 // than or equal to 60 characters. 185 DisplayName string `json:"displayName,omitempty"` 186 187 // Etag: Optional. Etag to validate that the object is unchanged for a 188 // read-modify-write operation. An empty etag will cause an update to 189 // overwrite other changes. 190 Etag string `json:"etag,omitempty"` 191 192 // Name: Output only. Resource name of the budget. The resource name 193 // implies the scope of a budget. Values are of the form 194 // `billingAccounts/{billingAccountId}/budgets/{budgetId}`. 195 Name string `json:"name,omitempty"` 196 197 // NotificationsRule: Optional. Rules to apply to notifications sent 198 // based on budget spend and thresholds. 199 NotificationsRule *GoogleCloudBillingBudgetsV1NotificationsRule `json:"notificationsRule,omitempty"` 200 201 // ThresholdRules: Optional. Rules that trigger alerts (notifications of 202 // thresholds being crossed) when spend exceeds the specified 203 // percentages of the budget. 204 ThresholdRules []*GoogleCloudBillingBudgetsV1ThresholdRule `json:"thresholdRules,omitempty"` 205 206 // ServerResponse contains the HTTP response code and headers from the 207 // server. 208 googleapi.ServerResponse `json:"-"` 209 210 // ForceSendFields is a list of field names (e.g. "Amount") to 211 // unconditionally include in API requests. By default, fields with 212 // empty values are omitted from API requests. However, any non-pointer, 213 // non-interface field appearing in ForceSendFields will be sent to the 214 // server regardless of whether the field is empty or not. This may be 215 // used to include empty fields in Patch requests. 216 ForceSendFields []string `json:"-"` 217 218 // NullFields is a list of field names (e.g. "Amount") to include in API 219 // requests with the JSON null value. By default, fields with empty 220 // values are omitted from API requests. However, any field with an 221 // empty value appearing in NullFields will be sent to the server as 222 // null. It is an error if a field in this list has a non-empty value. 223 // This may be used to include null fields in Patch requests. 224 NullFields []string `json:"-"` 225} 226 227func (s *GoogleCloudBillingBudgetsV1Budget) MarshalJSON() ([]byte, error) { 228 type NoMethod GoogleCloudBillingBudgetsV1Budget 229 raw := NoMethod(*s) 230 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 231} 232 233// GoogleCloudBillingBudgetsV1BudgetAmount: The budgeted amount for each 234// usage period. 235type GoogleCloudBillingBudgetsV1BudgetAmount struct { 236 // LastPeriodAmount: Use the last period's actual spend as the budget 237 // for the present period. LastPeriodAmount can only be set when the 238 // budget's time period is a Filter.calendar_period. It cannot be set in 239 // combination with Filter.custom_period. 240 LastPeriodAmount *GoogleCloudBillingBudgetsV1LastPeriodAmount `json:"lastPeriodAmount,omitempty"` 241 242 // SpecifiedAmount: A specified amount to use as the budget. 243 // `currency_code` is optional. If specified when creating a budget, it 244 // must match the currency of the billing account. If specified when 245 // updating a budget, it must match the currency_code of the existing 246 // budget. The `currency_code` is provided on output. 247 SpecifiedAmount *GoogleTypeMoney `json:"specifiedAmount,omitempty"` 248 249 // ForceSendFields is a list of field names (e.g. "LastPeriodAmount") 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 // NullFields is a list of field names (e.g. "LastPeriodAmount") to 258 // include in API requests with the JSON null value. By default, fields 259 // with empty values are omitted from API requests. However, any field 260 // with an empty value appearing in NullFields will be sent to the 261 // server as null. It is an error if a field in this list has a 262 // non-empty value. This may be used to include null fields in Patch 263 // requests. 264 NullFields []string `json:"-"` 265} 266 267func (s *GoogleCloudBillingBudgetsV1BudgetAmount) MarshalJSON() ([]byte, error) { 268 type NoMethod GoogleCloudBillingBudgetsV1BudgetAmount 269 raw := NoMethod(*s) 270 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 271} 272 273// GoogleCloudBillingBudgetsV1CustomPeriod: All date times begin at 12 274// AM US and Canadian Pacific Time (UTC-8). 275type GoogleCloudBillingBudgetsV1CustomPeriod struct { 276 // EndDate: Optional. The end date of the time period. Budgets with 277 // elapsed end date won't be processed. If unset, specifies to track all 278 // usage incurred since the start_date. 279 EndDate *GoogleTypeDate `json:"endDate,omitempty"` 280 281 // StartDate: Required. The start date must be after January 1, 2017. 282 StartDate *GoogleTypeDate `json:"startDate,omitempty"` 283 284 // ForceSendFields is a list of field names (e.g. "EndDate") to 285 // unconditionally include in API requests. By default, fields with 286 // empty values are omitted from API requests. However, any non-pointer, 287 // non-interface field appearing in ForceSendFields will be sent to the 288 // server regardless of whether the field is empty or not. This may be 289 // used to include empty fields in Patch requests. 290 ForceSendFields []string `json:"-"` 291 292 // NullFields is a list of field names (e.g. "EndDate") to include in 293 // API requests with the JSON null value. By default, fields with empty 294 // values are omitted from API requests. However, any field with an 295 // empty value appearing in NullFields will be sent to the server as 296 // null. It is an error if a field in this list has a non-empty value. 297 // This may be used to include null fields in Patch requests. 298 NullFields []string `json:"-"` 299} 300 301func (s *GoogleCloudBillingBudgetsV1CustomPeriod) MarshalJSON() ([]byte, error) { 302 type NoMethod GoogleCloudBillingBudgetsV1CustomPeriod 303 raw := NoMethod(*s) 304 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 305} 306 307// GoogleCloudBillingBudgetsV1Filter: A filter for a budget, limiting 308// the scope of the cost to calculate. 309type GoogleCloudBillingBudgetsV1Filter struct { 310 // CalendarPeriod: Optional. Specifies to track usage for recurring 311 // calendar period. E.g. Assume that CalendarPeriod.QUARTER is set. The 312 // budget will track usage from April 1 to June 30, when current 313 // calendar month is April, May, June. After that, it will track usage 314 // from July 1 to September 30 when current calendar month is July, 315 // August, September, and so on. 316 // 317 // Possible values: 318 // "CALENDAR_PERIOD_UNSPECIFIED" 319 // "MONTH" - A month. Month starts on the first day of each month, 320 // such as January 1, February 1, March 1, and so on. 321 // "QUARTER" - A quarter. Quarters start on dates January 1, April 1, 322 // July 1, and October 1 of each year. 323 // "YEAR" - A year. Year starts on January 1. 324 CalendarPeriod string `json:"calendarPeriod,omitempty"` 325 326 // CreditTypes: Optional. If Filter.credit_types_treatment is 327 // INCLUDE_SPECIFIED_CREDITS, this is a list of credit types to be 328 // subtracted from gross cost to determine the spend for threshold 329 // calculations. If Filter.credit_types_treatment is **not** 330 // INCLUDE_SPECIFIED_CREDITS, this field must be empty. See a list of 331 // acceptable credit type values 332 // (https://cloud.google.com/billing/docs/how-to/export-data-bigquery-tables#credits-type). 333 CreditTypes []string `json:"creditTypes,omitempty"` 334 335 // CreditTypesTreatment: Optional. If not set, default behavior is 336 // `INCLUDE_ALL_CREDITS`. 337 // 338 // Possible values: 339 // "CREDIT_TYPES_TREATMENT_UNSPECIFIED" 340 // "INCLUDE_ALL_CREDITS" - All types of credit are subtracted from the 341 // gross cost to determine the spend for threshold calculations. 342 // "EXCLUDE_ALL_CREDITS" - All types of credit are added to the net 343 // cost to determine the spend for threshold calculations. 344 // "INCLUDE_SPECIFIED_CREDITS" - Credit types specified in the 345 // credit_types field are subtracted from the gross cost to determine 346 // the spend for threshold calculations. 347 CreditTypesTreatment string `json:"creditTypesTreatment,omitempty"` 348 349 // CustomPeriod: Optional. Specifies to track usage from any start date 350 // (required) to any end date (optional). 351 CustomPeriod *GoogleCloudBillingBudgetsV1CustomPeriod `json:"customPeriod,omitempty"` 352 353 // Labels: Optional. A single label and value pair specifying that usage 354 // from only this set of labeled resources should be included in the 355 // budget. Currently, multiple entries or multiple values per entry are 356 // not allowed. If omitted, the report will include all labeled and 357 // unlabeled usage. 358 Labels map[string][]interface{} `json:"labels,omitempty"` 359 360 // Projects: Optional. A set of projects of the form 361 // `projects/{project}`, specifying that usage from only this set of 362 // projects should be included in the budget. If omitted, the report 363 // will include all usage for the billing account, regardless of which 364 // project the usage occurred on. Only zero or one project can be 365 // specified currently. 366 Projects []string `json:"projects,omitempty"` 367 368 // Services: Optional. A set of services of the form 369 // `services/{service_id}`, specifying that usage from only this set of 370 // services should be included in the budget. If omitted, the report 371 // will include usage for all the services. The service names are 372 // available through the Catalog API: 373 // https://cloud.google.com/billing/v1/how-tos/catalog-api. 374 Services []string `json:"services,omitempty"` 375 376 // Subaccounts: Optional. A set of subaccounts of the form 377 // `billingAccounts/{account_id}`, specifying that usage from only this 378 // set of subaccounts should be included in the budget. If a subaccount 379 // is set to the name of the parent account, usage from the parent 380 // account will be included. If the field is omitted, the report will 381 // include usage from the parent account and all subaccounts, if they 382 // exist. 383 Subaccounts []string `json:"subaccounts,omitempty"` 384 385 // ForceSendFields is a list of field names (e.g. "CalendarPeriod") to 386 // unconditionally include in API requests. By default, fields with 387 // empty values are omitted from API requests. However, any non-pointer, 388 // non-interface field appearing in ForceSendFields will be sent to the 389 // server regardless of whether the field is empty or not. This may be 390 // used to include empty fields in Patch requests. 391 ForceSendFields []string `json:"-"` 392 393 // NullFields is a list of field names (e.g. "CalendarPeriod") to 394 // include in API requests with the JSON null value. By default, fields 395 // with empty values are omitted from API requests. However, any field 396 // with an empty value appearing in NullFields will be sent to the 397 // server as null. It is an error if a field in this list has a 398 // non-empty value. This may be used to include null fields in Patch 399 // requests. 400 NullFields []string `json:"-"` 401} 402 403func (s *GoogleCloudBillingBudgetsV1Filter) MarshalJSON() ([]byte, error) { 404 type NoMethod GoogleCloudBillingBudgetsV1Filter 405 raw := NoMethod(*s) 406 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 407} 408 409// GoogleCloudBillingBudgetsV1LastPeriodAmount: Describes a budget 410// amount targeted to the last Filter.calendar_period spend. At this 411// time, the amount is automatically 100% of the last calendar period's 412// spend; that is, there are no other options yet. Future configuration 413// options will be described here (for example, configuring a percentage 414// of last period's spend). LastPeriodAmount cannot be set for a budget 415// configured with a Filter.custom_period. 416type GoogleCloudBillingBudgetsV1LastPeriodAmount struct { 417} 418 419// GoogleCloudBillingBudgetsV1ListBudgetsResponse: Response for 420// ListBudgets 421type GoogleCloudBillingBudgetsV1ListBudgetsResponse struct { 422 // Budgets: List of the budgets owned by the requested billing account. 423 Budgets []*GoogleCloudBillingBudgetsV1Budget `json:"budgets,omitempty"` 424 425 // NextPageToken: If not empty, indicates that there may be more budgets 426 // that match the request; this value should be passed in a new 427 // `ListBudgetsRequest`. 428 NextPageToken string `json:"nextPageToken,omitempty"` 429 430 // ServerResponse contains the HTTP response code and headers from the 431 // server. 432 googleapi.ServerResponse `json:"-"` 433 434 // ForceSendFields is a list of field names (e.g. "Budgets") to 435 // unconditionally include in API requests. By default, fields with 436 // empty values are omitted from API requests. However, any non-pointer, 437 // non-interface field appearing in ForceSendFields will be sent to the 438 // server regardless of whether the field is empty or not. This may be 439 // used to include empty fields in Patch requests. 440 ForceSendFields []string `json:"-"` 441 442 // NullFields is a list of field names (e.g. "Budgets") to include in 443 // API requests with the JSON null value. By default, fields with empty 444 // values are omitted from API requests. However, any field with an 445 // empty value appearing in NullFields will be sent to the server as 446 // null. It is an error if a field in this list has a non-empty value. 447 // This may be used to include null fields in Patch requests. 448 NullFields []string `json:"-"` 449} 450 451func (s *GoogleCloudBillingBudgetsV1ListBudgetsResponse) MarshalJSON() ([]byte, error) { 452 type NoMethod GoogleCloudBillingBudgetsV1ListBudgetsResponse 453 raw := NoMethod(*s) 454 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 455} 456 457// GoogleCloudBillingBudgetsV1NotificationsRule: NotificationsRule 458// defines notifications that are sent based on budget spend and 459// thresholds. 460type GoogleCloudBillingBudgetsV1NotificationsRule struct { 461 // DisableDefaultIamRecipients: Optional. When set to true, disables 462 // default notifications sent when a threshold is exceeded. Default 463 // notifications are sent to those with Billing Account Administrator 464 // and Billing Account User IAM roles for the target account. 465 DisableDefaultIamRecipients bool `json:"disableDefaultIamRecipients,omitempty"` 466 467 // MonitoringNotificationChannels: Optional. Targets to send 468 // notifications to when a threshold is exceeded. This is in addition to 469 // default recipients who have billing account IAM roles. The value is 470 // the full REST resource name of a monitoring notification channel with 471 // the form `projects/{project_id}/notificationChannels/{channel_id}`. A 472 // maximum of 5 channels are allowed. See 473 // https://cloud.google.com/billing/docs/how-to/budgets-notification-recipients 474 // for more details. 475 MonitoringNotificationChannels []string `json:"monitoringNotificationChannels,omitempty"` 476 477 // PubsubTopic: Optional. The name of the Pub/Sub topic where budget 478 // related messages will be published, in the form 479 // `projects/{project_id}/topics/{topic_id}`. Updates are sent at 480 // regular intervals to the topic. The topic needs to be created before 481 // the budget is created; see 482 // https://cloud.google.com/billing/docs/how-to/budgets#manage-notifications 483 // for more details. Caller is expected to have 484 // `pubsub.topics.setIamPolicy` permission on the topic when it's set 485 // for a budget, otherwise, the API call will fail with 486 // PERMISSION_DENIED. See 487 // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications 488 // for more details on Pub/Sub roles and permissions. 489 PubsubTopic string `json:"pubsubTopic,omitempty"` 490 491 // SchemaVersion: Optional. Required when NotificationsRule.pubsub_topic 492 // is set. The schema version of the notification sent to 493 // NotificationsRule.pubsub_topic. Only "1.0" is accepted. It represents 494 // the JSON schema as defined in 495 // https://cloud.google.com/billing/docs/how-to/budgets-programmatic-notifications#notification_format. 496 SchemaVersion string `json:"schemaVersion,omitempty"` 497 498 // ForceSendFields is a list of field names (e.g. 499 // "DisableDefaultIamRecipients") to unconditionally include in API 500 // requests. By default, fields with empty values are omitted from API 501 // requests. However, any non-pointer, non-interface field appearing in 502 // ForceSendFields will be sent to the server regardless of whether the 503 // field is empty or not. This may be used to include empty fields in 504 // Patch requests. 505 ForceSendFields []string `json:"-"` 506 507 // NullFields is a list of field names (e.g. 508 // "DisableDefaultIamRecipients") to include in API requests with the 509 // JSON null value. By default, fields with empty values are omitted 510 // from API requests. However, any field with an empty value appearing 511 // in NullFields will be sent to the server as null. It is an error if a 512 // field in this list has a non-empty value. This may be used to include 513 // null fields in Patch requests. 514 NullFields []string `json:"-"` 515} 516 517func (s *GoogleCloudBillingBudgetsV1NotificationsRule) MarshalJSON() ([]byte, error) { 518 type NoMethod GoogleCloudBillingBudgetsV1NotificationsRule 519 raw := NoMethod(*s) 520 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 521} 522 523// GoogleCloudBillingBudgetsV1ThresholdRule: ThresholdRule contains a 524// definition of a threshold which triggers an alert (a notification of 525// a threshold being crossed) to be sent when spend goes above the 526// specified amount. Alerts are automatically e-mailed to users with the 527// Billing Account Administrator role or the Billing Account User role. 528// The thresholds here have no effect on notifications sent to anything 529// configured under `Budget.all_updates_rule`. 530type GoogleCloudBillingBudgetsV1ThresholdRule struct { 531 // SpendBasis: Optional. The type of basis used to determine if spend 532 // has passed the threshold. Behavior defaults to CURRENT_SPEND if not 533 // set. 534 // 535 // Possible values: 536 // "BASIS_UNSPECIFIED" - Unspecified threshold basis. 537 // "CURRENT_SPEND" - Use current spend as the basis for comparison 538 // against the threshold. 539 // "FORECASTED_SPEND" - Use forecasted spend for the period as the 540 // basis for comparison against the threshold. FORECASTED_SPEND can only 541 // be set when the budget's time period is a Filter.calendar_period. It 542 // cannot be set in combination with Filter.custom_period. 543 SpendBasis string `json:"spendBasis,omitempty"` 544 545 // ThresholdPercent: Required. Send an alert when this threshold is 546 // exceeded. This is a 1.0-based percentage, so 0.5 = 50%. Validation: 547 // non-negative number. 548 ThresholdPercent float64 `json:"thresholdPercent,omitempty"` 549 550 // ForceSendFields is a list of field names (e.g. "SpendBasis") to 551 // unconditionally include in API requests. By default, fields with 552 // empty values are omitted from API requests. However, any non-pointer, 553 // non-interface field appearing in ForceSendFields will be sent to the 554 // server regardless of whether the field is empty or not. This may be 555 // used to include empty fields in Patch requests. 556 ForceSendFields []string `json:"-"` 557 558 // NullFields is a list of field names (e.g. "SpendBasis") to include in 559 // API requests with the JSON null value. By default, fields with empty 560 // values are omitted from API requests. However, any field with an 561 // empty value appearing in NullFields will be sent to the server as 562 // null. It is an error if a field in this list has a non-empty value. 563 // This may be used to include null fields in Patch requests. 564 NullFields []string `json:"-"` 565} 566 567func (s *GoogleCloudBillingBudgetsV1ThresholdRule) MarshalJSON() ([]byte, error) { 568 type NoMethod GoogleCloudBillingBudgetsV1ThresholdRule 569 raw := NoMethod(*s) 570 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 571} 572 573func (s *GoogleCloudBillingBudgetsV1ThresholdRule) UnmarshalJSON(data []byte) error { 574 type NoMethod GoogleCloudBillingBudgetsV1ThresholdRule 575 var s1 struct { 576 ThresholdPercent gensupport.JSONFloat64 `json:"thresholdPercent"` 577 *NoMethod 578 } 579 s1.NoMethod = (*NoMethod)(s) 580 if err := json.Unmarshal(data, &s1); err != nil { 581 return err 582 } 583 s.ThresholdPercent = float64(s1.ThresholdPercent) 584 return nil 585} 586 587// GoogleProtobufEmpty: A generic empty message that you can re-use to 588// avoid defining duplicated empty messages in your APIs. A typical 589// example is to use it as the request or the response type of an API 590// method. For instance: service Foo { rpc Bar(google.protobuf.Empty) 591// returns (google.protobuf.Empty); } The JSON representation for 592// `Empty` is empty JSON object `{}`. 593type GoogleProtobufEmpty struct { 594 // ServerResponse contains the HTTP response code and headers from the 595 // server. 596 googleapi.ServerResponse `json:"-"` 597} 598 599// GoogleTypeDate: Represents a whole or partial calendar date, such as 600// a birthday. The time of day and time zone are either specified 601// elsewhere or are insignificant. The date is relative to the Gregorian 602// Calendar. This can represent one of the following: * A full date, 603// with non-zero year, month, and day values * A month and day value, 604// with a zero year, such as an anniversary * A year on its own, with 605// zero month and day values * A year and month value, with a zero day, 606// such as a credit card expiration date Related types are 607// google.type.TimeOfDay and `google.protobuf.Timestamp`. 608type GoogleTypeDate struct { 609 // Day: Day of a month. Must be from 1 to 31 and valid for the year and 610 // month, or 0 to specify a year by itself or a year and month where the 611 // day isn't significant. 612 Day int64 `json:"day,omitempty"` 613 614 // Month: Month of a year. Must be from 1 to 12, or 0 to specify a year 615 // without a month and day. 616 Month int64 `json:"month,omitempty"` 617 618 // Year: Year of the date. Must be from 1 to 9999, or 0 to specify a 619 // date without a year. 620 Year int64 `json:"year,omitempty"` 621 622 // ForceSendFields is a list of field names (e.g. "Day") to 623 // unconditionally include in API requests. By default, fields with 624 // empty values are omitted from API requests. However, any non-pointer, 625 // non-interface field appearing in ForceSendFields will be sent to the 626 // server regardless of whether the field is empty or not. This may be 627 // used to include empty fields in Patch requests. 628 ForceSendFields []string `json:"-"` 629 630 // NullFields is a list of field names (e.g. "Day") to include in API 631 // requests with the JSON null value. By default, fields with empty 632 // values are omitted from API requests. However, any field with an 633 // empty value appearing in NullFields will be sent to the server as 634 // null. It is an error if a field in this list has a non-empty value. 635 // This may be used to include null fields in Patch requests. 636 NullFields []string `json:"-"` 637} 638 639func (s *GoogleTypeDate) MarshalJSON() ([]byte, error) { 640 type NoMethod GoogleTypeDate 641 raw := NoMethod(*s) 642 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 643} 644 645// GoogleTypeMoney: Represents an amount of money with its currency 646// type. 647type GoogleTypeMoney struct { 648 // CurrencyCode: The three-letter currency code defined in ISO 4217. 649 CurrencyCode string `json:"currencyCode,omitempty"` 650 651 // Nanos: Number of nano (10^-9) units of the amount. The value must be 652 // between -999,999,999 and +999,999,999 inclusive. If `units` is 653 // positive, `nanos` must be positive or zero. If `units` is zero, 654 // `nanos` can be positive, zero, or negative. If `units` is negative, 655 // `nanos` must be negative or zero. For example $-1.75 is represented 656 // as `units`=-1 and `nanos`=-750,000,000. 657 Nanos int64 `json:"nanos,omitempty"` 658 659 // Units: The whole units of the amount. For example if `currencyCode` 660 // is "USD", then 1 unit is one US dollar. 661 Units int64 `json:"units,omitempty,string"` 662 663 // ForceSendFields is a list of field names (e.g. "CurrencyCode") to 664 // unconditionally include in API requests. By default, fields with 665 // empty values are omitted from API requests. However, any non-pointer, 666 // non-interface field appearing in ForceSendFields will be sent to the 667 // server regardless of whether the field is empty or not. This may be 668 // used to include empty fields in Patch requests. 669 ForceSendFields []string `json:"-"` 670 671 // NullFields is a list of field names (e.g. "CurrencyCode") to include 672 // in API requests with the JSON null value. By default, fields with 673 // empty values are omitted from API requests. However, any field with 674 // an empty value appearing in NullFields will be sent to the server as 675 // null. It is an error if a field in this list has a non-empty value. 676 // This may be used to include null fields in Patch requests. 677 NullFields []string `json:"-"` 678} 679 680func (s *GoogleTypeMoney) MarshalJSON() ([]byte, error) { 681 type NoMethod GoogleTypeMoney 682 raw := NoMethod(*s) 683 return gensupport.MarshalJSON(raw, s.ForceSendFields, s.NullFields) 684} 685 686// method id "billingbudgets.billingAccounts.budgets.create": 687 688type BillingAccountsBudgetsCreateCall struct { 689 s *Service 690 parent string 691 googlecloudbillingbudgetsv1budget *GoogleCloudBillingBudgetsV1Budget 692 urlParams_ gensupport.URLParams 693 ctx_ context.Context 694 header_ http.Header 695} 696 697// Create: Creates a new budget. See Quotas and limits 698// (https://cloud.google.com/billing/quotas) for more information on the 699// limits of the number of budgets you can create. 700// 701// - parent: The name of the billing account to create the budget in. 702// Values are of the form `billingAccounts/{billingAccountId}`. 703func (r *BillingAccountsBudgetsService) Create(parent string, googlecloudbillingbudgetsv1budget *GoogleCloudBillingBudgetsV1Budget) *BillingAccountsBudgetsCreateCall { 704 c := &BillingAccountsBudgetsCreateCall{s: r.s, urlParams_: make(gensupport.URLParams)} 705 c.parent = parent 706 c.googlecloudbillingbudgetsv1budget = googlecloudbillingbudgetsv1budget 707 return c 708} 709 710// Fields allows partial responses to be retrieved. See 711// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 712// for more information. 713func (c *BillingAccountsBudgetsCreateCall) Fields(s ...googleapi.Field) *BillingAccountsBudgetsCreateCall { 714 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 715 return c 716} 717 718// Context sets the context to be used in this call's Do method. Any 719// pending HTTP request will be aborted if the provided context is 720// canceled. 721func (c *BillingAccountsBudgetsCreateCall) Context(ctx context.Context) *BillingAccountsBudgetsCreateCall { 722 c.ctx_ = ctx 723 return c 724} 725 726// Header returns an http.Header that can be modified by the caller to 727// add HTTP headers to the request. 728func (c *BillingAccountsBudgetsCreateCall) Header() http.Header { 729 if c.header_ == nil { 730 c.header_ = make(http.Header) 731 } 732 return c.header_ 733} 734 735func (c *BillingAccountsBudgetsCreateCall) doRequest(alt string) (*http.Response, error) { 736 reqHeaders := make(http.Header) 737 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210410") 738 for k, v := range c.header_ { 739 reqHeaders[k] = v 740 } 741 reqHeaders.Set("User-Agent", c.s.userAgent()) 742 var body io.Reader = nil 743 body, err := googleapi.WithoutDataWrapper.JSONReader(c.googlecloudbillingbudgetsv1budget) 744 if err != nil { 745 return nil, err 746 } 747 reqHeaders.Set("Content-Type", "application/json") 748 c.urlParams_.Set("alt", alt) 749 c.urlParams_.Set("prettyPrint", "false") 750 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/budgets") 751 urls += "?" + c.urlParams_.Encode() 752 req, err := http.NewRequest("POST", urls, body) 753 if err != nil { 754 return nil, err 755 } 756 req.Header = reqHeaders 757 googleapi.Expand(req.URL, map[string]string{ 758 "parent": c.parent, 759 }) 760 return gensupport.SendRequest(c.ctx_, c.s.client, req) 761} 762 763// Do executes the "billingbudgets.billingAccounts.budgets.create" call. 764// Exactly one of *GoogleCloudBillingBudgetsV1Budget or error will be 765// non-nil. Any non-2xx status code is an error. Response headers are in 766// either *GoogleCloudBillingBudgetsV1Budget.ServerResponse.Header or 767// (if a response was returned at all) in 768// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 769// whether the returned error was because http.StatusNotModified was 770// returned. 771func (c *BillingAccountsBudgetsCreateCall) Do(opts ...googleapi.CallOption) (*GoogleCloudBillingBudgetsV1Budget, error) { 772 gensupport.SetOptions(c.urlParams_, opts...) 773 res, err := c.doRequest("json") 774 if res != nil && res.StatusCode == http.StatusNotModified { 775 if res.Body != nil { 776 res.Body.Close() 777 } 778 return nil, &googleapi.Error{ 779 Code: res.StatusCode, 780 Header: res.Header, 781 } 782 } 783 if err != nil { 784 return nil, err 785 } 786 defer googleapi.CloseBody(res) 787 if err := googleapi.CheckResponse(res); err != nil { 788 return nil, err 789 } 790 ret := &GoogleCloudBillingBudgetsV1Budget{ 791 ServerResponse: googleapi.ServerResponse{ 792 Header: res.Header, 793 HTTPStatusCode: res.StatusCode, 794 }, 795 } 796 target := &ret 797 if err := gensupport.DecodeResponse(target, res); err != nil { 798 return nil, err 799 } 800 return ret, nil 801 // { 802 // "description": "Creates a new budget. See [Quotas and limits](https://cloud.google.com/billing/quotas) for more information on the limits of the number of budgets you can create.", 803 // "flatPath": "v1/billingAccounts/{billingAccountsId}/budgets", 804 // "httpMethod": "POST", 805 // "id": "billingbudgets.billingAccounts.budgets.create", 806 // "parameterOrder": [ 807 // "parent" 808 // ], 809 // "parameters": { 810 // "parent": { 811 // "description": "Required. The name of the billing account to create the budget in. Values are of the form `billingAccounts/{billingAccountId}`.", 812 // "location": "path", 813 // "pattern": "^billingAccounts/[^/]+$", 814 // "required": true, 815 // "type": "string" 816 // } 817 // }, 818 // "path": "v1/{+parent}/budgets", 819 // "request": { 820 // "$ref": "GoogleCloudBillingBudgetsV1Budget" 821 // }, 822 // "response": { 823 // "$ref": "GoogleCloudBillingBudgetsV1Budget" 824 // }, 825 // "scopes": [ 826 // "https://www.googleapis.com/auth/cloud-billing", 827 // "https://www.googleapis.com/auth/cloud-platform" 828 // ] 829 // } 830 831} 832 833// method id "billingbudgets.billingAccounts.budgets.delete": 834 835type BillingAccountsBudgetsDeleteCall struct { 836 s *Service 837 name string 838 urlParams_ gensupport.URLParams 839 ctx_ context.Context 840 header_ http.Header 841} 842 843// Delete: Deletes a budget. Returns successfully if already deleted. 844// 845// - name: Name of the budget to delete. Values are of the form 846// `billingAccounts/{billingAccountId}/budgets/{budgetId}`. 847func (r *BillingAccountsBudgetsService) Delete(name string) *BillingAccountsBudgetsDeleteCall { 848 c := &BillingAccountsBudgetsDeleteCall{s: r.s, urlParams_: make(gensupport.URLParams)} 849 c.name = name 850 return c 851} 852 853// Fields allows partial responses to be retrieved. See 854// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 855// for more information. 856func (c *BillingAccountsBudgetsDeleteCall) Fields(s ...googleapi.Field) *BillingAccountsBudgetsDeleteCall { 857 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 858 return c 859} 860 861// Context sets the context to be used in this call's Do method. Any 862// pending HTTP request will be aborted if the provided context is 863// canceled. 864func (c *BillingAccountsBudgetsDeleteCall) Context(ctx context.Context) *BillingAccountsBudgetsDeleteCall { 865 c.ctx_ = ctx 866 return c 867} 868 869// Header returns an http.Header that can be modified by the caller to 870// add HTTP headers to the request. 871func (c *BillingAccountsBudgetsDeleteCall) Header() http.Header { 872 if c.header_ == nil { 873 c.header_ = make(http.Header) 874 } 875 return c.header_ 876} 877 878func (c *BillingAccountsBudgetsDeleteCall) doRequest(alt string) (*http.Response, error) { 879 reqHeaders := make(http.Header) 880 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210410") 881 for k, v := range c.header_ { 882 reqHeaders[k] = v 883 } 884 reqHeaders.Set("User-Agent", c.s.userAgent()) 885 var body io.Reader = nil 886 c.urlParams_.Set("alt", alt) 887 c.urlParams_.Set("prettyPrint", "false") 888 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 889 urls += "?" + c.urlParams_.Encode() 890 req, err := http.NewRequest("DELETE", urls, body) 891 if err != nil { 892 return nil, err 893 } 894 req.Header = reqHeaders 895 googleapi.Expand(req.URL, map[string]string{ 896 "name": c.name, 897 }) 898 return gensupport.SendRequest(c.ctx_, c.s.client, req) 899} 900 901// Do executes the "billingbudgets.billingAccounts.budgets.delete" call. 902// Exactly one of *GoogleProtobufEmpty or error will be non-nil. Any 903// non-2xx status code is an error. Response headers are in either 904// *GoogleProtobufEmpty.ServerResponse.Header or (if a response was 905// returned at all) in error.(*googleapi.Error).Header. Use 906// googleapi.IsNotModified to check whether the returned error was 907// because http.StatusNotModified was returned. 908func (c *BillingAccountsBudgetsDeleteCall) Do(opts ...googleapi.CallOption) (*GoogleProtobufEmpty, error) { 909 gensupport.SetOptions(c.urlParams_, opts...) 910 res, err := c.doRequest("json") 911 if res != nil && res.StatusCode == http.StatusNotModified { 912 if res.Body != nil { 913 res.Body.Close() 914 } 915 return nil, &googleapi.Error{ 916 Code: res.StatusCode, 917 Header: res.Header, 918 } 919 } 920 if err != nil { 921 return nil, err 922 } 923 defer googleapi.CloseBody(res) 924 if err := googleapi.CheckResponse(res); err != nil { 925 return nil, err 926 } 927 ret := &GoogleProtobufEmpty{ 928 ServerResponse: googleapi.ServerResponse{ 929 Header: res.Header, 930 HTTPStatusCode: res.StatusCode, 931 }, 932 } 933 target := &ret 934 if err := gensupport.DecodeResponse(target, res); err != nil { 935 return nil, err 936 } 937 return ret, nil 938 // { 939 // "description": "Deletes a budget. Returns successfully if already deleted.", 940 // "flatPath": "v1/billingAccounts/{billingAccountsId}/budgets/{budgetsId}", 941 // "httpMethod": "DELETE", 942 // "id": "billingbudgets.billingAccounts.budgets.delete", 943 // "parameterOrder": [ 944 // "name" 945 // ], 946 // "parameters": { 947 // "name": { 948 // "description": "Required. Name of the budget to delete. Values are of the form `billingAccounts/{billingAccountId}/budgets/{budgetId}`.", 949 // "location": "path", 950 // "pattern": "^billingAccounts/[^/]+/budgets/[^/]+$", 951 // "required": true, 952 // "type": "string" 953 // } 954 // }, 955 // "path": "v1/{+name}", 956 // "response": { 957 // "$ref": "GoogleProtobufEmpty" 958 // }, 959 // "scopes": [ 960 // "https://www.googleapis.com/auth/cloud-billing", 961 // "https://www.googleapis.com/auth/cloud-platform" 962 // ] 963 // } 964 965} 966 967// method id "billingbudgets.billingAccounts.budgets.get": 968 969type BillingAccountsBudgetsGetCall struct { 970 s *Service 971 name string 972 urlParams_ gensupport.URLParams 973 ifNoneMatch_ string 974 ctx_ context.Context 975 header_ http.Header 976} 977 978// Get: Returns a budget. WARNING: There are some fields exposed on the 979// Google Cloud Console that aren't available on this API. When reading 980// from the API, you will not see these fields in the return value, 981// though they may have been set in the Cloud Console. 982// 983// - name: Name of budget to get. Values are of the form 984// `billingAccounts/{billingAccountId}/budgets/{budgetId}`. 985func (r *BillingAccountsBudgetsService) Get(name string) *BillingAccountsBudgetsGetCall { 986 c := &BillingAccountsBudgetsGetCall{s: r.s, urlParams_: make(gensupport.URLParams)} 987 c.name = name 988 return c 989} 990 991// Fields allows partial responses to be retrieved. See 992// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 993// for more information. 994func (c *BillingAccountsBudgetsGetCall) Fields(s ...googleapi.Field) *BillingAccountsBudgetsGetCall { 995 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 996 return c 997} 998 999// IfNoneMatch sets the optional parameter which makes the operation 1000// fail if the object's ETag matches the given value. This is useful for 1001// getting updates only after the object has changed since the last 1002// request. Use googleapi.IsNotModified to check whether the response 1003// error from Do is the result of In-None-Match. 1004func (c *BillingAccountsBudgetsGetCall) IfNoneMatch(entityTag string) *BillingAccountsBudgetsGetCall { 1005 c.ifNoneMatch_ = entityTag 1006 return c 1007} 1008 1009// Context sets the context to be used in this call's Do method. Any 1010// pending HTTP request will be aborted if the provided context is 1011// canceled. 1012func (c *BillingAccountsBudgetsGetCall) Context(ctx context.Context) *BillingAccountsBudgetsGetCall { 1013 c.ctx_ = ctx 1014 return c 1015} 1016 1017// Header returns an http.Header that can be modified by the caller to 1018// add HTTP headers to the request. 1019func (c *BillingAccountsBudgetsGetCall) Header() http.Header { 1020 if c.header_ == nil { 1021 c.header_ = make(http.Header) 1022 } 1023 return c.header_ 1024} 1025 1026func (c *BillingAccountsBudgetsGetCall) doRequest(alt string) (*http.Response, error) { 1027 reqHeaders := make(http.Header) 1028 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210410") 1029 for k, v := range c.header_ { 1030 reqHeaders[k] = v 1031 } 1032 reqHeaders.Set("User-Agent", c.s.userAgent()) 1033 if c.ifNoneMatch_ != "" { 1034 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1035 } 1036 var body io.Reader = nil 1037 c.urlParams_.Set("alt", alt) 1038 c.urlParams_.Set("prettyPrint", "false") 1039 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 1040 urls += "?" + c.urlParams_.Encode() 1041 req, err := http.NewRequest("GET", urls, body) 1042 if err != nil { 1043 return nil, err 1044 } 1045 req.Header = reqHeaders 1046 googleapi.Expand(req.URL, map[string]string{ 1047 "name": c.name, 1048 }) 1049 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1050} 1051 1052// Do executes the "billingbudgets.billingAccounts.budgets.get" call. 1053// Exactly one of *GoogleCloudBillingBudgetsV1Budget or error will be 1054// non-nil. Any non-2xx status code is an error. Response headers are in 1055// either *GoogleCloudBillingBudgetsV1Budget.ServerResponse.Header or 1056// (if a response was returned at all) in 1057// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1058// whether the returned error was because http.StatusNotModified was 1059// returned. 1060func (c *BillingAccountsBudgetsGetCall) Do(opts ...googleapi.CallOption) (*GoogleCloudBillingBudgetsV1Budget, error) { 1061 gensupport.SetOptions(c.urlParams_, opts...) 1062 res, err := c.doRequest("json") 1063 if res != nil && res.StatusCode == http.StatusNotModified { 1064 if res.Body != nil { 1065 res.Body.Close() 1066 } 1067 return nil, &googleapi.Error{ 1068 Code: res.StatusCode, 1069 Header: res.Header, 1070 } 1071 } 1072 if err != nil { 1073 return nil, err 1074 } 1075 defer googleapi.CloseBody(res) 1076 if err := googleapi.CheckResponse(res); err != nil { 1077 return nil, err 1078 } 1079 ret := &GoogleCloudBillingBudgetsV1Budget{ 1080 ServerResponse: googleapi.ServerResponse{ 1081 Header: res.Header, 1082 HTTPStatusCode: res.StatusCode, 1083 }, 1084 } 1085 target := &ret 1086 if err := gensupport.DecodeResponse(target, res); err != nil { 1087 return nil, err 1088 } 1089 return ret, nil 1090 // { 1091 // "description": "Returns a budget. WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.", 1092 // "flatPath": "v1/billingAccounts/{billingAccountsId}/budgets/{budgetsId}", 1093 // "httpMethod": "GET", 1094 // "id": "billingbudgets.billingAccounts.budgets.get", 1095 // "parameterOrder": [ 1096 // "name" 1097 // ], 1098 // "parameters": { 1099 // "name": { 1100 // "description": "Required. Name of budget to get. Values are of the form `billingAccounts/{billingAccountId}/budgets/{budgetId}`.", 1101 // "location": "path", 1102 // "pattern": "^billingAccounts/[^/]+/budgets/[^/]+$", 1103 // "required": true, 1104 // "type": "string" 1105 // } 1106 // }, 1107 // "path": "v1/{+name}", 1108 // "response": { 1109 // "$ref": "GoogleCloudBillingBudgetsV1Budget" 1110 // }, 1111 // "scopes": [ 1112 // "https://www.googleapis.com/auth/cloud-billing", 1113 // "https://www.googleapis.com/auth/cloud-platform" 1114 // ] 1115 // } 1116 1117} 1118 1119// method id "billingbudgets.billingAccounts.budgets.list": 1120 1121type BillingAccountsBudgetsListCall struct { 1122 s *Service 1123 parent string 1124 urlParams_ gensupport.URLParams 1125 ifNoneMatch_ string 1126 ctx_ context.Context 1127 header_ http.Header 1128} 1129 1130// List: Returns a list of budgets for a billing account. WARNING: There 1131// are some fields exposed on the Google Cloud Console that aren't 1132// available on this API. When reading from the API, you will not see 1133// these fields in the return value, though they may have been set in 1134// the Cloud Console. 1135// 1136// - parent: Name of billing account to list budgets under. Values are 1137// of the form `billingAccounts/{billingAccountId}`. 1138func (r *BillingAccountsBudgetsService) List(parent string) *BillingAccountsBudgetsListCall { 1139 c := &BillingAccountsBudgetsListCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1140 c.parent = parent 1141 return c 1142} 1143 1144// PageSize sets the optional parameter "pageSize": The maximum number 1145// of budgets to return per page. The default and maximum value are 100. 1146func (c *BillingAccountsBudgetsListCall) PageSize(pageSize int64) *BillingAccountsBudgetsListCall { 1147 c.urlParams_.Set("pageSize", fmt.Sprint(pageSize)) 1148 return c 1149} 1150 1151// PageToken sets the optional parameter "pageToken": The value returned 1152// by the last `ListBudgetsResponse` which indicates that this is a 1153// continuation of a prior `ListBudgets` call, and that the system 1154// should return the next page of data. 1155func (c *BillingAccountsBudgetsListCall) PageToken(pageToken string) *BillingAccountsBudgetsListCall { 1156 c.urlParams_.Set("pageToken", pageToken) 1157 return c 1158} 1159 1160// Fields allows partial responses to be retrieved. See 1161// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1162// for more information. 1163func (c *BillingAccountsBudgetsListCall) Fields(s ...googleapi.Field) *BillingAccountsBudgetsListCall { 1164 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1165 return c 1166} 1167 1168// IfNoneMatch sets the optional parameter which makes the operation 1169// fail if the object's ETag matches the given value. This is useful for 1170// getting updates only after the object has changed since the last 1171// request. Use googleapi.IsNotModified to check whether the response 1172// error from Do is the result of In-None-Match. 1173func (c *BillingAccountsBudgetsListCall) IfNoneMatch(entityTag string) *BillingAccountsBudgetsListCall { 1174 c.ifNoneMatch_ = entityTag 1175 return c 1176} 1177 1178// Context sets the context to be used in this call's Do method. Any 1179// pending HTTP request will be aborted if the provided context is 1180// canceled. 1181func (c *BillingAccountsBudgetsListCall) Context(ctx context.Context) *BillingAccountsBudgetsListCall { 1182 c.ctx_ = ctx 1183 return c 1184} 1185 1186// Header returns an http.Header that can be modified by the caller to 1187// add HTTP headers to the request. 1188func (c *BillingAccountsBudgetsListCall) Header() http.Header { 1189 if c.header_ == nil { 1190 c.header_ = make(http.Header) 1191 } 1192 return c.header_ 1193} 1194 1195func (c *BillingAccountsBudgetsListCall) doRequest(alt string) (*http.Response, error) { 1196 reqHeaders := make(http.Header) 1197 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210410") 1198 for k, v := range c.header_ { 1199 reqHeaders[k] = v 1200 } 1201 reqHeaders.Set("User-Agent", c.s.userAgent()) 1202 if c.ifNoneMatch_ != "" { 1203 reqHeaders.Set("If-None-Match", c.ifNoneMatch_) 1204 } 1205 var body io.Reader = nil 1206 c.urlParams_.Set("alt", alt) 1207 c.urlParams_.Set("prettyPrint", "false") 1208 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+parent}/budgets") 1209 urls += "?" + c.urlParams_.Encode() 1210 req, err := http.NewRequest("GET", urls, body) 1211 if err != nil { 1212 return nil, err 1213 } 1214 req.Header = reqHeaders 1215 googleapi.Expand(req.URL, map[string]string{ 1216 "parent": c.parent, 1217 }) 1218 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1219} 1220 1221// Do executes the "billingbudgets.billingAccounts.budgets.list" call. 1222// Exactly one of *GoogleCloudBillingBudgetsV1ListBudgetsResponse or 1223// error will be non-nil. Any non-2xx status code is an error. Response 1224// headers are in either 1225// *GoogleCloudBillingBudgetsV1ListBudgetsResponse.ServerResponse.Header 1226// or (if a response was returned at all) in 1227// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1228// whether the returned error was because http.StatusNotModified was 1229// returned. 1230func (c *BillingAccountsBudgetsListCall) Do(opts ...googleapi.CallOption) (*GoogleCloudBillingBudgetsV1ListBudgetsResponse, error) { 1231 gensupport.SetOptions(c.urlParams_, opts...) 1232 res, err := c.doRequest("json") 1233 if res != nil && res.StatusCode == http.StatusNotModified { 1234 if res.Body != nil { 1235 res.Body.Close() 1236 } 1237 return nil, &googleapi.Error{ 1238 Code: res.StatusCode, 1239 Header: res.Header, 1240 } 1241 } 1242 if err != nil { 1243 return nil, err 1244 } 1245 defer googleapi.CloseBody(res) 1246 if err := googleapi.CheckResponse(res); err != nil { 1247 return nil, err 1248 } 1249 ret := &GoogleCloudBillingBudgetsV1ListBudgetsResponse{ 1250 ServerResponse: googleapi.ServerResponse{ 1251 Header: res.Header, 1252 HTTPStatusCode: res.StatusCode, 1253 }, 1254 } 1255 target := &ret 1256 if err := gensupport.DecodeResponse(target, res); err != nil { 1257 return nil, err 1258 } 1259 return ret, nil 1260 // { 1261 // "description": "Returns a list of budgets for a billing account. WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. When reading from the API, you will not see these fields in the return value, though they may have been set in the Cloud Console.", 1262 // "flatPath": "v1/billingAccounts/{billingAccountsId}/budgets", 1263 // "httpMethod": "GET", 1264 // "id": "billingbudgets.billingAccounts.budgets.list", 1265 // "parameterOrder": [ 1266 // "parent" 1267 // ], 1268 // "parameters": { 1269 // "pageSize": { 1270 // "description": "Optional. The maximum number of budgets to return per page. The default and maximum value are 100.", 1271 // "format": "int32", 1272 // "location": "query", 1273 // "type": "integer" 1274 // }, 1275 // "pageToken": { 1276 // "description": "Optional. The value returned by the last `ListBudgetsResponse` which indicates that this is a continuation of a prior `ListBudgets` call, and that the system should return the next page of data.", 1277 // "location": "query", 1278 // "type": "string" 1279 // }, 1280 // "parent": { 1281 // "description": "Required. Name of billing account to list budgets under. Values are of the form `billingAccounts/{billingAccountId}`.", 1282 // "location": "path", 1283 // "pattern": "^billingAccounts/[^/]+$", 1284 // "required": true, 1285 // "type": "string" 1286 // } 1287 // }, 1288 // "path": "v1/{+parent}/budgets", 1289 // "response": { 1290 // "$ref": "GoogleCloudBillingBudgetsV1ListBudgetsResponse" 1291 // }, 1292 // "scopes": [ 1293 // "https://www.googleapis.com/auth/cloud-billing", 1294 // "https://www.googleapis.com/auth/cloud-platform" 1295 // ] 1296 // } 1297 1298} 1299 1300// Pages invokes f for each page of results. 1301// A non-nil error returned from f will halt the iteration. 1302// The provided context supersedes any context provided to the Context method. 1303func (c *BillingAccountsBudgetsListCall) Pages(ctx context.Context, f func(*GoogleCloudBillingBudgetsV1ListBudgetsResponse) error) error { 1304 c.ctx_ = ctx 1305 defer c.PageToken(c.urlParams_.Get("pageToken")) // reset paging to original point 1306 for { 1307 x, err := c.Do() 1308 if err != nil { 1309 return err 1310 } 1311 if err := f(x); err != nil { 1312 return err 1313 } 1314 if x.NextPageToken == "" { 1315 return nil 1316 } 1317 c.PageToken(x.NextPageToken) 1318 } 1319} 1320 1321// method id "billingbudgets.billingAccounts.budgets.patch": 1322 1323type BillingAccountsBudgetsPatchCall struct { 1324 s *Service 1325 name string 1326 googlecloudbillingbudgetsv1budget *GoogleCloudBillingBudgetsV1Budget 1327 urlParams_ gensupport.URLParams 1328 ctx_ context.Context 1329 header_ http.Header 1330} 1331 1332// Patch: Updates a budget and returns the updated budget. WARNING: 1333// There are some fields exposed on the Google Cloud Console that aren't 1334// available on this API. Budget fields that are not exposed in this API 1335// will not be changed by this method. 1336// 1337// - name: Output only. Resource name of the budget. The resource name 1338// implies the scope of a budget. Values are of the form 1339// `billingAccounts/{billingAccountId}/budgets/{budgetId}`. 1340func (r *BillingAccountsBudgetsService) Patch(name string, googlecloudbillingbudgetsv1budget *GoogleCloudBillingBudgetsV1Budget) *BillingAccountsBudgetsPatchCall { 1341 c := &BillingAccountsBudgetsPatchCall{s: r.s, urlParams_: make(gensupport.URLParams)} 1342 c.name = name 1343 c.googlecloudbillingbudgetsv1budget = googlecloudbillingbudgetsv1budget 1344 return c 1345} 1346 1347// UpdateMask sets the optional parameter "updateMask": Indicates which 1348// fields in the provided budget to update. Read-only fields (such as 1349// `name`) cannot be changed. If this is not provided, then only fields 1350// with non-default values from the request are updated. See 1351// https://developers.google.com/protocol-buffers/docs/proto3#default 1352// for more details about default values. 1353func (c *BillingAccountsBudgetsPatchCall) UpdateMask(updateMask string) *BillingAccountsBudgetsPatchCall { 1354 c.urlParams_.Set("updateMask", updateMask) 1355 return c 1356} 1357 1358// Fields allows partial responses to be retrieved. See 1359// https://developers.google.com/gdata/docs/2.0/basics#PartialResponse 1360// for more information. 1361func (c *BillingAccountsBudgetsPatchCall) Fields(s ...googleapi.Field) *BillingAccountsBudgetsPatchCall { 1362 c.urlParams_.Set("fields", googleapi.CombineFields(s)) 1363 return c 1364} 1365 1366// Context sets the context to be used in this call's Do method. Any 1367// pending HTTP request will be aborted if the provided context is 1368// canceled. 1369func (c *BillingAccountsBudgetsPatchCall) Context(ctx context.Context) *BillingAccountsBudgetsPatchCall { 1370 c.ctx_ = ctx 1371 return c 1372} 1373 1374// Header returns an http.Header that can be modified by the caller to 1375// add HTTP headers to the request. 1376func (c *BillingAccountsBudgetsPatchCall) Header() http.Header { 1377 if c.header_ == nil { 1378 c.header_ = make(http.Header) 1379 } 1380 return c.header_ 1381} 1382 1383func (c *BillingAccountsBudgetsPatchCall) doRequest(alt string) (*http.Response, error) { 1384 reqHeaders := make(http.Header) 1385 reqHeaders.Set("x-goog-api-client", "gl-go/"+gensupport.GoVersion()+" gdcl/20210410") 1386 for k, v := range c.header_ { 1387 reqHeaders[k] = v 1388 } 1389 reqHeaders.Set("User-Agent", c.s.userAgent()) 1390 var body io.Reader = nil 1391 body, err := googleapi.WithoutDataWrapper.JSONReader(c.googlecloudbillingbudgetsv1budget) 1392 if err != nil { 1393 return nil, err 1394 } 1395 reqHeaders.Set("Content-Type", "application/json") 1396 c.urlParams_.Set("alt", alt) 1397 c.urlParams_.Set("prettyPrint", "false") 1398 urls := googleapi.ResolveRelative(c.s.BasePath, "v1/{+name}") 1399 urls += "?" + c.urlParams_.Encode() 1400 req, err := http.NewRequest("PATCH", urls, body) 1401 if err != nil { 1402 return nil, err 1403 } 1404 req.Header = reqHeaders 1405 googleapi.Expand(req.URL, map[string]string{ 1406 "name": c.name, 1407 }) 1408 return gensupport.SendRequest(c.ctx_, c.s.client, req) 1409} 1410 1411// Do executes the "billingbudgets.billingAccounts.budgets.patch" call. 1412// Exactly one of *GoogleCloudBillingBudgetsV1Budget or error will be 1413// non-nil. Any non-2xx status code is an error. Response headers are in 1414// either *GoogleCloudBillingBudgetsV1Budget.ServerResponse.Header or 1415// (if a response was returned at all) in 1416// error.(*googleapi.Error).Header. Use googleapi.IsNotModified to check 1417// whether the returned error was because http.StatusNotModified was 1418// returned. 1419func (c *BillingAccountsBudgetsPatchCall) Do(opts ...googleapi.CallOption) (*GoogleCloudBillingBudgetsV1Budget, error) { 1420 gensupport.SetOptions(c.urlParams_, opts...) 1421 res, err := c.doRequest("json") 1422 if res != nil && res.StatusCode == http.StatusNotModified { 1423 if res.Body != nil { 1424 res.Body.Close() 1425 } 1426 return nil, &googleapi.Error{ 1427 Code: res.StatusCode, 1428 Header: res.Header, 1429 } 1430 } 1431 if err != nil { 1432 return nil, err 1433 } 1434 defer googleapi.CloseBody(res) 1435 if err := googleapi.CheckResponse(res); err != nil { 1436 return nil, err 1437 } 1438 ret := &GoogleCloudBillingBudgetsV1Budget{ 1439 ServerResponse: googleapi.ServerResponse{ 1440 Header: res.Header, 1441 HTTPStatusCode: res.StatusCode, 1442 }, 1443 } 1444 target := &ret 1445 if err := gensupport.DecodeResponse(target, res); err != nil { 1446 return nil, err 1447 } 1448 return ret, nil 1449 // { 1450 // "description": "Updates a budget and returns the updated budget. WARNING: There are some fields exposed on the Google Cloud Console that aren't available on this API. Budget fields that are not exposed in this API will not be changed by this method.", 1451 // "flatPath": "v1/billingAccounts/{billingAccountsId}/budgets/{budgetsId}", 1452 // "httpMethod": "PATCH", 1453 // "id": "billingbudgets.billingAccounts.budgets.patch", 1454 // "parameterOrder": [ 1455 // "name" 1456 // ], 1457 // "parameters": { 1458 // "name": { 1459 // "description": "Output only. Resource name of the budget. The resource name implies the scope of a budget. Values are of the form `billingAccounts/{billingAccountId}/budgets/{budgetId}`.", 1460 // "location": "path", 1461 // "pattern": "^billingAccounts/[^/]+/budgets/[^/]+$", 1462 // "required": true, 1463 // "type": "string" 1464 // }, 1465 // "updateMask": { 1466 // "description": "Optional. Indicates which fields in the provided budget to update. Read-only fields (such as `name`) cannot be changed. If this is not provided, then only fields with non-default values from the request are updated. See https://developers.google.com/protocol-buffers/docs/proto3#default for more details about default values.", 1467 // "format": "google-fieldmask", 1468 // "location": "query", 1469 // "type": "string" 1470 // } 1471 // }, 1472 // "path": "v1/{+name}", 1473 // "request": { 1474 // "$ref": "GoogleCloudBillingBudgetsV1Budget" 1475 // }, 1476 // "response": { 1477 // "$ref": "GoogleCloudBillingBudgetsV1Budget" 1478 // }, 1479 // "scopes": [ 1480 // "https://www.googleapis.com/auth/cloud-billing", 1481 // "https://www.googleapis.com/auth/cloud-platform" 1482 // ] 1483 // } 1484 1485} 1486