// Copyright 2020 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/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/talent/v4beta1/common.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
import "google/type/date.proto";

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

// Resource that represents a job application record of a candidate.
message Application {
  option (google.api.resource) = {
    type: "jobs.googleapis.com/Application"
    pattern: "projects/{project}/tenants/{tenant}/profiles/{profile}/applications/{application}"
  };

  // Enum that represents the application status.
  enum ApplicationState {
    // Default value.
    APPLICATION_STATE_UNSPECIFIED = 0;

    // The current stage is in progress or pending, for example, interviews in
    // progress.
    IN_PROGRESS = 1;

    // The current stage was terminated by a candidate decision.
    CANDIDATE_WITHDREW = 2;

    // The current stage was terminated by an employer or agency decision.
    EMPLOYER_WITHDREW = 3;

    // The current stage is successfully completed, but the next stage (if
    // applicable) has not begun.
    COMPLETED = 4;

    // The current stage was closed without an exception, or terminated for
    // reasons unrealated to the candidate.
    CLOSED = 5;
  }

  // The stage of the application.
  enum ApplicationStage {
    // Default value.
    APPLICATION_STAGE_UNSPECIFIED = 0;

    // Candidate has applied or a recruiter put candidate into consideration but
    // candidate is not yet screened / no decision has been made to move or not
    // move the candidate to the next stage.
    NEW = 1;

    // A recruiter decided to screen the candidate for this role.
    SCREEN = 2;

    // Candidate is being / was sent to the customer / hiring manager for
    // detailed review.
    HIRING_MANAGER_REVIEW = 3;

    // Candidate was approved by the client / hiring manager and is being / was
    // interviewed for the role.
    INTERVIEW = 4;

    // Candidate will be / has been given an offer of employment.
    OFFER_EXTENDED = 5;

    // Candidate has accepted their offer of employment.
    OFFER_ACCEPTED = 6;

    // Candidate has begun (or completed) their employment or assignment with
    // the employer.
    STARTED = 7;
  }

  // Required during application update.
  //
  // Resource name assigned to an application by the API.
  //
  // The format is
  // "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}/applications/{application_id}".
  // For example, "projects/foo/tenants/bar/profiles/baz/applications/qux".
  string name = 1;

  // Required. Client side application identifier, used to uniquely identify the
  // application.
  //
  // The maximum number of allowed characters is 255.
  string external_id = 31 [(google.api.field_behavior) = REQUIRED];

  // Output only. Resource name of the candidate of this application.
  //
  // The format is
  // "projects/{project_id}/tenants/{tenant_id}/profiles/{profile_id}".
  // For example, "projects/foo/tenants/bar/profiles/baz".
  string profile = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Required. Resource name of the job which the candidate applied for.
  //
  // The format is
  // "projects/{project_id}/tenants/{tenant_id}/jobs/{job_id}". For example,
  // "projects/foo/tenants/bar/jobs/baz".
  string job = 4 [
    (google.api.resource_reference).type = "jobs.googleapis.com/Job",
    (google.api.field_behavior) = REQUIRED
  ];

  // Resource name of the company which the candidate applied for.
  //
  // The format is
  // "projects/{project_id}/tenants/{tenant_id}/companies/{company_id}".
  // For example, "projects/foo/tenants/bar/companies/baz".
  string company = 5 [
    (google.api.resource_reference) = { type: "jobs.googleapis.com/Company" }
  ];

  // The application date.
  google.type.Date application_date = 7;

  // Required. What is the most recent stage of the application (that is, new,
  // screen, send cv, hired, finished work)?  This field is intentionally not
  // comprehensive of every possible status, but instead, represents statuses
  // that would be used to indicate to the ML models good / bad matches.
  ApplicationStage stage = 11 [(google.api.field_behavior) = REQUIRED];

  // The application state.
  ApplicationState state = 13;

  // All interviews (screen, onsite, and so on) conducted as part of this
  // application (includes details such as user conducting the interview,
  // timestamp, feedback, and so on).
  repeated Interview interviews = 16;

  // If the candidate is referred by a employee.
  google.protobuf.BoolValue referral = 18;

  // Required. Reflects the time that the application was created.
  google.protobuf.Timestamp create_time = 19
      [(google.api.field_behavior) = REQUIRED];

  // The last update timestamp.
  google.protobuf.Timestamp update_time = 20;

  // Free text reason behind the recruitement outcome (for example, reason for
  // withdraw / reject, reason for an unsuccessful finish, and so on).
  //
  // Number of characters allowed is 100.
  string outcome_notes = 21;

  // Outcome positiveness shows how positive the outcome is.
  Outcome outcome = 22;

  // Output only. Indicates whether this job application is a match to
  // application related filters. This value is only applicable in profile
  // search response.
  google.protobuf.BoolValue is_match = 28
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Job title snippet shows how the job title is related to a
  // search query. It's empty if the job title isn't related to the search
  // query.
  string job_title_snippet = 29 [(google.api.field_behavior) = OUTPUT_ONLY];
}
