/*
 * Copyright 2020-2021 Exactpro (Exactpro Systems Limited)
 *
 * 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";

option java_multiple_files = true;
option java_package = "com.exactpro.th2.act.grpc.hand";

import "th2_grpc_hand/rhactionsmessages.proto";
import "th2_grpc_hand/rhactionsmessages_win.proto";
import "th2_grpc_common/common.proto";
import "google/protobuf/empty.proto";

service RhBatch {
  rpc register(RhTargetServer) returns (RhSessionID) {}
  rpc unregister(RhSessionID) returns (google.protobuf.Empty) {}
  rpc executeRhActionsBatch(RhActionsList) returns (RhBatchResponse) {}
}

message RhSessionID {
    string id = 1;
    string sessionAlias = 2;
}

message RhTargetServer {
    string target = 1;
}

message ResultDetails {
    string actionId = 1;
    string result = 2;
}

message RhBatchResponse {

    enum ScriptExecutionStatus {
        SUCCESS = 0;
        COMPILE_ERROR = 1;
        EXECUTION_ERROR = 2;
    }

    ScriptExecutionStatus scriptStatus = 1;
    string errorMessage = 2;
    repeated ResultDetails result = 3;
    string sessionId = 4;
    repeated MessageID attached_message_ids = 5;
}

// Represents list of RhActions which need to be executed to perform some operation user wants to
message RhActionsList {
  RhSessionID sessionId = 1;
  repeated RhAction rhAction = 2;
  EventID parentEventId = 3;
}

message RhAction {
  oneof action {
      Open open = 1;
      Click click = 2;
      SetCheckbox setCheckbox = 3;
      SendKeys sendKeys = 4;
      WaitForElement waitForElement = 5;
      WaitForNew waitForNew = 6;
      Wait wait = 7;
      GetElement getElement = 8;
      GetElementInnerHtml getElementInnerHtml = 9;
      GetElementValue getElementValue = 10;
      GetElementAttribute getElementAttribute = 11;
      GetDynamicTable getDynamicTable = 12;
      ScrollTo scrollTo = 13;
      ScrollDivTo scrollDivTo = 14;
      ScrollDivUntil scrollDivUntil = 15;
      PageSource pageSource = 16;
      Refresh refresh = 17;
      Select select = 18;
      ClearElement clearElement = 19;
      Output output = 20;
      FindElement findElement = 21;
      KeyAction keyAction = 22;
      PressKey pressKey = 23;
      SendKeysToActive sendKeysToActive = 24;
      UploadFile uploadFile = 25;
      DownloadFile downloadFile = 26;
      SwitchWindow switchWindow = 27;
      CloseWindow closeWindow = 28;
      GetCurrentURL getCurrentURL = 29;
      SetZoom setZoom = 30;
      DurationStart durationStart = 31;
      GetDuration getDuration = 32;
      GetElementScreenshot getElementScreenshot = 33;
      WaitForChanges waitForChanges = 34;
      AcceptAlert acceptAlert = 35;
      DismissAlert dismissAlert = 36;
      CheckImageAvailability checkImageAvailability = 37;
      GetScreenshot getScreenshot = 38;
      StoreElementState storeElementState = 39;
      ExecuteJS executeJs = 40;
      ExecuteJSElement executeJsElement = 41;
      
      //windows actions
      WinOpen winOpen = 100;
      WinClick winClick = 101;
      WinSendText winSendText = 102;
      WinGetActiveWindow winGetActiveWindow = 103;
      WinGetElementAttribute winGetElementAttribute = 104;
      WinWait winWait= 105;
      WinToggleCheckBox winToggleCheckBox = 106;
      WinCheckElement winCheckElement = 108;
      WinGetWindow winGetWindow = 109;
      WinSearchElement winSearchElement = 110;
      WinWaitForAttribute winWaitForAttribute = 111;
      WinScrollUsingText winScrollUsingText = 112;
      WinGetDataFromClipboard winGetDataFromClipboard = 113;
      WinWaitForElement winWaitForElement = 114;
      WinTableSearch winTableSearch = 115;
      MaximizeMainWindow winMaximizeMainWindow = 116;
      WinGetScreenshot winGetScreenshot = 117;
      WinGetElementColor winGetElementColor = 118;
      WinDragAndDrop winDragAndDrop = 119;
      WinScrollToElement winScrollToElement = 120;
      WinRestartDriver winRestartDriver = 121;
      WinColorsCollector winColorsCollector = 122;
  }
}
