...

Source file src/google.golang.org/api/billingbudgets/v1/billingbudgets-gen.go

Documentation: google.golang.org/api/billingbudgets/v1

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

View as plain text