// 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 Dataproc workflow template resource.
public struct WorkflowTemplate: Codable, Equatable, GoogleCloudWkt._AnyPackable,
  Sendable
{
  public var id: Swift.String = Swift.String()

  /// Output only. The resource name of the workflow template, as described
  /// in https://cloud.google.com/apis/design/resource_names.
  ///
  /// * For `projects.regions.workflowTemplates`, the resource name of the
  ///   template has the following format:
  ///   `projects/{project_id}/regions/{region}/workflowTemplates/{template_id}`
  ///
  /// * For `projects.locations.workflowTemplates`, the resource name of the
  ///   template has the following format:
  ///   `projects/{project_id}/locations/{location}/workflowTemplates/{template_id}`
  public var name: Swift.String = Swift.String()

  /// Optional. Used to perform a consistent read-modify-write.
  ///
  /// This field should be left blank for a `CreateWorkflowTemplate` request. It
  /// is required for an `UpdateWorkflowTemplate` request, and must match the
  /// current server version. A typical update template flow would fetch the
  /// current template with a `GetWorkflowTemplate` request, which will return
  /// the current template with the `version` field filled in with the
  /// current server version. The user updates other fields in the template,
  /// then returns it as part of the `UpdateWorkflowTemplate` request.
  public var version: Swift.Int32 = Swift.Int32()

  /// Output only. The time template was created.
  public var createTime: GoogleCloudWkt.Timestamp? = nil

  /// Output only. The time template was last updated.
  public var updateTime: GoogleCloudWkt.Timestamp? = nil

  /// Optional. The labels to associate with this template. These labels
  /// will be propagated to all jobs and clusters created by the workflow
  /// instance.
  ///
  /// Label **keys** must contain 1 to 63 characters, and must conform to
  /// [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt).
  ///
  /// Label **values** may be empty, but, if present, must contain 1 to 63
  /// characters, and must conform to
  /// [RFC 1035](https://www.ietf.org/rfc/rfc1035.txt).
  ///
  /// No more than 32 labels can be associated with a template.
  public var labels: [Swift.String: Swift.String] = [:]

  /// Required. WorkflowTemplate scheduling information.
  public var placement: WorkflowTemplatePlacement? = nil

  /// Required. The Directed Acyclic Graph of Jobs to submit.
  public var jobs: [OrderedJob] = []

  /// Optional. Template parameters whose values are substituted into the
  /// template. Values for parameters must be provided when the template is
  /// instantiated.
  public var parameters: [TemplateParameter] = []

  /// Optional. Timeout duration for the DAG of jobs, expressed in seconds (see
  /// [JSON representation of
  /// duration](https://developers.google.com/protocol-buffers/docs/proto3#json)).
  /// The timeout duration must be from 10 minutes ("600s") to 24 hours
  /// ("86400s"). The timer begins when the first job is submitted. If the
  /// workflow is running at the end of the timeout period, any remaining jobs
  /// are cancelled, the workflow is ended, and if the workflow was running on a
  /// [managed
  /// cluster](/dataproc/docs/concepts/workflows/using-workflows#configuring_or_selecting_a_cluster),
  /// the cluster is deleted.
  public var dagTimeout: GoogleCloudWkt.Duration? = nil

  /// Optional. Encryption settings for encrypting workflow template job
  /// arguments.
  public var encryptionConfig: WorkflowTemplate.EncryptionConfig? = nil

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

  /// Encryption settings for encrypting workflow template job arguments.
  public struct EncryptionConfig: Codable, Equatable, GoogleCloudWkt._AnyPackable,
    Sendable
  {
    /// Optional. The Cloud KMS key name to use for encrypting
    /// workflow template job arguments.
    ///
    /// When this this key is provided, the following workflow template
    /// [job arguments]
    /// (https://cloud.google.com/dataproc/docs/concepts/workflows/use-workflows#adding_jobs_to_a_template),
    /// if present, are
    /// [CMEK
    /// encrypted](https://cloud.google.com/dataproc/docs/concepts/configuring-clusters/customer-managed-encryption#use_cmek_with_workflow_template_data):
    ///
    /// * [FlinkJob
    /// args](https://cloud.google.com/dataproc/docs/reference/rest/v1/FlinkJob)
    /// * [HadoopJob
    /// args](https://cloud.google.com/dataproc/docs/reference/rest/v1/HadoopJob)
    /// * [SparkJob
    /// args](https://cloud.google.com/dataproc/docs/reference/rest/v1/SparkJob)
    /// * [SparkRJob
    /// args](https://cloud.google.com/dataproc/docs/reference/rest/v1/SparkRJob)
    /// * [PySparkJob
    /// args](https://cloud.google.com/dataproc/docs/reference/rest/v1/PySparkJob)
    /// * [SparkSqlJob](https://cloud.google.com/dataproc/docs/reference/rest/v1/SparkSqlJob)
    ///   scriptVariables and queryList.queries
    /// * [HiveJob](https://cloud.google.com/dataproc/docs/reference/rest/v1/HiveJob)
    ///   scriptVariables and queryList.queries
    /// * [PigJob](https://cloud.google.com/dataproc/docs/reference/rest/v1/PigJob)
    ///   scriptVariables and queryList.queries
    /// * [PrestoJob](https://cloud.google.com/dataproc/docs/reference/rest/v1/PrestoJob)
    ///   scriptVariables and queryList.queries
    public var kmsKey: Swift.String = Swift.String()

    /// Initialize a new instance of `EncryptionConfig`.
    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 = EncryptionConfig().with { $0.kmsKey = ... }
    /// ```
    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.dataproc.v1.WorkflowTemplate.EncryptionConfig"
    }
    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)
    }
  }

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