// Copyright 2018 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.monitoring.v3;

import "google/api/annotations.proto";
import "google/monitoring/v3/uptime.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Cloud.Monitoring.V3";
option go_package = "google.golang.org/genproto/googleapis/monitoring/v3;monitoring";
option java_multiple_files = true;
option java_outer_classname = "UptimeServiceProto";
option java_package = "com.google.monitoring.v3";
option php_namespace = "Google\\Cloud\\Monitoring\\V3";

// The UptimeCheckService API is used to manage (list, create, delete, edit)
// uptime check configurations in the Stackdriver Monitoring product. An uptime
// check is a piece of configuration that determines which resources and
// services to monitor for availability. These configurations can also be
// configured interactively by navigating to the [Cloud Console]
// (http://console.cloud.google.com), selecting the appropriate project,
// clicking on "Monitoring" on the left-hand side to navigate to Stackdriver,
// and then clicking on "Uptime".
service UptimeCheckService {
  // Lists the existing valid uptime check configurations for the project,
  // leaving out any invalid configurations.
  rpc ListUptimeCheckConfigs(ListUptimeCheckConfigsRequest)
      returns (ListUptimeCheckConfigsResponse) {
    option (google.api.http) = {
      get: "/v3/{parent=projects/*}/uptimeCheckConfigs"
    };
  }

  // Gets a single uptime check configuration.
  rpc GetUptimeCheckConfig(GetUptimeCheckConfigRequest)
      returns (UptimeCheckConfig) {
    option (google.api.http) = {
      get: "/v3/{name=projects/*/uptimeCheckConfigs/*}"
    };
  }

  // Creates a new uptime check configuration.
  rpc CreateUptimeCheckConfig(CreateUptimeCheckConfigRequest)
      returns (UptimeCheckConfig) {
    option (google.api.http) = {
      post: "/v3/{parent=projects/*}/uptimeCheckConfigs"
      body: "uptime_check_config"
    };
  }

  // Updates an uptime check configuration. You can either replace the entire
  // configuration with a new one or replace only certain fields in the current
  // configuration by specifying the fields to be updated via `"updateMask"`.
  // Returns the updated configuration.
  rpc UpdateUptimeCheckConfig(UpdateUptimeCheckConfigRequest)
      returns (UptimeCheckConfig) {
    option (google.api.http) = {
      patch: "/v3/{uptime_check_config.name=projects/*/uptimeCheckConfigs/*}"
      body: "uptime_check_config"
    };
  }

  // Deletes an uptime check configuration. Note that this method will fail
  // if the uptime check configuration is referenced by an alert policy or
  // other dependent configs that would be rendered invalid by the deletion.
  rpc DeleteUptimeCheckConfig(DeleteUptimeCheckConfigRequest)
      returns (google.protobuf.Empty) {
    option (google.api.http) = {
      delete: "/v3/{name=projects/*/uptimeCheckConfigs/*}"
    };
  }

  // Returns the list of IPs that checkers run from
  rpc ListUptimeCheckIps(ListUptimeCheckIpsRequest)
      returns (ListUptimeCheckIpsResponse) {
    option (google.api.http) = {
      get: "/v3/uptimeCheckIps"
    };
  }
}

// The protocol for the `ListUptimeCheckConfigs` request.
message ListUptimeCheckConfigsRequest {
  // The project whose uptime check configurations are listed. The format
  //   is `projects/[PROJECT_ID]`.
  string parent = 1;

  // The maximum number of results to return in a single response. The server
  // may further constrain the maximum number of results returned in a single
  // page. If the page_size is <=0, the server will decide the number of results
  // to be returned.
  int32 page_size = 3;

  // If this field is not empty then it must contain the `nextPageToken` value
  // returned by a previous call to this method.  Using this field causes the
  // method to return more results from the previous method call.
  string page_token = 4;
}

// The protocol for the `ListUptimeCheckConfigs` response.
message ListUptimeCheckConfigsResponse {
  // The returned uptime check configurations.
  repeated UptimeCheckConfig uptime_check_configs = 1;

  // This field represents the pagination token to retrieve the next page of
  // results. If the value is empty, it means no further results for the
  // request. To retrieve the next page of results, the value of the
  // next_page_token is passed to the subsequent List method call (in the
  // request message's page_token field).
  string next_page_token = 2;

  // The total number of uptime check configurations for the project,
  // irrespective of any pagination.
  int32 total_size = 3;
}

// The protocol for the `GetUptimeCheckConfig` request.
message GetUptimeCheckConfigRequest {
  // The uptime check configuration to retrieve. The format
  //   is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`.
  string name = 1;
}

// The protocol for the `CreateUptimeCheckConfig` request.
message CreateUptimeCheckConfigRequest {
  // The project in which to create the uptime check. The format
  //   is `projects/[PROJECT_ID]`.
  string parent = 1;

  // The new uptime check configuration.
  UptimeCheckConfig uptime_check_config = 2;
}

// The protocol for the `UpdateUptimeCheckConfig` request.
message UpdateUptimeCheckConfigRequest {
  // Optional. If present, only the listed fields in the current uptime check
  // configuration are updated with values from the new configuration. If this
  // field is empty, then the current configuration is completely replaced with
  // the new configuration.
  google.protobuf.FieldMask update_mask = 2;

  // Required. If an `"updateMask"` has been specified, this field gives
  // the values for the set of fields mentioned in the `"updateMask"`. If an
  // `"updateMask"` has not been given, this uptime check configuration replaces
  // the current configuration. If a field is mentioned in `"updateMask"` but
  // the corresonding field is omitted in this partial uptime check
  // configuration, it has the effect of deleting/clearing the field from the
  // configuration on the server.
  //
  // The following fields can be updated: `display_name`,
  // `http_check`, `tcp_check`, `timeout`, `content_matchers`, and
  // `selected_regions`.
  UptimeCheckConfig uptime_check_config = 3;
}

// The protocol for the `DeleteUptimeCheckConfig` request.
message DeleteUptimeCheckConfigRequest {
  // The uptime check configuration to delete. The format
  //   is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`.
  string name = 1;
}

// The protocol for the `ListUptimeCheckIps` request.
message ListUptimeCheckIpsRequest {
  // The maximum number of results to return in a single response. The server
  // may further constrain the maximum number of results returned in a single
  // page. If the page_size is <=0, the server will decide the number of results
  // to be returned.
  // NOTE: this field is not yet implemented
  int32 page_size = 2;

  // If this field is not empty then it must contain the `nextPageToken` value
  // returned by a previous call to this method.  Using this field causes the
  // method to return more results from the previous method call.
  // NOTE: this field is not yet implemented
  string page_token = 3;
}

// The protocol for the `ListUptimeCheckIps` response.
message ListUptimeCheckIpsResponse {
  // The returned list of IP addresses (including region and location) that the
  // checkers run from.
  repeated UptimeCheckIp uptime_check_ips = 1;

  // This field represents the pagination token to retrieve the next page of
  // results. If the value is empty, it means no further results for the
  // request. To retrieve the next page of results, the value of the
  // next_page_token is passed to the subsequent List method call (in the
  // request message's page_token field).
  // NOTE: this field is not yet implemented
  string next_page_token = 2;
}
