// 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.automl.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/cloud/automl/v1/annotation_payload.proto";
import "google/cloud/automl/v1/data_items.proto";
import "google/cloud/automl/v1/io.proto";
import "google/cloud/automl/v1/operations.proto";
import "google/longrunning/operations.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/automl/v1;automl";
option csharp_namespace = "Google.Cloud.AutoML.V1";
option java_multiple_files = true;
option java_outer_classname = "PredictionServiceProto";
option java_package = "com.google.cloud.automl.v1";
option php_namespace = "Google\\Cloud\\AutoML\\V1";
option ruby_package = "Google::Cloud::AutoML::V1";

// AutoML Prediction API.
//
// On any input that is documented to expect a string parameter in
// snake_case or kebab-case, either of those cases is accepted.
service PredictionService {
  option (google.api.default_host) = "automl.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Perform an online prediction. The prediction result will be directly
  // returned in the response.
  // Available for following ML problems, and their expected request payloads:
  // * Translation - TextSnippet, content up to 25,000 characters, UTF-8
  //                 encoded.
  rpc Predict(PredictRequest) returns (PredictResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/models/*}:predict"
      body: "*"
    };
  }
}

// Request message for
// [PredictionService.Predict][google.cloud.automl.v1.PredictionService.Predict].
message PredictRequest {
  // Name of the model requested to serve the prediction.
  string name = 1;

  // Required. Payload to perform a prediction on. The payload must match the
  // problem type that the model was trained to solve.
  ExamplePayload payload = 2;

  // Additional domain-specific parameters, any string must be up to 25000
  // characters long.
  map<string, string> params = 3;
}

// Response message for
// [PredictionService.Predict][google.cloud.automl.v1.PredictionService.Predict].
message PredictResponse {
  // Prediction result.
  // Translation and Text Sentiment will return precisely one payload.
  repeated AnnotationPayload payload = 1;

  // Additional domain-specific prediction response metadata.
  map<string, string> metadata = 2;
}
