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