// 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.v2beta1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/dialogflow/v2beta1/audio_config.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.V2beta1";
option go_package = "google.golang.org/genproto/googleapis/cloud/dialogflow/v2beta1;dialogflow";
option java_multiple_files = true;
option java_outer_classname = "EnvironmentProto";
option java_package = "com.google.cloud.dialogflow.v2beta1";
option objc_class_prefix = "DF";

// Service for managing [Environments][google.cloud.dialogflow.v2beta1.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 non-draft environments of the specified agent.
  rpc ListEnvironments(ListEnvironmentsRequest) returns (ListEnvironmentsResponse) {
    option (google.api.http) = {
      get: "/v2beta1/{parent=projects/*/agent}/environments"
      additional_bindings {
        get: "/v2beta1/{parent=projects/*/locations/*/agent}/environments"
      }
    };
    option (google.api.method_signature) = "parent";
  }
}

// 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.
//
// For more information, see the [versions and environments
// guide](https://cloud.google.com/dialogflow/docs/agents-versions).
message Environment {
  option (google.api.resource) = {
    type: "dialogflow.googleapis.com/Environment"
    pattern: "projects/{project}/agent/environments/{environment}"
    pattern: "projects/{project}/locations/{location}/agent/environments/{environment}"
  };

  // Represents an environment state. When an environment is pointed to a new
  // agent version, the environment is temporarily set to the `LOADING` state.
  // During that time, the environment keeps on serving the previous version of
  // the agent. After the new agent version is done loading, the environment is
  // set back to the `RUNNING` state.
  enum State {
    // Not specified. This value is not used.
    STATE_UNSPECIFIED = 0;

    // Stopped.
    STOPPED = 1;

    // Loading.
    LOADING = 2;

    // Running.
    RUNNING = 3;
  }

  // Output only. The unique identifier of this agent environment.
  // Supported formats:
  // - `projects/<Project Number / ID>/agent/environments/<Environment ID>`
  // - `projects/<Project Number / ID>/locations/<Location
  //   ID>/agent/environments/<Environment ID>`
  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The developer-provided description for this environment.
  // The maximum length is 500 characters. If exceeded, the request is rejected.
  string description = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The agent version loaded into this environment.
  // Supported formats:
  // - `projects/<Project ID>/agent/versions/<Version ID>`
  // - `projects/<Project ID>/locations/<Location ID>/agent/versions/<Version
  //   ID>`
  string agent_version = 3 [(google.api.field_behavior) = OPTIONAL];

  // Output only. The state of this environment. This field is read-only, i.e., it cannot be
  // set by create and update methods.
  State state = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The last update time of this environment. This field is read-only, i.e., it
  // cannot be set by create and update methods.
  google.protobuf.Timestamp update_time = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
}

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

  // Optional. The maximum number of items to return in a single page. By default 100 and
  // at most 1000.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The next_page_token value returned from a previous list request.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// The response message for [Environments.ListEnvironments][google.cloud.dialogflow.v2beta1.Environments.ListEnvironments].
message ListEnvironmentsResponse {
  // The list of agent environments. There will be a maximum number of items
  // returned based on the page_size field in the request.
  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;
}
