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

/// Represents an operation contained in an API version in the API Hub.
/// An operation is added/updated/deleted in an API version when a new spec is
/// added or an existing spec is updated/deleted in a version.
/// Currently, an operation will be created only corresponding to OpenAPI spec as
/// parsing is supported for OpenAPI spec.
/// Alternatively operations can be managed via create,update and delete APIs,
/// creation of apiOperation can be possible only for version with no parsed
/// operations and update/delete can be possible only for operations created via
/// create API.
public struct ApiOperation: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  /// Identifier. The name of the operation.
  ///
  /// Format:
  /// `projects/{project}/locations/{location}/apis/{api}/versions/{version}/operations/{operation}`
  public var name: Swift.String = Swift.String()

  /// Output only. The name of the spec will be of the format:
  /// `projects/{project}/locations/{location}/apis/{api}/versions/{version}/specs/{spec}`
  /// Note:The name of the spec will be empty if the operation is created via
  /// [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation] API.
  ///
  /// [google.cloud.apihub.v1.ApiHub.CreateApiOperation]: <doc:ApiHub/createApiOperation(request:)>
  public var spec: Swift.String = Swift.String()

  /// Optional. Operation details.
  /// Note: Even though this field is optional, it is required for
  /// [CreateApiOperation][google.cloud.apihub.v1.ApiHub.CreateApiOperation]
  /// API and we will fail the request if not provided.
  ///
  /// [google.cloud.apihub.v1.ApiHub.CreateApiOperation]: <doc:ApiHub/createApiOperation(request:)>
  public var details: OperationDetails? = nil

  /// Output only. The time at which the operation was created.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The time at which the operation was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Optional. The list of user defined attributes associated with the API
  /// operation resource. The key is the attribute name. It will be of the
  /// format: `projects/{project}/locations/{location}/attributes/{attribute}`.
  /// The value is the attribute values associated with the resource.
  public var attributes: [Swift.String: AttributeValues] = [:]

  /// Output only. The list of sources and metadata from the sources of the API
  /// operation.
  public var sourceMetadata: [SourceMetadata] = []

  /// Initialize a new instance of `ApiOperation`.
  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 = ApiOperation().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.apihub.v1.ApiOperation"
  }
  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)
  }
}
