// Copyright 2025 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
//
//     http://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.

syntax = "proto3";

package google.cloud.dataform.logging.v1;

import "google/api/field_behavior.proto";

option go_package = "cloud.google.com/go/dataform/logging/apiv1/loggingpb;loggingpb";
option java_multiple_files = true;
option java_outer_classname = "LoggingProto";
option java_package = "com.google.cloud.dataform.logging.v1";

// Structured payload for logs generated from Dataform workflow invocation
// completions.
message WorkflowInvocationCompletionLogEntry {
  // Represents the final termination state of a workflow invocation.
  enum TerminalState {
    // Default value. This value is unused.
    TERMINAL_STATE_UNSPECIFIED = 0;

    // The workflow invocation succeeded.
    SUCCEEDED = 1;

    // The workflow invocation was cancelled.
    CANCELLED = 2;

    // The workflow invocation failed.
    FAILED = 3;
  }

  // Required. Identifier of the workflow invocation.
  string workflow_invocation_id = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. Identifier of the workflow config.
  string workflow_config_id = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Identifier of the release config.
  string release_config_id = 3 [(google.api.field_behavior) = OPTIONAL];

  // Required. The workflow invocation's final termination state.
  TerminalState terminal_state = 4 [(google.api.field_behavior) = REQUIRED];
}

// Structured payload for logs generated from Dataform Act-as dry run results.
message ActAsDryRunResultLogEntry {
  // Context specific to `CreateRepository` API calls.
  message CreateRepositoryContext {
    // Optional. Resource name of the repository.
    // Format: `projects/*/locations/*/repositories/*`.
    string repository = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Context specific to `UpdateRepository` API calls.
  message UpdateRepositoryContext {
    // Optional. Resource name of the repository.
    // Format: `projects/*/locations/*/repositories/*`.
    string repository = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Context specific to `UpdateReleaseConfig` API calls.
  message UpdateReleaseConfigContext {
    // Optional. Resource name of the release config.
    // Format: `projects/*/locations/*/repositories/*/releaseConfigs/*`.
    string release_config = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Context specific to `CreateWorkflowConfig` API calls.
  message CreateWorkflowConfigContext {
    // Optional. Resource name of the workflow config.
    // Format: `projects/*/locations/*/repositories/*/workflowConfigs/*`.
    string workflow_config = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Context specific to `UpdateWorkflowConfig` API calls.
  message UpdateWorkflowConfigContext {
    // Optional. Resource name of the workflow config.
    // Format: `projects/*/locations/*/repositories/*/workflowConfigs/*`.
    string workflow_config = 1 [(google.api.field_behavior) = OPTIONAL];
  }

  // Context specific to `CreateWorkflowInvocation` API calls.
  message CreateWorkflowInvocationContext {
    // Optional. Resource name of the workflow invocation.
    // Format: `projects/*/locations/*/repositories/*/workflowInvocations/*`.
    string workflow_invocation = 1 [(google.api.field_behavior) = OPTIONAL];

    // The identifier of the compilation source.
    oneof compilation_source {
      // Optional. The name of the compilation result to use for this
      // invocation. Must be in the format
      // `projects/*/locations/*/repositories/*/compilationResults/*`.
      string compilation_result = 2 [(google.api.field_behavior) = OPTIONAL];

      // Optional. The name of the workflow config to invoke. Must be in the
      // format `projects/*/locations/*/repositories/*/workflowConfigs/*`.
      string workflow_config = 3 [(google.api.field_behavior) = OPTIONAL];
    }
  }

  // Required. The API method name that triggered the dry run check.
  string api_method = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The caller that triggered the dry run check.
  string caller = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The service account used for the dry run check.
  string service_account = 3 [(google.api.field_behavior) = REQUIRED];

  // Required. The result of the dry run check. True if check passed, false if
  // check failed.
  bool dry_run_result = 4 [(google.api.field_behavior) = REQUIRED];

  // Additional context specific to the API method that triggered the dry run.
  oneof api_method_context {
    // Optional. Context for `CreateWorkflowInvocation` calls.
    CreateWorkflowInvocationContext create_workflow_invocation_context = 5
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Context for `CreateRepository` calls.
    CreateRepositoryContext create_repository_context = 6
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Context for `UpdateRepository` calls.
    UpdateRepositoryContext update_repository_context = 7
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Context for `UpdateReleaseConfig` calls.
    UpdateReleaseConfigContext update_release_config_context = 8
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Context for `UpdateWorkflowConfig` calls.
    UpdateWorkflowConfigContext update_workflow_config_context = 9
        [(google.api.field_behavior) = OPTIONAL];

    // Optional. Context for `CreateWorkflowConfig` calls.
    CreateWorkflowConfigContext create_workflow_config_context = 10
        [(google.api.field_behavior) = OPTIONAL];
  }
}
