// Copyright 2019 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.talent.v4beta1;

import "google/api/annotations.proto";
import "google/cloud/talent/v4beta1/job.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/talent/v4beta1;talent";
option java_multiple_files = true;
option java_outer_classname = "BatchProto";
option java_package = "com.google.cloud.talent.v4beta1";
option objc_class_prefix = "CTS";

// Output only.
//
// Metadata used for long running operations returned by CTS batch APIs.
// It's used to replace
// [google.longrunning.Operation.metadata][google.longrunning.Operation.metadata].
message BatchOperationMetadata {
  enum State {
    // Default value.
    STATE_UNSPECIFIED = 0;

    // The batch operation is being prepared for processing.
    INITIALIZING = 1;

    // The batch operation is actively being processed.
    PROCESSING = 2;

    // The batch operation is processed, and at least one item has been
    // successfully processed.
    SUCCEEDED = 3;

    // The batch operation is done and no item has been successfully processed.
    FAILED = 4;

    // The batch operation is in the process of cancelling after
    // [google.longrunning.Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
    // is called.
    CANCELLING = 5;

    // The batch operation is done after
    // [google.longrunning.Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
    // is called. Any items processed before cancelling are returned in the
    // response.
    CANCELLED = 6;
  }

  // The state of a long running operation.
  State state = 1;

  // More detailed information about operation state.
  string state_description = 2;

  // Count of successful item(s) inside an operation.
  int32 success_count = 3;

  // Count of failed item(s) inside an operation.
  int32 failure_count = 4;

  // Count of total item(s) inside an operation.
  int32 total_count = 5;

  // The time when the batch operation is created.
  google.protobuf.Timestamp create_time = 6;

  // The time when the batch operation status is updated. The metadata and the
  // [update_time][google.cloud.talent.v4beta1.BatchOperationMetadata.update_time]
  // is refreshed every minute otherwise cached data is returned.
  google.protobuf.Timestamp update_time = 7;

  // The time when the batch operation is finished and
  // [google.longrunning.Operation.done][google.longrunning.Operation.done] is
  // set to `true`.
  google.protobuf.Timestamp end_time = 8;
}

// Output only.
//
// The result of
// [JobService.BatchCreateJobs][google.cloud.talent.v4beta1.JobService.BatchCreateJobs]
// or
// [JobService.BatchUpdateJobs][google.cloud.talent.v4beta1.JobService.BatchUpdateJobs]
// APIs. It's used to replace
// [google.longrunning.Operation.response][google.longrunning.Operation.response]
// in case of success.
message JobOperationResult {
  // Mutation result of a job.
  message JobResult {
    // Here [Job][google.cloud.talent.v4beta1.Job] only contains basic
    // information including [name][google.cloud.talent.v4beta1.Job.name],
    // [company][google.cloud.talent.v4beta1.Job.company],
    // [language_code][google.cloud.talent.v4beta1.Job.language_code] and
    // [requisition_id][google.cloud.talent.v4beta1.Job.requisition_id], use
    // getJob method to retrieve detailed information of the created/updated
    // job.
    Job job = 1;

    // The status of the job processed. This field is populated if the
    // processing of the
    // [job][google.cloud.talent.v4beta1.JobOperationResult.JobResult.job]
    // fails.
    google.rpc.Status status = 2;
  }

  // List of job mutation results from a batch mutate operation. It can change
  // until operation status is FINISHED, FAILED or CANCELLED.
  repeated JobResult job_results = 1;
}
