// 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.

#if RegionCompositeHealthChecks
  import Foundation
  import GoogleCloudWkt

  /// Represents a composite health check.
  ///
  /// A composite health check resource specifies the health source resources and
  /// the health destination resource to which the aggregated health result from
  /// the health source resources is delivered.
  public struct CompositeHealthCheck: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Output only. [Output Only] Creation timestamp inRFC3339
    /// text format.
    public var creationTimestamp: Swift.String? = nil

    /// An optional description of this resource. Provide this property when you
    /// create the resource.
    public var description: Swift.String? = nil

    /// Fingerprint of this resource. A hash of the contents stored in this object.
    /// This field is used in optimistic locking. This field will be ignored when
    /// inserting a CompositeHealthCheck. An up-to-date fingerprint
    /// must be provided in order to patch the CompositeHealthCheck; Otherwise,
    /// the request will fail with error 412 conditionNotMet. To see
    /// the latest fingerprint, make a get() request to retrieve the
    /// CompositeHealthCheck.
    public var fingerprint: Foundation.Data? = nil

    /// URL to the destination resource. Must be set. Must be aForwardingRule. The ForwardingRule must have
    /// load balancing scheme INTERNAL orINTERNAL_MANAGED and must be regional and in the same region
    /// as the CompositeHealthCheck (cross-region deployment forINTERNAL_MANAGED is not supported). Can be mutated.
    public var healthDestination: Swift.String? = nil

    /// URLs to the HealthSource resources whose results are AND'ed.
    /// I.e. he aggregated result is is HEALTHY only if all sources
    /// are HEALTHY. Must have at least 1. Must not have more than 10.
    /// Must be regional and in the same region as theCompositeHealthCheck. Can be mutated.
    public var healthSources: [Swift.String] = []

    /// Output only. [Output Only] A unique identifier for this resource type. The server
    /// generates this identifier.
    public var id: Swift.UInt64? = nil

    /// Output only. [Output Only] Type of the resource. Alwayscompute#compositeHealthCheck for composite health checks.
    public var kind: Swift.String? = nil

    /// Name of the resource. Provided by the client when the resource is created.
    /// The name must be 1-63 characters long, and comply withRFC1035.
    /// Specifically, the name must be 1-63 characters long and match the regular
    /// expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first
    /// character must be a lowercase letter, and all following characters must
    /// be a dash, lowercase letter, or digit, except the last character, which
    /// cannot be a dash.
    public var name: Swift.String? = nil

    /// Output only. [Output Only] URL of the region where the composite health check resides.
    /// This field applies only to the regional resource. You must specify this
    /// field as part of the HTTP request URL. It is not settable as a field in
    /// the request body.
    public var region: Swift.String? = nil

    /// Output only. [Output Only] Server-defined URL for the resource.
    public var selfLink: Swift.String? = nil

    /// Output only. [Output Only] Server-defined URL with id for the resource.
    public var selfLinkWithId: Swift.String? = nil

    /// Initialize a new instance of `CompositeHealthCheck`.
    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 = CompositeHealthCheck().with { $0.creationTimestamp = ... }
    /// ```
    public func with(_ config: (inout Self) throws -> Swift.Void) rethrows -> Self {
      var copy = self
      try config(&copy)
      return copy
    }

    private enum CodingKeys: Swift.String, CodingKey {
      case creationTimestamp = "creationTimestamp"
      case description = "description"
      case fingerprint = "fingerprint"
      case healthDestination = "healthDestination"
      case healthSources = "healthSources"
      case id = "id"
      case kind = "kind"
      case name = "name"
      case region = "region"
      case selfLink = "selfLink"
      case selfLinkWithId = "selfLinkWithId"
    }

    public init(from decoder: Decoder) throws {
      let container = try decoder.container(keyedBy: CodingKeys.self)
      self.creationTimestamp = try container.decodeIfPresent(
        Swift.String.self, forKey: .creationTimestamp)
      self.description = try container.decodeIfPresent(Swift.String.self, forKey: .description)
      if let s = try container.decodeIfPresent(Swift.String.self, forKey: .fingerprint) {
        guard let v = GoogleCloudWkt._DiscoveryBase64.decode(s) else {
          throw DecodingError.dataCorrupted(
            DecodingError.Context(
              codingPath: decoder.codingPath, debugDescription: "Expected url-safe encoded value")
          )
        }
        self.fingerprint = v
      }
      self.healthDestination = try container.decodeIfPresent(
        Swift.String.self, forKey: .healthDestination)
      self.healthSources = try container.decode([Swift.String].self, forKey: .healthSources)
      self.id = try container.decodeIfPresent(Swift.UInt64.self, forKey: .id)
      self.kind = try container.decodeIfPresent(Swift.String.self, forKey: .kind)
      self.name = try container.decodeIfPresent(Swift.String.self, forKey: .name)
      self.region = try container.decodeIfPresent(Swift.String.self, forKey: .region)
      self.selfLink = try container.decodeIfPresent(Swift.String.self, forKey: .selfLink)
      self.selfLinkWithId = try container.decodeIfPresent(
        Swift.String.self, forKey: .selfLinkWithId)
    }

    public func encode(to encoder: Encoder) throws {
      var container = encoder.container(keyedBy: CodingKeys.self)
      try container.encode(self.creationTimestamp, forKey: .creationTimestamp)
      try container.encode(self.description, forKey: .description)
      if let v = fingerprint {
        try container.encode(
          GoogleCloudWkt._DiscoveryBase64.encode(v), forKey: .fingerprint
        )
      }
      try container.encode(self.healthDestination, forKey: .healthDestination)
      try container.encode(self.healthSources, forKey: .healthSources)
      try container.encode(self.id, forKey: .id)
      try container.encode(self.kind, forKey: .kind)
      try container.encode(self.name, forKey: .name)
      try container.encode(self.region, forKey: .region)
      try container.encode(self.selfLink, forKey: .selfLink)
      try container.encode(self.selfLinkWithId, forKey: .selfLinkWithId)
    }

    public static var _anyTypeUrl: Swift.String {
      return "type.googleapis.com/google.cloud.compute.v1.CompositeHealthCheck"
    }
    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)
    }
  }
#endif
