// @project        The CERN Tape Archive (CTA)
// @brief          CTA-EOS API definition
// @copyright      Copyright 2017 CERN
// @license        This program is free software: you can redistribute it and/or modify
//                 it under the terms of the GNU General Public License as published by
//                 the Free Software Foundation, either version 3 of the License, or
//                 (at your option) any later version.
//
//                 This program is distributed in the hope that it will be useful,
//                 but WITHOUT ANY WARRANTY; without even the implied warranty of
//                 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//                 GNU General Public License for more details.
//
//                 You should have received a copy of the GNU General Public License
//                 along with this program.  If not, see <http://www.gnu.org/licenses/>.

syntax = "proto3";
package cta.eos;

import "cta_common.proto";

//
// Messages sent from EOS to CTA Frontend
//

message Workflow {
  enum EventType {
    NONE          = 0;
    OPENR         = 1;
    OPENW         = 2;
    CLOSER        = 3;
    CLOSEW        = 4;
    DELETE        = 5;
    PREPARE       = 6;
    CREATE        = 7;
    ABORT_PREPARE = 8;
    UPDATE_FID    = 10;
  }
  EventType event             =  1;      //< event
  //string queue              =  2;      //< RESERVED
  //string wfname             =  3;      //< RESERVED
  //string vpath              =  4;      //< RESERVED
  cta.common.Service instance =  5;      //< instance information
  //uint64 timestamp          =  6;      //< RESERVED

  // for CLOSEW events submitted by the FST
  string requester_instance   =  7;      //< hostname and instance name of the FST which submitted the request

  // For PREPARE events
  bool verify_only            = 10;      //< Recall file from tape but do not write a disk copy
  string vid                  = 11;      //< Recall from the specified tape VID only (in the case of dual-copy files)
}

message Client {
  cta.common.RequesterId user =  1;      //< acting client
  cta.common.Security sec     =  2;      //< client security information
}

message Transport {
  string dst_url              =  1;      //< transport destination URL
  string report_url           =  2;      //< URL to report successful archiving
  string error_report_url     =  3;      //< URL to report errors
}

message Metadata {
  uint64 fid                  =  1;      //< file/container id
  uint64 pid                  =  2;      //< parent id (NOT USED BY CTA)
  cta.common.Clock ctime      =  3;      //< change time (NOT USED BY CTA)
  cta.common.Clock mtime      =  4;      //< modification time (NOT USED BY CTA)
  cta.common.Clock btime      =  5;      //< birth time (NOT USED BY CTA)
  cta.common.Clock ttime      =  6;      //< tree modification time (NOT USED BY CTA)
  cta.common.OwnerId owner    =  7;      //< ownership
  uint64 size                 =  8;      //< size 
  sint32 mode                 = 10;      //< mode (NOT USED BY CTA)
  string lpath                = 11;      //< logical path
  map<string, string> xattr   = 12;      //< xattribute map
  cta.common.ChecksumBlob csb = 13;      //< array of checksums

  // Additions for dCache integration

  string disk_file_id         = 14;      //< String identifier for Disk File ID (= fid above)
  uint64 archive_file_id      = 15;      //< CTA Archive File ID
  string storage_class        = 16;      //< CTA Storage Class
};

message Notification {
  Workflow wf                 =  1;      //< workflow
  Client cli                  =  2;      //< client information
  Transport transport         =  3;      //< transport
  Metadata file               =  4;      //< file meta data
  Metadata directory          =  5;      //< directory meta data (NOT USED BY CTA)
}