// 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.dialogflow.cx.v3beta1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

option cc_enable_arenas = true;
option csharp_namespace = "Google.Cloud.Dialogflow.Cx.V3Beta1";
option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/cx/v3beta1;cx";
option java_multiple_files = true;
option java_outer_classname = "EnvironmentProto";
option java_package = "com.google.cloud.dialogflow.cx.v3beta1";
option objc_class_prefix = "DF";

// Service for managing [Environments][google.cloud.dialogflow.cx.v3beta1.Environment].
service Environments {
  option (google.api.default_host) = "dialogflow.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform,"
      "https://www.googleapis.com/auth/dialogflow";

  // Returns the list of all environments in the specified [Agent][google.cloud.dialogflow.cx.v3beta1.Agent].
  rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) {
    option (google.api.http) = {
      get: "/v3beta1/{parent=projects/*/locations/*/agents/*}/environments"
    };
    option (google.api.method_signature) = "parent";
  }

  // Retrieves the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment].
  rpc GetEnvironment(GetEnvironmentRequest) returns (Environment) {
    option (google.api.http) = {
      get: "/v3beta1/{name=projects/*/locations/*/agents/*/environments/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates an [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] in the specified [Agent][google.cloud.dialogflow.cx.v3beta1.Agent].
  rpc CreateEnvironment(CreateEnvironmentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v3beta1/{parent=projects/*/locations/*/agents/*}/environments"
      body: "environment"
    };
    option (google.api.method_signature) = "parent,environment";
    option (google.longrunning.operation_info) = {
      response_type: "Environment"
      metadata_type: "google.protobuf.Struct"
    };
  }

  // Updates the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment].
  rpc UpdateEnvironment(UpdateEnvironmentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      patch: "/v3beta1/{environment.name=projects/*/locations/*/agents/*/environments/*}"
      body: "environment"
    };
    option (google.api.method_signature) = "environment,update_mask";
    option (google.longrunning.operation_info) = {
      response_type: "Environment"
      metadata_type: "google.protobuf.Struct"
    };
  }

  // Deletes the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment].
  rpc DeleteEnvironment(DeleteEnvironmentRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v3beta1/{name=projects/*/locations/*/agents/*/environments/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Looks up the history of the specified [Environment][google.cloud.dialogflow.cx.v3beta1.Environment].
  rpc LookupEnvironmentHistory(LookupEnvironmentHistoryRequest) returns (LookupEnvironmentHistoryResponse) {
    option (google.api.http) = {
      get: "/v3beta1/{name=projects/*/locations/*/agents/*/environments/*}:lookupEnvironmentHistory"
    };
    option (google.api.method_signature) = "name";
  }
}

// Represents an environment for an agent. You can create multiple versions
// of your agent and publish them to separate environments. When you edit an
// agent, you are editing the draft agent. At any point, you can save the draft
// agent as an agent version, which is an immutable snapshot of your agent. When
// you save the draft agent, it is published to the default environment. When
// you create agent versions, you can publish them to custom environments. You
// can create a variety of custom environments for testing, development,
// production, etc.
message Environment {
  option (google.api.resource) = {
    type: "dialogflow.googleapis.com/Environment"
    pattern: "projects/{project}/locations/{location}/agents/{agent}/environments/{environment}"
  };

  // Configuration for the version.
  message VersionConfig {
    // Required. Format: projects/<Project ID>/locations/<Location ID>/agents/<Agent
    // ID>/flows/<Flow ID>/versions/<Version ID>.
    string version = 1 [
      (google.api.field_behavior) = REQUIRED,
      (google.api.resource_reference) = {
        type: "dialogflow.googleapis.com/Version"
      }
    ];
  }

  // The name of the environment.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
  // ID>/environments/<Environment ID>`.
  string name = 1;

  // Required. The human-readable name of the environment (unique in an agent). Limit of
  // 64 characters.
  string display_name = 2 [(google.api.field_behavior) = REQUIRED];

  // The human-readable description of the environment. The maximum length is
  // 500 characters. If exceeded, the request is rejected.
  string description = 3;

  // Required. A list of configurations for flow versions. You should include version
  // configs for all flows that are reachable from [`Start
  // Flow`][Agent.start_flow] in the agent. Otherwise, an error will be
  // returned.
  repeated VersionConfig version_configs = 6 [(google.api.field_behavior) = REQUIRED];

  // Output only. Update time of this environment.
  google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// The request message for [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3beta1.Environments.ListEnvironments].
message ListEnvironmentsRequest {
  // Required. The [Agent][google.cloud.dialogflow.cx.v3beta1.Agent] to list all environments for.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "dialogflow.googleapis.com/Environment"
    }
  ];

  // The maximum number of items to return in a single page. By default 20 and
  // at most 100.
  int32 page_size = 2;

  // The next_page_token value returned from a previous list request.
  string page_token = 3;
}

// The response message for [Environments.ListEnvironments][google.cloud.dialogflow.cx.v3beta1.Environments.ListEnvironments].
message ListEnvironmentsResponse {
  // The list of environments. There will be a maximum number of items
  // returned based on the page_size field in the request. The list may in some
  // cases be empty or contain fewer entries than page_size even if this isn't
  // the last page.
  repeated Environment environments = 1;

  // Token to retrieve the next page of results, or empty if there are no more
  // results in the list.
  string next_page_token = 2;
}

// The request message for [Environments.GetEnvironment][google.cloud.dialogflow.cx.v3beta1.Environments.GetEnvironment].
message GetEnvironmentRequest {
  // Required. The name of the [Environment][google.cloud.dialogflow.cx.v3beta1.Environment].
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
  // ID>/environments/<Environment ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Environment"
    }
  ];
}

// The request message for [Environments.CreateEnvironment][google.cloud.dialogflow.cx.v3beta1.Environments.CreateEnvironment].
message CreateEnvironmentRequest {
  // Required. The [Agent][google.cloud.dialogflow.cx.v3beta1.Agent] to create an [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] for.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent ID>`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "dialogflow.googleapis.com/Environment"
    }
  ];

  // Required. The environment to create.
  Environment environment = 2 [(google.api.field_behavior) = REQUIRED];
}

// The request message for [Environments.UpdateEnvironment][google.cloud.dialogflow.cx.v3beta1.Environments.UpdateEnvironment].
message UpdateEnvironmentRequest {
  // Required. The environment to update.
  Environment environment = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. The mask to control which fields get updated.
  google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
}

// The request message for [Environments.DeleteEnvironment][google.cloud.dialogflow.cx.v3beta1.Environments.DeleteEnvironment].
message DeleteEnvironmentRequest {
  // Required. The name of the [Environment][google.cloud.dialogflow.cx.v3beta1.Environment] to delete.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
  // ID>/environments/<Environment ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Environment"
    }
  ];
}

// The request message for [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3beta1.Environments.LookupEnvironmentHistory].
message LookupEnvironmentHistoryRequest {
  // Required. Resource name of the environment to look up the history for.
  // Format: `projects/<Project ID>/locations/<Location ID>/agents/<Agent
  // ID>/environments/<Environment ID>`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "dialogflow.googleapis.com/Environment"
    }
  ];

  // The maximum number of items to return in a single page. By default 100 and
  // at most 1000.
  int32 page_size = 2;

  // The next_page_token value returned from a previous list request.
  string page_token = 3;
}

// The response message for [Environments.LookupEnvironmentHistory][google.cloud.dialogflow.cx.v3beta1.Environments.LookupEnvironmentHistory].
message LookupEnvironmentHistoryResponse {
  // Represents a list of snapshots for an environment. Time of the snapshots is
  // stored in [`update_time`][google.cloud.dialogflow.cx.v3beta1.Environment.update_time].
  repeated Environment environments = 1;

  // Token to retrieve the next page of results, or empty if there are no more
  // results in the list.
  string next_page_token = 2;
}
