// Code generated by sidekick. DO NOT EDIT.
//
// Copyright 2026 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import Foundation
import GoogleCloudWkt

/// A budget is a plan that describes what you expect to spend on Cloud
/// projects, plus the rules to execute as spend is tracked against that plan,
/// (for example, send an alert when 90% of the target spend is met).
/// The budget time period is configurable, with options such as month (default),
/// quarter, year, or custom time period.
public struct Budget: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Output only. Resource name of the budget.
  /// The resource name implies the scope of a budget. Values are of the form
  /// `billingAccounts/{billingAccountId}/budgets/{budgetId}`.
  public var name: Swift.String = Swift.String()

  /// User data for display name in UI. The name must be less than or equal to 60
  /// characters.
  public var displayName: Swift.String = Swift.String()

  /// Optional. Filters that define which resources are used to compute the
  /// actual spend against the budget amount, such as projects, services, and the
  /// budget's time period, as well as other filters.
  public var budgetFilter: Filter? = nil

  /// Required. Budgeted amount.
  public var amount: BudgetAmount? = nil

  /// Optional. Rules that trigger alerts (notifications of thresholds
  /// being crossed) when spend exceeds the specified percentages of the budget.
  ///
  /// Optional for `pubsubTopic` notifications.
  ///
  /// Required if using email notifications.
  public var thresholdRules: [ThresholdRule] = []

  /// Optional. Rules to apply to notifications sent based on budget spend and
  /// thresholds.
  public var notificationsRule: NotificationsRule? = nil

  /// Optional. Etag to validate that the object is unchanged for a
  /// read-modify-write operation.
  /// An empty etag causes an update to overwrite other changes.
  public var etag: Swift.String = Swift.String()

  /// Initialize a new instance of `Budget`.
  public init() {}

  /// Use `config` to return a new instance of this object, with some fields updated.
  ///
  /// Commonly used to initialize the value, for example:
  ///
  /// ```
  /// let value = Budget().with { $0.name = ... }
  /// ```
  public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
    var copy = self
    try config(&copy)
    return copy
  }

  public static var _anyTypeUrl: Swift.String {
    return "type.googleapis.com/google.cloud.billing.budgets.v1.Budget"
  }
  public init(fromAny any: GoogleCloudWkt.`Any`) throws {
    self = try GoogleCloudWkt._slowAnyDeserialize(Self.self, from: any)
  }
  public func _pack() throws -> GoogleCloudWkt.Struct {
    return try GoogleCloudWkt._slowAnySerialize(message: self)
  }
}
