diff --git a/typescript/src/start_script.ts b/typescript/src/start_script.ts index a04abf744..a2c490dd7 100755 --- a/typescript/src/start_script.ts +++ b/typescript/src/start_script.ts @@ -70,7 +70,6 @@ const commonProtoPath = argv.commonProtoPath || GOOGLE_GAX_PROTOS_DIR; // run protoc command to generate client library const cliPath = path.join(__dirname, 'cli.js'); const protocCommand = [ - `-I${commonProtoPath}`, `--plugin=protoc-gen-typescript_gapic=${cliPath}`, `--typescript_gapic_out=${outputDir}`, ]; @@ -89,6 +88,7 @@ if (mainServiceName) { } protocCommand.push(...protoDirsArg); protocCommand.push(...protoFiles); +protocCommand.push(`-I${commonProtoPath}`); try { execFileSync(`protoc`, protocCommand, { stdio: 'inherit' }); } catch (err) { diff --git a/typescript/test/protos/google/monitoring/v3/service.proto b/typescript/test/protos/google/monitoring/v3/service.proto new file mode 100644 index 000000000..82a953bde --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/service.proto @@ -0,0 +1,397 @@ +// 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.monitoring.v3; + +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/calendar_period.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 = "ServiceMonitoringProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// A `Service` is a discrete, autonomous, and network-accessible unit, designed +// to solve an individual concern +// ([Wikipedia](https://en.wikipedia.org/wiki/Service-orientation)). In +// Stackdriver Monitoring, a `Service` acts as the root resource under which +// operational aspects of the service are accessible. +message Service { + option (google.api.resource) = { + type: "monitoring.googleapis.com/Service" + pattern: "projects/{project}/services/{service}" + pattern: "organizations/{organization}/services/{service}" + pattern: "folders/{folder}/services/{service}" + pattern: "*" + }; + + // Custom view of service telemetry. Currently a place-holder pending final + // design. + message Custom { + + } + + // App Engine service. Learn more at https://cloud.google.com/appengine. + message AppEngine { + // The ID of the App Engine module underlying this service. Corresponds to + // the `module_id` resource label in the `gae_app` monitored resource: + // https://cloud.google.com/monitoring/api/resources#tag_gae_app + string module_id = 1; + } + + // Cloud Endpoints service. Learn more at https://cloud.google.com/endpoints. + message CloudEndpoints { + // The name of the Cloud Endpoints service underlying this service. + // Corresponds to the `service` resource label in the `api` monitored + // resource: https://cloud.google.com/monitoring/api/resources#tag_api + string service = 1; + } + + // Istio service. Learn more at http://istio.io. + message ClusterIstio { + // The location of the Kubernetes cluster in which this Istio service is + // defined. Corresponds to the `location` resource label in `k8s_cluster` + // resources. + string location = 1; + + // The name of the Kubernetes cluster in which this Istio service is + // defined. Corresponds to the `cluster_name` resource label in + // `k8s_cluster` resources. + string cluster_name = 2; + + // The namespace of the Istio service underlying this service. Corresponds + // to the `destination_service_namespace` metric label in Istio metrics. + string service_namespace = 3; + + // The name of the Istio service underlying this service. Corresponds to the + // `destination_service_name` metric label in Istio metrics. + string service_name = 4; + } + + // Configuration for how to query telemetry on a Service. + message Telemetry { + // The full name of the resource that defines this service. Formatted as + // described in https://cloud.google.com/apis/design/resource_names. + string resource_name = 1; + } + + // Resource name for this Service. Of the form + // `projects/{project_id}/services/{service_id}`. + string name = 1; + + // Name used for UI elements listing this Service. + string display_name = 2; + + // REQUIRED. Service-identifying atoms specifying the underlying service. + oneof identifier { + // Custom service type. + Custom custom = 6; + + // Type used for App Engine services. + AppEngine app_engine = 7; + + // Type used for Cloud Endpoints services. + CloudEndpoints cloud_endpoints = 8; + + // Type used for Istio services that live in a Kubernetes cluster. + ClusterIstio cluster_istio = 9; + } + + // Configuration for how to query telemetry on a Service. + Telemetry telemetry = 13; +} + +// A Service-Level Objective (SLO) describes a level of desired good service. It +// consists of a service-level indicator (SLI), a performance goal, and a period +// over which the objective is to be evaluated against that goal. The SLO can +// use SLIs defined in a number of different manners. Typical SLOs might include +// "99% of requests in each rolling week have latency below 200 milliseconds" or +// "99.5% of requests in each calendar month return successfully." +message ServiceLevelObjective { + option (google.api.resource) = { + type: "monitoring.googleapis.com/ServiceLevelObjective" + pattern: "projects/{project}/services/{service}/serviceLevelObjectives/{service_level_objective}" + pattern: "organizations/{organization}/services/{service}/serviceLevelObjectives/{service_level_objective}" + pattern: "folders/{folder}/services/{service}/serviceLevelObjectives/{service_level_objective}" + pattern: "*" + history: ORIGINALLY_SINGLE_PATTERN + }; + + // `ServiceLevelObjective.View` determines what form of + // `ServiceLevelObjective` is returned from `GetServiceLevelObjective`, + // `ListServiceLevelObjectives`, and `ListServiceLevelObjectiveVersions` RPCs. + enum View { + // Same as FULL. + VIEW_UNSPECIFIED = 0; + + // Return the embedded `ServiceLevelIndicator` in the form in which it was + // defined. If it was defined using a `BasicSli`, return that `BasicSli`. + FULL = 2; + + // For `ServiceLevelIndicator`s using `BasicSli` articulation, instead + // return the `ServiceLevelIndicator` with its mode of computation fully + // spelled out as a `RequestBasedSli`. For `ServiceLevelIndicator`s using + // `RequestBasedSli` or `WindowsBasedSli`, return the + // `ServiceLevelIndicator` as it was provided. + EXPLICIT = 1; + } + + // Resource name for this `ServiceLevelObjective`. + // Of the form + // `projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}`. + string name = 1; + + // Name used for UI elements listing this SLO. + string display_name = 11; + + // The definition of good service, used to measure and calculate the quality + // of the `Service`'s performance with respect to a single aspect of service + // quality. + ServiceLevelIndicator service_level_indicator = 3; + + // The fraction of service that must be good in order for this objective to be + // met. `0 < goal <= 0.999`. + double goal = 4; + + // The time period over which the objective will be evaluated. + oneof period { + // A rolling time period, semantically "in the past ``". + // Must be an integer multiple of 1 day no larger than 30 days. + google.protobuf.Duration rolling_period = 5; + + // A calendar period, semantically "since the start of the current + // ``". At this time, only `DAY`, `WEEK`, `FORTNIGHT`, and + // `MONTH` are supported. + google.type.CalendarPeriod calendar_period = 6; + } +} + +// A Service-Level Indicator (SLI) describes the "performance" of a service. For +// some services, the SLI is well-defined. In such cases, the SLI can be +// described easily by referencing the well-known SLI and providing the needed +// parameters. Alternatively, a "custom" SLI can be defined with a query to the +// underlying metric store. An SLI is defined to be `good_service / +// total_service` over any queried time interval. The value of performance +// always falls into the range `0 <= performance <= 1`. A custom SLI describes +// how to compute this ratio, whether this is by dividing values from a pair of +// time series, cutting a `Distribution` into good and bad counts, or counting +// time windows in which the service complies with a criterion. For separation +// of concerns, a single Service-Level Indicator measures performance for only +// one aspect of service quality, such as fraction of successful queries or +// fast-enough queries. +message ServiceLevelIndicator { + // Service level indicators can be grouped by whether the "unit" of service + // being measured is based on counts of good requests or on counts of good + // time windows + oneof type { + // Basic SLI on a well-known service type. + BasicSli basic_sli = 4; + + // Request-based SLIs + RequestBasedSli request_based = 1; + + // Windows-based SLIs + WindowsBasedSli windows_based = 2; + } +} + +// An SLI measuring performance on a well-known service type. Performance will +// be computed on the basis of pre-defined metrics. The type of the +// `service_resource` determines the metrics to use and the +// `service_resource.labels` and `metric_labels` are used to construct a +// monitoring filter to filter that metric down to just the data relevant to +// this service. +message BasicSli { + // Future parameters for the availability SLI. + message AvailabilityCriteria { + + } + + // Parameters for a latency threshold SLI. + message LatencyCriteria { + // Good service is defined to be the count of requests made to this service + // that return in no more than `threshold`. + google.protobuf.Duration threshold = 3; + } + + // OPTIONAL: The set of RPCs to which this SLI is relevant. Telemetry from + // other methods will not be used to calculate performance for this SLI. If + // omitted, this SLI applies to all the Service's methods. For service types + // that don't support breaking down by method, setting this field will result + // in an error. + repeated string method = 7; + + // OPTIONAL: The set of locations to which this SLI is relevant. Telemetry + // from other locations will not be used to calculate performance for this + // SLI. If omitted, this SLI applies to all locations in which the Service has + // activity. For service types that don't support breaking down by location, + // setting this field will result in an error. + repeated string location = 8; + + // OPTIONAL: The set of API versions to which this SLI is relevant. Telemetry + // from other API versions will not be used to calculate performance for this + // SLI. If omitted, this SLI applies to all API versions. For service types + // that don't support breaking down by version, setting this field will result + // in an error. + repeated string version = 9; + + // This SLI can be evaluated on the basis of availability or latency. + oneof sli_criteria { + // Good service is defined to be the count of requests made to this service + // that return successfully. + AvailabilityCriteria availability = 2; + + // Good service is defined to be the count of requests made to this service + // that are fast enough with respect to `latency.threshold`. + LatencyCriteria latency = 3; + } +} + +// Range of numerical values, inclusive of `min` and exclusive of `max`. If the +// open range "< range.max" is desired, set `range.min = -infinity`. If the open +// range ">= range.min" is desired, set `range.max = infinity`. +message Range { + // Range minimum. + double min = 1; + + // Range maximum. + double max = 2; +} + +// Service Level Indicators for which atomic units of service are counted +// directly. +message RequestBasedSli { + // The means to compute a ratio of `good_service` to `total_service`. + oneof method { + // `good_total_ratio` is used when the ratio of `good_service` to + // `total_service` is computed from two `TimeSeries`. + TimeSeriesRatio good_total_ratio = 1; + + // `distribution_cut` is used when `good_service` is a count of values + // aggregated in a `Distribution` that fall into a good range. The + // `total_service` is the total count of all values aggregated in the + // `Distribution`. + DistributionCut distribution_cut = 3; + } +} + +// A `TimeSeriesRatio` specifies two `TimeSeries` to use for computing the +// `good_service / total_service` ratio. The specified `TimeSeries` must have +// `ValueType = DOUBLE` or `ValueType = INT64` and must have `MetricKind = +// DELTA` or `MetricKind = CUMULATIVE`. The `TimeSeriesRatio` must specify +// exactly two of good, bad, and total, and the relationship `good_service + +// bad_service = total_service` will be assumed. +message TimeSeriesRatio { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` quantifying good service provided. Must have + // `ValueType = DOUBLE` or `ValueType = INT64` and must have `MetricKind = + // DELTA` or `MetricKind = CUMULATIVE`. + string good_service_filter = 4; + + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` quantifying bad service, either demanded service + // that was not provided or demanded service that was of inadequate quality. + // Must have `ValueType = DOUBLE` or `ValueType = INT64` and must have + // `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. + string bad_service_filter = 5; + + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` quantifying total demanded service. Must have + // `ValueType = DOUBLE` or `ValueType = INT64` and must have `MetricKind = + // DELTA` or `MetricKind = CUMULATIVE`. + string total_service_filter = 6; +} + +// A `DistributionCut` defines a `TimeSeries` and thresholds used for measuring +// good service and total service. The `TimeSeries` must have `ValueType = +// DISTRIBUTION` and `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. The +// computed `good_service` will be the count of values x in the `Distribution` +// such that `range.min <= x < range.max`. +message DistributionCut { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` aggregating values. Must have `ValueType = + // DISTRIBUTION` and `MetricKind = DELTA` or `MetricKind = CUMULATIVE`. + string distribution_filter = 4; + + // Range of values considered "good." For a one-sided range, set one bound to + // an infinite value. + Range range = 5; +} + +// A `WindowsBasedSli` defines `good_service` as the count of time windows for +// which the provided service was of good quality. Criteria for determining +// if service was good are embedded in the `window_criterion`. +message WindowsBasedSli { + // A `PerformanceThreshold` is used when each window is good when that window + // has a sufficiently high `performance`. + message PerformanceThreshold { + // The means, either a request-based SLI or a basic SLI, by which to compute + // performance over a window. + oneof type { + // `RequestBasedSli` to evaluate to judge window quality. + RequestBasedSli performance = 1; + + // `BasicSli` to evaluate to judge window quality. + BasicSli basic_sli_performance = 3; + } + + // If window `performance >= threshold`, the window is counted as good. + double threshold = 2; + } + + // A `MetricRange` is used when each window is good when the value x of a + // single `TimeSeries` satisfies `range.min <= x < range.max`. The provided + // `TimeSeries` must have `ValueType = INT64` or `ValueType = DOUBLE` and + // `MetricKind = GAUGE`. + message MetricRange { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying the `TimeSeries` to use for evaluating window quality. + string time_series = 1; + + // Range of values considered "good." For a one-sided range, set one bound + // to an infinite value. + Range range = 4; + } + + // The criterion to use for evaluating window goodness. + oneof window_criterion { + // A [monitoring filter](https://cloud.google.com/monitoring/api/v3/filters) + // specifying a `TimeSeries` with `ValueType = BOOL`. The window is good if + // any `true` values appear in the window. + string good_bad_metric_filter = 5; + + // A window is good if its `performance` is high enough. + PerformanceThreshold good_total_ratio_threshold = 2; + + // A window is good if the metric's value is in a good range, averaged + // across returned streams. + MetricRange metric_mean_in_range = 6; + + // A window is good if the metric's value is in a good range, summed across + // returned streams. + MetricRange metric_sum_in_range = 7; + } + + // Duration over which window quality is evaluated. Must be an integer + // fraction of a day and at least `60s`. + google.protobuf.Duration window_period = 4; +} diff --git a/typescript/test/protos/google/monitoring/v3/service_service.proto b/typescript/test/protos/google/monitoring/v3/service_service.proto new file mode 100644 index 000000000..5b9c096a0 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/service_service.proto @@ -0,0 +1,337 @@ +// 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.monitoring.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/service.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 = "ServiceMonitoringServiceProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The Stackdriver Monitoring Service-Oriented Monitoring API has endpoints for +// managing and querying aspects of a workspace's services. These include the +// `Service`'s monitored resources, its Service-Level Objectives, and a taxonomy +// of categorized Health Metrics. +service ServiceMonitoringService { + option (google.api.default_host) = "monitoring.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/monitoring," + "https://www.googleapis.com/auth/monitoring.read"; + + // Create a `Service`. + rpc CreateService(CreateServiceRequest) returns (Service) { + option (google.api.http) = { + post: "/v3/{parent=*/*}/services" + body: "service" + }; + option (google.api.method_signature) = "parent,service"; + } + + // Get the named `Service`. + rpc GetService(GetServiceRequest) returns (Service) { + option (google.api.http) = { + get: "/v3/{name=*/*/services/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List `Service`s for this workspace. + rpc ListServices(ListServicesRequest) returns (ListServicesResponse) { + option (google.api.http) = { + get: "/v3/{parent=*/*}/services" + }; + option (google.api.method_signature) = "parent"; + } + + // Update this `Service`. + rpc UpdateService(UpdateServiceRequest) returns (Service) { + option (google.api.http) = { + patch: "/v3/{service.name=*/*/services/*}" + body: "service" + }; + option (google.api.method_signature) = "service"; + } + + // Soft delete this `Service`. + rpc DeleteService(DeleteServiceRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=*/*/services/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Create a `ServiceLevelObjective` for the given `Service`. + rpc CreateServiceLevelObjective(CreateServiceLevelObjectiveRequest) returns (ServiceLevelObjective) { + option (google.api.http) = { + post: "/v3/{parent=*/*/services/*}/serviceLevelObjectives" + body: "service_level_objective" + }; + option (google.api.method_signature) = "parent,service_level_objective"; + } + + // Get a `ServiceLevelObjective` by name. + rpc GetServiceLevelObjective(GetServiceLevelObjectiveRequest) returns (ServiceLevelObjective) { + option (google.api.http) = { + get: "/v3/{name=*/*/services/*/serviceLevelObjectives/*}" + }; + option (google.api.method_signature) = "name"; + } + + // List the `ServiceLevelObjective`s for the given `Service`. + rpc ListServiceLevelObjectives(ListServiceLevelObjectivesRequest) returns (ListServiceLevelObjectivesResponse) { + option (google.api.http) = { + get: "/v3/{parent=*/*/services/*}/serviceLevelObjectives" + }; + option (google.api.method_signature) = "parent"; + } + + // Update the given `ServiceLevelObjective`. + rpc UpdateServiceLevelObjective(UpdateServiceLevelObjectiveRequest) returns (ServiceLevelObjective) { + option (google.api.http) = { + patch: "/v3/{service_level_objective.name=*/*/services/*/serviceLevelObjectives/*}" + body: "service_level_objective" + }; + option (google.api.method_signature) = "service_level_objective"; + } + + // Delete the given `ServiceLevelObjective`. + rpc DeleteServiceLevelObjective(DeleteServiceLevelObjectiveRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v3/{name=*/*/services/*/serviceLevelObjectives/*}" + }; + option (google.api.method_signature) = "name"; + } +} + +// The `CreateService` request. +message CreateServiceRequest { + // Required. Resource name of the parent workspace. + // Of the form `projects/{project_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/Service" + } + ]; + + // Optional. The Service id to use for this Service. If omitted, an id will be + // generated instead. Must match the pattern [a-z0-9\-]+ + string service_id = 3; + + // Required. The `Service` to create. + Service service = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The `GetService` request. +message GetServiceRequest { + // Required. Resource name of the `Service`. + // Of the form `projects/{project_id}/services/{service_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Service" + } + ]; +} + +// The `ListServices` request. +message ListServicesRequest { + // Required. Resource name of the parent `Workspace`. + // Of the form `projects/{project_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/Service" + } + ]; + + // A filter specifying what `Service`s to return. The filter currently + // supports the following fields: + // + // - `identifier_case` + // - `app_engine.module_id` + // - `cloud_endpoints.service` + // - `cluster_istio.location` + // - `cluster_istio.cluster_name` + // - `cluster_istio.service_namespace` + // - `cluster_istio.service_name` + // + // `identifier_case` refers to which option in the identifier oneof is + // populated. For example, the filter `identifier_case = "CUSTOM"` would match + // all services with a value for the `custom` field. Valid options are + // "CUSTOM", "APP_ENGINE", "CLOUD_ENDPOINTS", and "CLUSTER_ISTIO". + string filter = 2; + + // A non-negative number that is the maximum number of results to return. + // When 0, use default page size. + 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 additional results from the previous method call. + string page_token = 4; +} + +// The `ListServices` response. +message ListServicesResponse { + // The `Service`s matching the specified filter. + repeated Service services = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `UpdateService` request. +message UpdateServiceRequest { + // Required. The `Service` to draw updates from. + // The given `name` specifies the resource to update. + Service service = 1 [(google.api.field_behavior) = REQUIRED]; + + // A set of field paths defining which fields to use for the update. + google.protobuf.FieldMask update_mask = 2; +} + +// The `DeleteService` request. +message DeleteServiceRequest { + // Required. Resource name of the `Service` to delete. + // Of the form `projects/{project_id}/services/{service_id}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Service" + } + ]; +} + +// The `CreateServiceLevelObjective` request. +message CreateServiceLevelObjectiveRequest { + // Required. Resource name of the parent `Service`. + // Of the form `projects/{project_id}/services/{service_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Service" + } + ]; + + // Optional. The ServiceLevelObjective id to use for this + // ServiceLevelObjective. If omitted, an id will be generated instead. Must + // match the pattern [a-z0-9\-]+ + string service_level_objective_id = 3; + + // Required. The `ServiceLevelObjective` to create. + // The provided `name` will be respected if no `ServiceLevelObjective` exists + // with this name. + ServiceLevelObjective service_level_objective = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// The `GetServiceLevelObjective` request. +message GetServiceLevelObjectiveRequest { + // Required. Resource name of the `ServiceLevelObjective` to get. + // Of the form + // `projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/ServiceLevelObjective" + } + ]; + + // View of the `ServiceLevelObjective` to return. If `DEFAULT`, return the + // `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the + // `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the + // `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. + ServiceLevelObjective.View view = 2; +} + +// The `ListServiceLevelObjectives` request. +message ListServiceLevelObjectivesRequest { + // Required. Resource name of the parent `Service`. + // Of the form `projects/{project_id}/services/{service_id}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/Service" + } + ]; + + // A filter specifying what `ServiceLevelObjective`s to return. + string filter = 2; + + // A non-negative number that is the maximum number of results to return. + // When 0, use default page size. + 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 additional results from the previous method call. + string page_token = 4; + + // View of the `ServiceLevelObjective`s to return. If `DEFAULT`, return each + // `ServiceLevelObjective` as originally defined. If `EXPLICIT` and the + // `ServiceLevelObjective` is defined in terms of a `BasicSli`, replace the + // `BasicSli` with a `RequestBasedSli` spelling out how the SLI is computed. + ServiceLevelObjective.View view = 5; +} + +// The `ListServiceLevelObjectives` response. +message ListServiceLevelObjectivesResponse { + // The `ServiceLevelObjective`s matching the specified filter. + repeated ServiceLevelObjective service_level_objectives = 1; + + // If there are more results than have been returned, then this field is set + // to a non-empty value. To see the additional results, + // use that value as `pageToken` in the next call to this method. + string next_page_token = 2; +} + +// The `UpdateServiceLevelObjective` request. +message UpdateServiceLevelObjectiveRequest { + // Required. The `ServiceLevelObjective` to draw updates from. + // The given `name` specifies the resource to update. + ServiceLevelObjective service_level_objective = 1 [(google.api.field_behavior) = REQUIRED]; + + // A set of field paths defining which fields to use for the update. + google.protobuf.FieldMask update_mask = 2; +} + +// The `DeleteServiceLevelObjective` request. +message DeleteServiceLevelObjectiveRequest { + // Required. Resource name of the `ServiceLevelObjective` to delete. + // Of the form + // `projects/{project_id}/services/{service_id}/serviceLevelObjectives/{slo_name}`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/ServiceLevelObjective" + } + ]; +} diff --git a/typescript/test/protos/google/monitoring/v3/span_context.proto b/typescript/test/protos/google/monitoring/v3/span_context.proto new file mode 100644 index 000000000..cbcb8f72e --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/span_context.proto @@ -0,0 +1,43 @@ +// 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.monitoring.v3; + +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 = "SpanContextProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The context of a span, attached to google.api.Distribution.Exemplars +// in google.api.Distribution values during aggregation. +// +// It contains the name of a span with format: +// projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] +message SpanContext { + // The resource name of the span in the following format: + // + // projects/[PROJECT_ID]/traces/[TRACE_ID]/spans/[SPAN_ID] + // + // [TRACE_ID] is a unique identifier for a trace within a project; + // it is a 32-character hexadecimal encoding of a 16-byte array. + // + // [SPAN_ID] is a unique identifier for a span within a trace; it + // is a 16-character hexadecimal encoding of an 8-byte array. + string span_name = 1; +} diff --git a/typescript/test/protos/google/monitoring/v3/uptime.proto b/typescript/test/protos/google/monitoring/v3/uptime.proto new file mode 100644 index 000000000..7cb4947d5 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/uptime.proto @@ -0,0 +1,350 @@ +// 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.monitoring.v3; + +import "google/api/monitored_resource.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.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 = "UptimeProto"; +option java_package = "com.google.monitoring.v3"; +option php_namespace = "Google\\Cloud\\Monitoring\\V3"; + +// The regions from which an Uptime check can be run. +enum UptimeCheckRegion { + // Default value if no region is specified. Will result in Uptime checks + // running from all regions. + REGION_UNSPECIFIED = 0; + + // Allows checks to run from locations within the United States of America. + USA = 1; + + // Allows checks to run from locations within the continent of Europe. + EUROPE = 2; + + // Allows checks to run from locations within the continent of South + // America. + SOUTH_AMERICA = 3; + + // Allows checks to run from locations within the Asia Pacific area (ex: + // Singapore). + ASIA_PACIFIC = 4; +} + +// An internal checker allows Uptime checks to run on private/internal GCP +// resources. +message InternalChecker { + option deprecated = true; + + // Operational states for an internal checker. + enum State { + // An internal checker should never be in the unspecified state. + UNSPECIFIED = 0; + + // The checker is being created, provisioned, and configured. A checker in + // this state can be returned by `ListInternalCheckers` or + // `GetInternalChecker`, as well as by examining the [long running + // Operation](https://cloud.google.com/apis/design/design_patterns#long_running_operations) + // that created it. + CREATING = 1; + + // The checker is running and available for use. A checker in this state + // can be returned by `ListInternalCheckers` or `GetInternalChecker` as + // well as by examining the [long running + // Operation](https://cloud.google.com/apis/design/design_patterns#long_running_operations) + // that created it. + // If a checker is being torn down, it is neither visible nor usable, so + // there is no "deleting" or "down" state. + RUNNING = 2; + } + + // A unique resource name for this InternalChecker. The format is: + // + // `projects/[PROJECT_ID]/internalCheckers/[INTERNAL_CHECKER_ID]`. + // + // `[PROJECT_ID]` is the Stackdriver Workspace project for the + // Uptime check config associated with the internal checker. + string name = 1; + + // The checker's human-readable name. The display name + // should be unique within a Stackdriver Workspace in order to make it easier + // to identify; however, uniqueness is not enforced. + string display_name = 2; + + // The [GCP VPC network](https://cloud.google.com/vpc/docs/vpc) where the + // internal resource lives (ex: "default"). + string network = 3; + + // The GCP zone the Uptime check should egress from. Only respected for + // internal Uptime checks, where internal_network is specified. + string gcp_zone = 4; + + // The GCP project ID where the internal checker lives. Not necessary + // the same as the Workspace project. + string peer_project_id = 6; + + // The current operational state of the internal checker. + State state = 7; +} + +// This message configures which resources and services to monitor for +// availability. +message UptimeCheckConfig { + option (google.api.resource) = { + type: "monitoring.googleapis.com/UptimeCheckConfig" + pattern: "projects/{project}/uptimeCheckConfigs/{uptime_check_config}" + pattern: "organizations/{organization}/uptimeCheckConfigs/{uptime_check_config}" + pattern: "folders/{folder}/uptimeCheckConfigs/{uptime_check_config}" + pattern: "*" + }; + + // The resource submessage for group checks. It can be used instead of a + // monitored resource, when multiple resources are being monitored. + message ResourceGroup { + // The group of resources being monitored. Should be only the `[GROUP_ID]`, + // and not the full-path `projects/[PROJECT_ID]/groups/[GROUP_ID]`. + string group_id = 1; + + // The resource type of the group members. + GroupResourceType resource_type = 2; + } + + // Information involved in an HTTP/HTTPS Uptime check request. + message HttpCheck { + // The authentication parameters to provide to the specified resource or + // URL that requires a username and password. Currently, only + // [Basic HTTP authentication](https://tools.ietf.org/html/rfc7617) is + // supported in Uptime checks. + message BasicAuthentication { + // The username to use when authenticating with the HTTP server. + string username = 1; + + // The password to use when authenticating with the HTTP server. + string password = 2; + } + + // If `true`, use HTTPS instead of HTTP to run the check. + bool use_ssl = 1; + + // Optional (defaults to "/"). The path to the page against which to run + // the check. Will be combined with the `host` (specified within the + // `monitored_resource`) and `port` to construct the full URL. If the + // provided path does not begin with "/", a "/" will be prepended + // automatically. + string path = 2; + + // Optional (defaults to 80 when `use_ssl` is `false`, and 443 when + // `use_ssl` is `true`). The TCP port on the HTTP server against which to + // run the check. Will be combined with host (specified within the + // `monitored_resource`) and `path` to construct the full URL. + int32 port = 3; + + // The authentication information. Optional when creating an HTTP check; + // defaults to empty. + BasicAuthentication auth_info = 4; + + // Boolean specifiying whether to encrypt the header information. + // Encryption should be specified for any headers related to authentication + // that you do not wish to be seen when retrieving the configuration. The + // server will be responsible for encrypting the headers. + // On Get/List calls, if `mask_headers` is set to `true` then the headers + // will be obscured with `******.` + bool mask_headers = 5; + + // The list of headers to send as part of the Uptime check request. + // If two headers have the same key and different values, they should + // be entered as a single header, with the value being a comma-separated + // list of all the desired values as described at + // https://www.w3.org/Protocols/rfc2616/rfc2616.txt (page 31). + // Entering two separate headers with the same key in a Create call will + // cause the first to be overwritten by the second. + // The maximum number of headers allowed is 100. + map headers = 6; + + // Boolean specifying whether to include SSL certificate validation as a + // part of the Uptime check. Only applies to checks where + // `monitored_resource` is set to `uptime_url`. If `use_ssl` is `false`, + // setting `validate_ssl` to `true` has no effect. + bool validate_ssl = 7; + } + + // Information required for a TCP Uptime check request. + message TcpCheck { + // The TCP port on the server against which to run the check. Will be + // combined with host (specified within the `monitored_resource`) to + // construct the full URL. Required. + int32 port = 1; + } + + // Optional. Used to perform content matching. This allows matching based on + // substrings and regular expressions, together with their negations. Only the + // first 4 MB of an HTTP or HTTPS check's response (and the first + // 1 MB of a TCP check's response) are examined for purposes of content + // matching. + message ContentMatcher { + // Options to perform content matching. + enum ContentMatcherOption { + // No content matcher type specified (maintained for backward + // compatibility, but deprecated for future use). + // Treated as `CONTAINS_STRING`. + CONTENT_MATCHER_OPTION_UNSPECIFIED = 0; + + // Selects substring matching. The match succeeds if the output contains + // the `content` string. This is the default value for checks without + // a `matcher` option, or where the value of `matcher` is + // `CONTENT_MATCHER_OPTION_UNSPECIFIED`. + CONTAINS_STRING = 1; + + // Selects negation of substring matching. The match succeeds if the + // output does _NOT_ contain the `content` string. + NOT_CONTAINS_STRING = 2; + + // Selects regular-expression matching. The match succeeds of the output + // matches the regular expression specified in the `content` string. + MATCHES_REGEX = 3; + + // Selects negation of regular-expression matching. The match succeeds if + // the output does _NOT_ match the regular expression specified in the + // `content` string. + NOT_MATCHES_REGEX = 4; + } + + // String or regex content to match. Maximum 1024 bytes. An empty `content` + // string indicates no content matching is to be performed. + string content = 1; + + // The type of content matcher that will be applied to the server output, + // compared to the `content` string when the check is run. + ContentMatcherOption matcher = 2; + } + + // A unique resource name for this Uptime check configuration. The format is: + // + // `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + // + // This field should be omitted when creating the Uptime check configuration; + // on create, the resource name is assigned by the server and included in the + // response. + string name = 1; + + // A human-friendly name for the Uptime check configuration. The display name + // should be unique within a Stackdriver Workspace in order to make it easier + // to identify; however, uniqueness is not enforced. Required. + string display_name = 2; + + // The resource the check is checking. Required. + oneof resource { + // The [monitored + // resource](https://cloud.google.com/monitoring/api/resources) associated + // with the configuration. + // The following monitored resource types are supported for Uptime checks: + // `uptime_url`, + // `gce_instance`, + // `gae_app`, + // `aws_ec2_instance`, + // `aws_elb_load_balancer` + google.api.MonitoredResource monitored_resource = 3; + + // The group resource associated with the configuration. + ResourceGroup resource_group = 4; + } + + // The type of Uptime check request. + oneof check_request_type { + // Contains information needed to make an HTTP or HTTPS check. + HttpCheck http_check = 5; + + // Contains information needed to make a TCP check. + TcpCheck tcp_check = 6; + } + + // How often, in seconds, the Uptime check is performed. + // Currently, the only supported values are `60s` (1 minute), `300s` + // (5 minutes), `600s` (10 minutes), and `900s` (15 minutes). Optional, + // defaults to `60s`. + google.protobuf.Duration period = 7; + + // The maximum amount of time to wait for the request to complete (must be + // between 1 and 60 seconds). Required. + google.protobuf.Duration timeout = 8; + + // The content that is expected to appear in the data returned by the target + // server against which the check is run. Currently, only the first entry + // in the `content_matchers` list is supported, and additional entries will + // be ignored. This field is optional and should only be specified if a + // content match is required as part of the/ Uptime check. + repeated ContentMatcher content_matchers = 9; + + // The list of regions from which the check will be run. + // Some regions contain one location, and others contain more than one. + // If this field is specified, enough regions must be provided to include a + // minimum of 3 locations. Not specifying this field will result in Uptime + // checks running from all available regions. + repeated UptimeCheckRegion selected_regions = 10; + + // If this is `true`, then checks are made only from the 'internal_checkers'. + // If it is `false`, then checks are made only from the 'selected_regions'. + // It is an error to provide 'selected_regions' when is_internal is `true`, + // or to provide 'internal_checkers' when is_internal is `false`. + bool is_internal = 15 [deprecated = true]; + + // The internal checkers that this check will egress from. If `is_internal` is + // `true` and this list is empty, the check will egress from all the + // InternalCheckers configured for the project that owns this + // `UptimeCheckConfig`. + repeated InternalChecker internal_checkers = 14 [deprecated = true]; +} + +// The supported resource types that can be used as values of +// `group_resource.resource_type`. +// `INSTANCE` includes `gce_instance` and `aws_ec2_instance` resource types. +// The resource types `gae_app` and `uptime_url` are not valid here because +// group checks on App Engine modules and URLs are not allowed. +enum GroupResourceType { + // Default value (not valid). + RESOURCE_TYPE_UNSPECIFIED = 0; + + // A group of instances from Google Cloud Platform (GCP) or + // Amazon Web Services (AWS). + INSTANCE = 1; + + // A group of Amazon ELB load balancers. + AWS_ELB_LOAD_BALANCER = 2; +} + +// Contains the region, location, and list of IP +// addresses where checkers in the location run from. +message UptimeCheckIp { + // A broad region category in which the IP address is located. + UptimeCheckRegion region = 1; + + // A more specific location within the region that typically encodes + // a particular city/town/metro (and its containing state/province or country) + // within the broader umbrella region category. + string location = 2; + + // The IP address from which the Uptime check originates. This is a fully + // specified IP address (not an IP address range). Most IP addresses, as of + // this publication, are in IPv4 format; however, one should not rely on the + // IP addresses being in IPv4 format indefinitely, and should support + // interpreting this field in either IPv4 or IPv6 format. + string ip_address = 3; +} diff --git a/typescript/test/protos/google/monitoring/v3/uptime_service.proto b/typescript/test/protos/google/monitoring/v3/uptime_service.proto new file mode 100644 index 000000000..9c7bf7961 --- /dev/null +++ b/typescript/test/protos/google/monitoring/v3/uptime_service.proto @@ -0,0 +1,237 @@ +// 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.monitoring.v3; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/monitoring/v3/uptime.proto"; +import "google/protobuf/duration.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 { + option (google.api.default_host) = "monitoring.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/monitoring," + "https://www.googleapis.com/auth/monitoring.read"; + + // 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" + }; + option (google.api.method_signature) = "parent"; + } + + // Gets a single Uptime check configuration. + rpc GetUptimeCheckConfig(GetUptimeCheckConfigRequest) returns (UptimeCheckConfig) { + option (google.api.http) = { + get: "/v3/{name=projects/*/uptimeCheckConfigs/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Creates a new Uptime check configuration. + rpc CreateUptimeCheckConfig(CreateUptimeCheckConfigRequest) returns (UptimeCheckConfig) { + option (google.api.http) = { + post: "/v3/{parent=projects/*}/uptimeCheckConfigs" + body: "uptime_check_config" + }; + option (google.api.method_signature) = "parent,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" + }; + option (google.api.method_signature) = "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/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Returns the list of IP addresses that checkers run from + rpc ListUptimeCheckIps(ListUptimeCheckIpsRequest) returns (ListUptimeCheckIpsResponse) { + option (google.api.http) = { + get: "/v3/uptimeCheckIps" + }; + } +} + +// The protocol for the `ListUptimeCheckConfigs` request. +message ListUptimeCheckConfigsRequest { + // Required. The project whose Uptime check configurations are listed. The format + // is `projects/[PROJECT_ID]`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/UptimeCheckConfig" + } + ]; + + // 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 { + // Required. The Uptime check configuration to retrieve. The format + // is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/UptimeCheckConfig" + } + ]; +} + +// The protocol for the `CreateUptimeCheckConfig` request. +message CreateUptimeCheckConfigRequest { + // Required. The project in which to create the Uptime check. The format + // is `projects/[PROJECT_ID]`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "monitoring.googleapis.com/UptimeCheckConfig" + } + ]; + + // Required. The new Uptime check configuration. + UptimeCheckConfig uptime_check_config = 2 [(google.api.field_behavior) = REQUIRED]; +} + +// 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 [(google.api.field_behavior) = REQUIRED]; +} + +// The protocol for the `DeleteUptimeCheckConfig` request. +message DeleteUptimeCheckConfigRequest { + // Required. The Uptime check configuration to delete. The format + // is `projects/[PROJECT_ID]/uptimeCheckConfigs/[UPTIME_CHECK_ID]`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "monitoring.googleapis.com/UptimeCheckConfig" + } + ]; +} + +// 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; +} diff --git a/typescript/test/testdata/monitoring/.gitignore.baseline b/typescript/test/testdata/monitoring/.gitignore.baseline new file mode 100644 index 000000000..5d32b2378 --- /dev/null +++ b/typescript/test/testdata/monitoring/.gitignore.baseline @@ -0,0 +1,14 @@ +**/*.log +**/node_modules +.coverage +coverage +.nyc_output +docs/ +out/ +build/ +system-test/secrets.js +system-test/*key.json +*.lock +.DS_Store +package-lock.json +__pycache__ diff --git a/typescript/test/testdata/monitoring/.jsdoc.js.baseline b/typescript/test/testdata/monitoring/.jsdoc.js.baseline new file mode 100644 index 000000000..65303f3e4 --- /dev/null +++ b/typescript/test/testdata/monitoring/.jsdoc.js.baseline @@ -0,0 +1,48 @@ +/*! + * Copyright 2019 Google LLC. All Rights Reserved. + * + * 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. + */ + +'use strict'; + +module.exports = { + opts: { + package: './package.json', + template: './node_modules/jsdoc-fresh', + recurse: true, + verbose: true, + destination: './docs/' + }, + plugins: [ + 'plugins/markdown', + 'jsdoc-region-tag' + ], + source: { + include: [ + 'build/src', + 'protos' + ], + includePattern: '\\.js$' + }, + templates: { + copyright: 'Copyright 2019 Google, LLC.', + includeDate: false, + sourceFiles: false, + systemName: 'Monitoring', + theme: 'lumen' + }, + markdown: { + idInHeadings: true + } +}; diff --git a/typescript/test/testdata/monitoring/.mocharc.json.baseline b/typescript/test/testdata/monitoring/.mocharc.json.baseline new file mode 100644 index 000000000..670c5e2c2 --- /dev/null +++ b/typescript/test/testdata/monitoring/.mocharc.json.baseline @@ -0,0 +1,5 @@ +{ + "enable-source-maps": true, + "throw-deprecation": true, + "timeout": 10000 +} diff --git a/typescript/test/testdata/monitoring/linkinator.config.json.baseline b/typescript/test/testdata/monitoring/linkinator.config.json.baseline new file mode 100644 index 000000000..b555215ca --- /dev/null +++ b/typescript/test/testdata/monitoring/linkinator.config.json.baseline @@ -0,0 +1,8 @@ +{ + "recurse": true, + "skip": [ + "https://codecov.io/gh/googleapis/", + "www.googleapis.com", + "img.shields.io" + ] +} diff --git a/typescript/test/testdata/monitoring/package.json.baseline b/typescript/test/testdata/monitoring/package.json.baseline new file mode 100644 index 000000000..ff68a18c3 --- /dev/null +++ b/typescript/test/testdata/monitoring/package.json.baseline @@ -0,0 +1,49 @@ +{ + "name": "monitoring", + "version": "0.1.0", + "description": "Monitoring client for Node.js", + "repository": "googleapis/nodejs-monitoring", + "license": "Apache-2.0", + "author": "Google LLC", + "files": [ + "build/src", + "build/protos" + ], + "main": "build/src/index.js", + "scripts": { + "clean": "gts clean", + "compile": "tsc -p . && cp -r protos build/", + "compile-protos": "compileProtos src", + "docs": "jsdoc -c .jsdoc.js", + "docs-test": "linkinator docs", + "fix": "gts fix", + "lint": "gts check", + "predocs-test": "npm run docs", + "prepare": "npm run compile-protos && npm run compile", + "system-test": "c8 mocha build/system-test", + "test": "c8 mocha build/test" + }, + "dependencies": { + "google-gax": "^1.12.0" + }, + "devDependencies": { + "@types/mocha": "^5.2.5", + "@types/node": "^12.0.0", + "c8": "^6.0.0", + "gts": "^1.0.0", + "jsdoc": "^3.5.5", + "jsdoc-fresh": "^1.0.1", + "jsdoc-region-tag": "^1.0.2", + "linkinator": "^1.5.0", + "mocha": "^6.0.0", + "pack-n-play": "^1.0.0-2", + "null-loader": "^3.0.0", + "ts-loader": "^6.2.1", + "typescript": "~3.6.4", + "webpack": "^4.41.2", + "webpack-cli": "^3.3.10" + }, + "engines": { + "node": ">=8.13.0" + } +} diff --git a/typescript/test/testdata/monitoring/proto.list.baseline b/typescript/test/testdata/monitoring/proto.list.baseline new file mode 100644 index 000000000..f2467e62f --- /dev/null +++ b/typescript/test/testdata/monitoring/proto.list.baseline @@ -0,0 +1,17 @@ +google/api/http.proto +google/protobuf/descriptor.proto +google/api/annotations.proto +google/api/client.proto +google/api/field_behavior.proto +google/api/label.proto +google/api/launch_stage.proto +google/protobuf/struct.proto +google/api/monitored_resource.proto +google/api/resource.proto +google/protobuf/duration.proto +google/protobuf/timestamp.proto +google/type/calendar_period.proto +google/monitoring/v3/service.proto +google/protobuf/empty.proto +google/protobuf/field_mask.proto +google/monitoring/v3/service_service.proto diff --git a/typescript/test/testdata/monitoring/src/index.ts.baseline b/typescript/test/testdata/monitoring/src/index.ts.baseline new file mode 100644 index 000000000..dc5a358b0 --- /dev/null +++ b/typescript/test/testdata/monitoring/src/index.ts.baseline @@ -0,0 +1,23 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import * as v3 from './v3'; +export {v3}; +// For compatibility with JavaScript libraries we need to provide this default export: +// tslint:disable-next-line no-default-export +export default {v3}; diff --git a/typescript/test/testdata/monitoring/src/v3/index.ts.baseline b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline new file mode 100644 index 000000000..c8ae05a7a --- /dev/null +++ b/typescript/test/testdata/monitoring/src/v3/index.ts.baseline @@ -0,0 +1,19 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline new file mode 100644 index 000000000..d6aa6493c --- /dev/null +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.js.baseline @@ -0,0 +1,26 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + +/* eslint-disable node/no-missing-require, no-unused-vars */ +const monitoring = require('monitoring'); + +function main() { +} + +main(); diff --git a/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline new file mode 100644 index 000000000..cf2e349fd --- /dev/null +++ b/typescript/test/testdata/monitoring/system-test/fixtures/sample/src/index.ts.baseline @@ -0,0 +1,24 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import {} from 'monitoring'; + +function main() { +} + +main(); diff --git a/typescript/test/testdata/monitoring/system-test/install.ts.baseline b/typescript/test/testdata/monitoring/system-test/install.ts.baseline new file mode 100644 index 000000000..140852a85 --- /dev/null +++ b/typescript/test/testdata/monitoring/system-test/install.ts.baseline @@ -0,0 +1,49 @@ +// 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 +// +// https://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. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + +import { packNTest } from 'pack-n-play'; +import { readFileSync } from 'fs'; +import { describe, it } from 'mocha'; + +describe('typescript consumer tests', () => { + + it('should have correct type signature for typescript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.ts').toString() + } + }; + await packNTest(options); // will throw upon error. + }); + + it('should have correct type signature for javascript users', async function() { + this.timeout(300000); + const options = { + packageDir: process.cwd(), // path to your module. + sample: { + description: 'typescript based user can use the type definitions', + ts: readFileSync('./system-test/fixtures/sample/src/index.js').toString() + } + }; + await packNTest(options); // will throw upon error. + }); + +}); diff --git a/typescript/test/testdata/monitoring/tsconfig.json.baseline b/typescript/test/testdata/monitoring/tsconfig.json.baseline new file mode 100644 index 000000000..613d35597 --- /dev/null +++ b/typescript/test/testdata/monitoring/tsconfig.json.baseline @@ -0,0 +1,19 @@ +{ + "extends": "./node_modules/gts/tsconfig-google.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build", + "resolveJsonModule": true, + "lib": [ + "es2016", + "dom" + ] + }, + "include": [ + "src/*.ts", + "src/**/*.ts", + "test/*.ts", + "test/**/*.ts", + "system-test/*.ts" + ] +} diff --git a/typescript/test/testdata/monitoring/tslint.json.baseline b/typescript/test/testdata/monitoring/tslint.json.baseline new file mode 100644 index 000000000..617dc975b --- /dev/null +++ b/typescript/test/testdata/monitoring/tslint.json.baseline @@ -0,0 +1,3 @@ +{ + "extends": "gts/tslint.json" +} diff --git a/typescript/test/testdata/monitoring/webpack.config.js.baseline b/typescript/test/testdata/monitoring/webpack.config.js.baseline new file mode 100644 index 000000000..c38f3d48b --- /dev/null +++ b/typescript/test/testdata/monitoring/webpack.config.js.baseline @@ -0,0 +1,64 @@ +// 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 +// +// https://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. + +const path = require('path'); + +module.exports = { + entry: './src/index.ts', + output: { + library: 'monitoring', + filename: './monitoring.js', + }, + node: { + child_process: 'empty', + fs: 'empty', + crypto: 'empty', + }, + resolve: { + alias: { + '../../../package.json': path.resolve(__dirname, 'package.json'), + }, + extensions: ['.js', '.json', '.ts'], + }, + module: { + rules: [ + { + test: /\.tsx?$/, + use: 'ts-loader', + exclude: /node_modules/ + }, + { + test: /node_modules[\\/]@grpc[\\/]grpc-js/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]grpc/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]retry-request/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]https?-proxy-agent/, + use: 'null-loader' + }, + { + test: /node_modules[\\/]gtoken/, + use: 'null-loader' + }, + ], + }, + mode: 'production', +}; diff --git a/typescript/test/unit/monitor.ts b/typescript/test/unit/monitor.ts new file mode 100644 index 000000000..3637f1728 --- /dev/null +++ b/typescript/test/unit/monitor.ts @@ -0,0 +1,83 @@ +import * as assert from 'assert'; +import { execSync } from 'child_process'; +import * as fs from 'fs'; +import { describe, it } from 'mocha'; +import * as path from 'path'; +import * as rimraf from 'rimraf'; + +import { equalToBaseline } from '../util'; + +const cwd = process.cwd(); + +const START_SCRIPT = path.join( + process.cwd(), + 'build', + 'src', + 'start_script.js' +); + +const OUTPUT_DIR = path.join(cwd, '.test-out-monitoring'); +const GOOGLE_GAX_PROTOS_DIR = path.join( + cwd, + 'node_modules', + 'google-gax', + 'protos' +); + +const PROTOS_DIR = path.join(cwd, 'build', 'test', 'protos'); +const MONITOR_PROTO_FILE = path.join( + PROTOS_DIR, + 'google', + 'monitoring', + 'v3', + 'service_service.proto' +); + +const BASELINE_DIR = path.join( + __dirname, + '..', + '..', + '..', + 'typescript', + 'test', + 'testdata' +); + +const BASELINE_DIR_MONITOR = path.join(BASELINE_DIR, 'monitoring'); +const SRCDIR = path.join(cwd, 'build', 'src'); +const CLI = path.join(SRCDIR, 'cli.js'); +const PLUGIN = path.join(SRCDIR, 'protoc-gen-typescript_gapic'); + +describe('MonitoringGenerateTest', () => { + describe('Generate Client library', () => { + it('Generated proto list should have same output with baseline.', function() { + this.timeout(10000); + if (fs.existsSync(OUTPUT_DIR)) { + rimraf.sync(OUTPUT_DIR); + } + fs.mkdirSync(OUTPUT_DIR); + + if (fs.existsSync(PLUGIN)) { + rimraf.sync(PLUGIN); + } + fs.copyFileSync(CLI, PLUGIN); + process.env['PATH'] = SRCDIR + path.delimiter + process.env['PATH']; + + try { + execSync(`chmod +x ${PLUGIN}`); + } catch (err) { + console.warn(`Failed to chmod +x ${PLUGIN}: ${err}. Ignoring...`); + } + + execSync( + 'node ' + + START_SCRIPT + + ` -I${PROTOS_DIR}` + + ` ${MONITOR_PROTO_FILE}` + + ` --output_dir=${OUTPUT_DIR}` + + ` --main_service=monitoring` + ); + assert(equalToBaseline(OUTPUT_DIR, BASELINE_DIR_MONITOR)); + }); + }); +});