# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
#     ***     AUTO GENERATED CODE    ***    Type: MMv1     ***
#
# ----------------------------------------------------------------------------
#
#     This file is automatically generated by Magic Modules and manual
#     changes will be clobbered when the file is regenerated.
#
#     Please read more about how to change this file in README.md and
#     CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/dataflow/property/projectlocationjob_environment'
require 'google/dataflow/property/projectlocationjob_environment_debug_options'
require 'google/dataflow/property/projectlocationjob_environment_debug_options_data_sampling'
require 'google/dataflow/property/projectlocationjob_environment_internal_experiments'
require 'google/dataflow/property/projectlocationjob_environment_sdk_pipeline_options'
require 'google/dataflow/property/projectlocationjob_environment_user_agent'
require 'google/dataflow/property/projectlocationjob_environment_version'
require 'google/dataflow/property/projectlocationjob_environment_worker_pools'
require 'google/dataflow/property/projectlocationjob_execution_info'
require 'google/dataflow/property/projectlocationjob_execution_info_stages'
require 'google/dataflow/property/projectlocationjob_job_metadata'
require 'google/dataflow/property/projectlocationjob_job_metadata_big_table_details'
require 'google/dataflow/property/projectlocationjob_job_metadata_bigquery_details'
require 'google/dataflow/property/projectlocationjob_job_metadata_datastore_details'
require 'google/dataflow/property/projectlocationjob_job_metadata_file_details'
require 'google/dataflow/property/projectlocationjob_job_metadata_pubsub_details'
require 'google/dataflow/property/projectlocationjob_job_metadata_sdk_version'
require 'google/dataflow/property/projectlocationjob_job_metadata_sdk_version_bugs'
require 'google/dataflow/property/projectlocationjob_job_metadata_spanner_details'
require 'google/dataflow/property/projectlocationjob_job_metadata_user_display_properties'
require 'google/dataflow/property/projectlocationjob_labels'
require 'google/dataflow/property/projectlocationjob_pipeline_description'
require 'google/dataflow/property/projectlocationjob_pipeline_description_display_data'
require 'google/dataflow/property/projectlocationjob_pipeline_description_execution_pipeline_stage'
require 'google/dataflow/property/projectlocationjob_pipeline_description_original_pipeline_transform'
require 'google/dataflow/property/projectlocationjob_runtime_updatable_params'
require 'google/dataflow/property/projectlocationjob_stage_states'
require 'google/dataflow/property/projectlocationjob_steps'
require 'google/dataflow/property/projectlocationjob_transform_name_mapping'

# A provider to manage dataflow resources.
class DataflowProjectLocationJob < GcpResourceBase
  name 'google_dataflow_project_location_job'
  desc 'ProjectLocationJob'
  supports platform: 'gcp'

  attr_reader :params
  attr_reader :id
  attr_reader :project_id
  attr_reader :name
  attr_reader :type
  attr_reader :environment
  attr_reader :steps
  attr_reader :steps_location
  attr_reader :current_state
  attr_reader :current_state_time
  attr_reader :requested_state
  attr_reader :execution_info
  attr_reader :create_time
  attr_reader :replace_job_id
  attr_reader :transform_name_mapping
  attr_reader :client_request_id
  attr_reader :replaced_by_job_id
  attr_reader :temp_files
  attr_reader :labels
  attr_reader :location
  attr_reader :pipeline_description
  attr_reader :stage_states
  attr_reader :job_metadata
  attr_reader :start_time
  attr_reader :created_from_snapshot_id
  attr_reader :satisfies_pzs
  attr_reader :runtime_updatable_params
  attr_reader :satisfies_pzi

  def initialize(params)
    super(params.merge({ use_http_transport: true }))
    @params = params
    @fetched = @connection.fetch(product_url(params[:beta]), resource_base_url, params, 'Get')
    parse unless @fetched.nil?
  end

  def parse
    @id = @fetched['id']
    @project_id = @fetched['projectId']
    @name = @fetched['name']
    @type = @fetched['type']
    @environment = GoogleInSpec::Dataflow::Property::ProjectLocationJobEnvironment.new(@fetched['environment'], to_s)
    @steps = GoogleInSpec::Dataflow::Property::ProjectLocationJobStepsArray.parse(@fetched['steps'], to_s)
    @steps_location = @fetched['stepsLocation']
    @current_state = @fetched['currentState']
    @current_state_time = @fetched['currentStateTime']
    @requested_state = @fetched['requestedState']
    @execution_info = GoogleInSpec::Dataflow::Property::ProjectLocationJobExecutionInfo.new(@fetched['executionInfo'], to_s)
    @create_time = @fetched['createTime']
    @replace_job_id = @fetched['replaceJobId']
    @transform_name_mapping = GoogleInSpec::Dataflow::Property::ProjectLocationJobTransformNameMapping.new(@fetched['transformNameMapping'], to_s)
    @client_request_id = @fetched['clientRequestId']
    @replaced_by_job_id = @fetched['replacedByJobId']
    @temp_files = @fetched['tempFiles']
    @labels = GoogleInSpec::Dataflow::Property::ProjectLocationJobLabels.new(@fetched['labels'], to_s)
    @location = @fetched['location']
    @pipeline_description = GoogleInSpec::Dataflow::Property::ProjectLocationJobPipelineDescription.new(@fetched['pipelineDescription'], to_s)
    @stage_states = GoogleInSpec::Dataflow::Property::ProjectLocationJobStageStatesArray.parse(@fetched['stageStates'], to_s)
    @job_metadata = GoogleInSpec::Dataflow::Property::ProjectLocationJobJobMetadata.new(@fetched['jobMetadata'], to_s)
    @start_time = @fetched['startTime']
    @created_from_snapshot_id = @fetched['createdFromSnapshotId']
    @satisfies_pzs = @fetched['satisfiesPzs']
    @runtime_updatable_params = GoogleInSpec::Dataflow::Property::ProjectLocationJobRuntimeUpdatableParams.new(@fetched['runtimeUpdatableParams'], to_s)
    @satisfies_pzi = @fetched['satisfiesPzi']
  end

  def exists?
    !@fetched.nil?
  end

  def to_s
    "ProjectLocationJob #{@params[:jobId]}"
  end

  private

  def product_url(_ = nil)
    'https://dataflow.googleapis.com/v1b3/'
  end

  def resource_base_url
    'projects/{{project}}/locations/{{location}}/jobs/{{job}}'
  end
end
