From 41ea89046f6c6ae198bd992160715c16b60b55fd Mon Sep 17 00:00:00 2001 From: Anthonios Partheniou Date: Wed, 2 Jun 2021 05:30:38 -0400 Subject: [PATCH 01/10] chore: delete unused protos (#85) --- google/cloud/trace_v1/proto/trace.proto | 305 ----------------- google/cloud/trace_v2/proto/trace.proto | 378 ---------------------- google/cloud/trace_v2/proto/tracing.proto | 79 ----- 3 files changed, 762 deletions(-) delete mode 100644 google/cloud/trace_v1/proto/trace.proto delete mode 100644 google/cloud/trace_v2/proto/trace.proto delete mode 100644 google/cloud/trace_v2/proto/tracing.proto diff --git a/google/cloud/trace_v1/proto/trace.proto b/google/cloud/trace_v1/proto/trace.proto deleted file mode 100644 index d3948fa1..00000000 --- a/google/cloud/trace_v1/proto/trace.proto +++ /dev/null @@ -1,305 +0,0 @@ -// 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.devtools.cloudtrace.v1; - -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.Trace.V1"; -option go_package = "google.golang.org/genproto/googleapis/devtools/cloudtrace/v1;cloudtrace"; -option java_multiple_files = true; -option java_outer_classname = "TraceProto"; -option java_package = "com.google.devtools.cloudtrace.v1"; -option php_namespace = "Google\\Cloud\\Trace\\V1"; -option ruby_package = "Google::Cloud::Trace::V1"; - -// This file describes an API for collecting and viewing traces and spans -// within a trace. A Trace is a collection of spans corresponding to a single -// operation or set of operations for an application. A span is an individual -// timed event which forms a node of the trace tree. Spans for a single trace -// may span multiple services. -service TraceService { - option (google.api.default_host) = "cloudtrace.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/trace.append," - "https://www.googleapis.com/auth/trace.readonly"; - - // Returns of a list of traces that match the specified filter conditions. - rpc ListTraces(ListTracesRequest) returns (ListTracesResponse) { - option (google.api.http) = { - get: "/v1/projects/{project_id}/traces" - }; - option (google.api.method_signature) = "project_id"; - } - - // Gets a single trace by its ID. - rpc GetTrace(GetTraceRequest) returns (Trace) { - option (google.api.http) = { - get: "/v1/projects/{project_id}/traces/{trace_id}" - }; - option (google.api.method_signature) = "project_id,trace_id"; - } - - // Sends new traces to Stackdriver Trace or updates existing traces. If the ID - // of a trace that you send matches that of an existing trace, any fields - // in the existing trace and its spans are overwritten by the provided values, - // and any new fields provided are merged with the existing trace data. If the - // ID does not match, a new trace is created. - rpc PatchTraces(PatchTracesRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - patch: "/v1/projects/{project_id}/traces" - body: "traces" - }; - option (google.api.method_signature) = "project_id,traces"; - } -} - -// A trace describes how long it takes for an application to perform an -// operation. It consists of a set of spans, each of which represent a single -// timed event within the operation. -message Trace { - // Project ID of the Cloud project where the trace data is stored. - string project_id = 1; - - // Globally unique identifier for the trace. This identifier is a 128-bit - // numeric value formatted as a 32-byte hex string. For example, - // `382d4f4c6b7bb2f4a972559d9085001d`. - string trace_id = 2; - - // Collection of spans in the trace. - repeated TraceSpan spans = 3; -} - -// List of new or updated traces. -message Traces { - // List of traces. - repeated Trace traces = 1; -} - -// A span represents a single timed event within a trace. Spans can be nested -// and form a trace tree. Often, a trace contains a root span that describes the -// end-to-end latency of an operation and, optionally, one or more subspans for -// its suboperations. Spans do not need to be contiguous. There may be gaps -// between spans in a trace. -message TraceSpan { - // Type of span. Can be used to specify additional relationships between spans - // in addition to a parent/child relationship. - enum SpanKind { - // Unspecified. - SPAN_KIND_UNSPECIFIED = 0; - - // Indicates that the span covers server-side handling of an RPC or other - // remote network request. - RPC_SERVER = 1; - - // Indicates that the span covers the client-side wrapper around an RPC or - // other remote request. - RPC_CLIENT = 2; - } - - // Identifier for the span. Must be a 64-bit integer other than 0 and - // unique within a trace. For example, `2205310701640571284`. - fixed64 span_id = 1; - - // Distinguishes between spans generated in a particular context. For example, - // two spans with the same name may be distinguished using `RPC_CLIENT` - // and `RPC_SERVER` to identify queueing latency associated with the span. - SpanKind kind = 2; - - // Name of the span. Must be less than 128 bytes. The span name is sanitized - // and displayed in the Stackdriver Trace tool in the - // Google Cloud Platform Console. - // The name may be a method name or some other per-call site name. - // For the same executable and the same call point, a best practice is - // to use a consistent name, which makes it easier to correlate - // cross-trace spans. - string name = 3; - - // Start time of the span in nanoseconds from the UNIX epoch. - google.protobuf.Timestamp start_time = 4; - - // End time of the span in nanoseconds from the UNIX epoch. - google.protobuf.Timestamp end_time = 5; - - // Optional. ID of the parent span, if any. - fixed64 parent_span_id = 6 [(google.api.field_behavior) = OPTIONAL]; - - // Collection of labels associated with the span. Label keys must be less than - // 128 bytes. Label values must be less than 16 kilobytes (10MB for - // `/stacktrace` values). - // - // Some predefined label keys exist, or you may create your own. When creating - // your own, we recommend the following formats: - // - // * `/category/product/key` for agents of well-known products (e.g. - // `/db/mongodb/read_size`). - // * `short_host/path/key` for domain-specific keys (e.g. - // `foo.com/myproduct/bar`) - // - // Predefined labels include: - // - // * `/agent` - // * `/component` - // * `/error/message` - // * `/error/name` - // * `/http/client_city` - // * `/http/client_country` - // * `/http/client_protocol` - // * `/http/client_region` - // * `/http/host` - // * `/http/method` - // * `/http/path` - // * `/http/redirected_url` - // * `/http/request/size` - // * `/http/response/size` - // * `/http/route` - // * `/http/status_code` - // * `/http/url` - // * `/http/user_agent` - // * `/pid` - // * `/stacktrace` - // * `/tid` - map labels = 7; -} - -// The request message for the `ListTraces` method. All fields are required -// unless specified. -message ListTracesRequest { - // Type of data returned for traces in the list. - enum ViewType { - // Default is `MINIMAL` if unspecified. - VIEW_TYPE_UNSPECIFIED = 0; - - // Minimal view of the trace record that contains only the project - // and trace IDs. - MINIMAL = 1; - - // Root span view of the trace record that returns the root spans along - // with the minimal trace data. - ROOTSPAN = 2; - - // Complete view of the trace record that contains the actual trace data. - // This is equivalent to calling the REST `get` or RPC `GetTrace` method - // using the ID of each listed trace. - COMPLETE = 3; - } - - // Required. ID of the Cloud project where the trace data is stored. - string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Optional. Type of data returned for traces in the list. Default is - // `MINIMAL`. - ViewType view = 2 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Maximum number of traces to return. If not specified or <= 0, the - // implementation selects a reasonable value. The implementation may - // return fewer traces than the requested page size. - int32 page_size = 3 [(google.api.field_behavior) = OPTIONAL]; - - // Token identifying the page of results to return. If provided, use the - // value of the `next_page_token` field from a previous request. - string page_token = 4; - - // Start of the time interval (inclusive) during which the trace data was - // collected from the application. - google.protobuf.Timestamp start_time = 5; - - // End of the time interval (inclusive) during which the trace data was - // collected from the application. - google.protobuf.Timestamp end_time = 6; - - // Optional. A filter against labels for the request. - // - // By default, searches use prefix matching. To specify exact match, prepend - // a plus symbol (`+`) to the search term. - // Multiple terms are ANDed. Syntax: - // - // * `root:NAME_PREFIX` or `NAME_PREFIX`: Return traces where any root - // span starts with `NAME_PREFIX`. - // * `+root:NAME` or `+NAME`: Return traces where any root span's name is - // exactly `NAME`. - // * `span:NAME_PREFIX`: Return traces where any span starts with - // `NAME_PREFIX`. - // * `+span:NAME`: Return traces where any span's name is exactly - // `NAME`. - // * `latency:DURATION`: Return traces whose overall latency is - // greater or equal to than `DURATION`. Accepted units are nanoseconds - // (`ns`), milliseconds (`ms`), and seconds (`s`). Default is `ms`. For - // example, `latency:24ms` returns traces whose overall latency - // is greater than or equal to 24 milliseconds. - // * `label:LABEL_KEY`: Return all traces containing the specified - // label key (exact match, case-sensitive) regardless of the key:value - // pair's value (including empty values). - // * `LABEL_KEY:VALUE_PREFIX`: Return all traces containing the specified - // label key (exact match, case-sensitive) whose value starts with - // `VALUE_PREFIX`. Both a key and a value must be specified. - // * `+LABEL_KEY:VALUE`: Return all traces containing a key:value pair - // exactly matching the specified text. Both a key and a value must be - // specified. - // * `method:VALUE`: Equivalent to `/http/method:VALUE`. - // * `url:VALUE`: Equivalent to `/http/url:VALUE`. - string filter = 7 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Field used to sort the returned traces. - // Can be one of the following: - // - // * `trace_id` - // * `name` (`name` field of root span in the trace) - // * `duration` (difference between `end_time` and `start_time` fields of - // the root span) - // * `start` (`start_time` field of the root span) - // - // Descending order can be specified by appending `desc` to the sort field - // (for example, `name desc`). - // - // Only one sort field is permitted. - string order_by = 8 [(google.api.field_behavior) = OPTIONAL]; -} - -// The response message for the `ListTraces` method. -message ListTracesResponse { - // List of trace records as specified by the view parameter. - repeated Trace traces = 1; - - // If defined, indicates that there are more traces that match the request - // and that this value should be passed to the next request to continue - // retrieving additional traces. - string next_page_token = 2; -} - -// The request message for the `GetTrace` method. -message GetTraceRequest { - // Required. ID of the Cloud project where the trace data is stored. - string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. ID of the trace to return. - string trace_id = 2 [(google.api.field_behavior) = REQUIRED]; -} - -// The request message for the `PatchTraces` method. -message PatchTracesRequest { - // Required. ID of the Cloud project where the trace data is stored. - string project_id = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The body of the message. - Traces traces = 2 [(google.api.field_behavior) = REQUIRED]; -} diff --git a/google/cloud/trace_v2/proto/trace.proto b/google/cloud/trace_v2/proto/trace.proto deleted file mode 100644 index 66669aa6..00000000 --- a/google/cloud/trace_v2/proto/trace.proto +++ /dev/null @@ -1,378 +0,0 @@ -// 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.devtools.cloudtrace.v2; - -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/protobuf/timestamp.proto"; -import "google/protobuf/wrappers.proto"; -import "google/rpc/status.proto"; -import "google/api/annotations.proto"; - -option csharp_namespace = "Google.Cloud.Trace.V2"; -option go_package = "google.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace"; -option java_multiple_files = true; -option java_outer_classname = "TraceProto"; -option java_package = "com.google.devtools.cloudtrace.v2"; -option php_namespace = "Google\\Cloud\\Trace\\V2"; -option ruby_package = "Google::Cloud::Trace::V2"; - -// A span represents a single operation within a trace. Spans can be -// nested to form a trace tree. Often, a trace contains a root span -// that describes the end-to-end latency, and one or more subspans for -// its sub-operations. A trace can also contain multiple root spans, -// or none at all. Spans do not need to be contiguous—there may be -// gaps or overlaps between spans in a trace. -message Span { - option (google.api.resource) = { - type: "cloudtrace.googleapis.com/Span" - pattern: "projects/{project}/traces/{trace}/spans/{span}" - }; - - // A set of attributes, each in the format `[KEY]:[VALUE]`. - message Attributes { - // The set of attributes. Each attribute's key can be up to 128 bytes - // long. The value can be a string up to 256 bytes, a signed 64-bit integer, - // or the Boolean values `true` and `false`. For example: - // - // "/instance_id": { "string_value": { "value": "my-instance" } } - // "/http/request_bytes": { "int_value": 300 } - // "abc.com/myattribute": { "bool_value": false } - map attribute_map = 1; - - // The number of attributes that were discarded. Attributes can be discarded - // because their keys are too long or because there are too many attributes. - // If this value is 0 then all attributes are valid. - int32 dropped_attributes_count = 2; - } - - // A time-stamped annotation or message event in the Span. - message TimeEvent { - // Text annotation with a set of attributes. - message Annotation { - // A user-supplied message describing the event. The maximum length for - // the description is 256 bytes. - TruncatableString description = 1; - - // A set of attributes on the annotation. You can have up to 4 attributes - // per Annotation. - Attributes attributes = 2; - } - - // An event describing a message sent/received between Spans. - message MessageEvent { - // Indicates whether the message was sent or received. - enum Type { - // Unknown event type. - TYPE_UNSPECIFIED = 0; - - // Indicates a sent message. - SENT = 1; - - // Indicates a received message. - RECEIVED = 2; - } - - // Type of MessageEvent. Indicates whether the message was sent or - // received. - Type type = 1; - - // An identifier for the MessageEvent's message that can be used to match - // SENT and RECEIVED MessageEvents. It is recommended to be unique within - // a Span. - int64 id = 2; - - // The number of uncompressed bytes sent or received. - int64 uncompressed_size_bytes = 3; - - // The number of compressed bytes sent or received. If missing assumed to - // be the same size as uncompressed. - int64 compressed_size_bytes = 4; - } - - // The timestamp indicating the time the event occurred. - google.protobuf.Timestamp time = 1; - - // A `TimeEvent` can contain either an `Annotation` object or a - // `MessageEvent` object, but not both. - oneof value { - // Text annotation with a set of attributes. - Annotation annotation = 2; - - // An event describing a message sent/received between Spans. - MessageEvent message_event = 3; - } - } - - // A collection of `TimeEvent`s. A `TimeEvent` is a time-stamped annotation - // on the span, consisting of either user-supplied key:value pairs, or - // details of a message sent/received between Spans. - message TimeEvents { - // A collection of `TimeEvent`s. - repeated TimeEvent time_event = 1; - - // The number of dropped annotations in all the included time events. - // If the value is 0, then no annotations were dropped. - int32 dropped_annotations_count = 2; - - // The number of dropped message events in all the included time events. - // If the value is 0, then no message events were dropped. - int32 dropped_message_events_count = 3; - } - - // A pointer from the current span to another span in the same trace or in a - // different trace. For example, this can be used in batching operations, - // where a single batch handler processes multiple requests from different - // traces or when the handler receives a request from a different project. - message Link { - // The relationship of the current span relative to the linked span: child, - // parent, or unspecified. - enum Type { - // The relationship of the two spans is unknown. - TYPE_UNSPECIFIED = 0; - - // The linked span is a child of the current span. - CHILD_LINKED_SPAN = 1; - - // The linked span is a parent of the current span. - PARENT_LINKED_SPAN = 2; - } - - // The [TRACE_ID] for a trace within a project. - string trace_id = 1; - - // The [SPAN_ID] for a span within a trace. - string span_id = 2; - - // The relationship of the current span relative to the linked span. - Type type = 3; - - // A set of attributes on the link. You have have up to 32 attributes per - // link. - Attributes attributes = 4; - } - - // A collection of links, which are references from this span to a span - // in the same or different trace. - message Links { - // A collection of links. - repeated Link link = 1; - - // The number of dropped links after the maximum size was enforced. If - // this value is 0, then no links were dropped. - int32 dropped_links_count = 2; - } - - // Type of span. Can be used to specify additional relationships between spans - // in addition to a parent/child relationship. - enum SpanKind { - // Unspecified. Do NOT use as default. - // Implementations MAY assume SpanKind.INTERNAL to be default. - SPAN_KIND_UNSPECIFIED = 0; - - // Indicates that the span is used internally. Default value. - INTERNAL = 1; - - // Indicates that the span covers server-side handling of an RPC or other - // remote network request. - SERVER = 2; - - // Indicates that the span covers the client-side wrapper around an RPC or - // other remote request. - CLIENT = 3; - - // Indicates that the span describes producer sending a message to a broker. - // Unlike client and server, there is no direct critical path latency - // relationship between producer and consumer spans (e.g. publishing a - // message to a pubsub service). - PRODUCER = 4; - - // Indicates that the span describes consumer receiving a message from a - // broker. Unlike client and server, there is no direct critical path - // latency relationship between producer and consumer spans (e.g. receiving - // a message from a pubsub service subscription). - CONSUMER = 5; - } - - // Required. 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 name = 1 [(google.api.field_behavior) = REQUIRED]; - - // Required. The [SPAN_ID] portion of the span's resource name. - string span_id = 2 [(google.api.field_behavior) = REQUIRED]; - - // The [SPAN_ID] of this span's parent span. If this is a root span, - // then this field must be empty. - string parent_span_id = 3; - - // Required. A description of the span's operation (up to 128 bytes). - // Stackdriver Trace displays the description in the - // Google Cloud Platform Console. - // For example, the display name can be a qualified method name or a file name - // and a line number where the operation is called. A best practice is to use - // the same display name within an application and at the same call point. - // This makes it easier to correlate spans in different traces. - TruncatableString display_name = 4 [(google.api.field_behavior) = REQUIRED]; - - // Required. The start time of the span. On the client side, this is the time kept by - // the local machine where the span execution starts. On the server side, this - // is the time when the server's application handler starts running. - google.protobuf.Timestamp start_time = 5 [(google.api.field_behavior) = REQUIRED]; - - // Required. The end time of the span. On the client side, this is the time kept by - // the local machine where the span execution ends. On the server side, this - // is the time when the server application handler stops running. - google.protobuf.Timestamp end_time = 6 [(google.api.field_behavior) = REQUIRED]; - - // A set of attributes on the span. You can have up to 32 attributes per - // span. - Attributes attributes = 7; - - // Stack trace captured at the start of the span. - StackTrace stack_trace = 8; - - // A set of time events. You can have up to 32 annotations and 128 message - // events per span. - TimeEvents time_events = 9; - - // Links associated with the span. You can have up to 128 links per Span. - Links links = 10; - - // Optional. The final status for this span. - google.rpc.Status status = 11 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Set this parameter to indicate whether this span is in - // the same process as its parent. If you do not set this parameter, - // Stackdriver Trace is unable to take advantage of this helpful - // information. - google.protobuf.BoolValue same_process_as_parent_span = 12 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. The number of child spans that were generated while this span - // was active. If set, allows implementation to detect missing child spans. - google.protobuf.Int32Value child_span_count = 13 [(google.api.field_behavior) = OPTIONAL]; - - // Optional. Distinguishes between spans generated in a particular context. For example, - // two spans with the same name may be distinguished using `CLIENT` (caller) - // and `SERVER` (callee) to identify an RPC call. - SpanKind span_kind = 14 [(google.api.field_behavior) = OPTIONAL]; -} - -// The allowed types for [VALUE] in a `[KEY]:[VALUE]` attribute. -message AttributeValue { - // The type of the value. - oneof value { - // A string up to 256 bytes long. - TruncatableString string_value = 1; - - // A 64-bit signed integer. - int64 int_value = 2; - - // A Boolean value represented by `true` or `false`. - bool bool_value = 3; - } -} - -// A call stack appearing in a trace. -message StackTrace { - // Represents a single stack frame in a stack trace. - message StackFrame { - // The fully-qualified name that uniquely identifies the function or - // method that is active in this frame (up to 1024 bytes). - TruncatableString function_name = 1; - - // An un-mangled function name, if `function_name` is - // [mangled](http://www.avabodh.com/cxxin/namemangling.html). The name can - // be fully-qualified (up to 1024 bytes). - TruncatableString original_function_name = 2; - - // The name of the source file where the function call appears (up to 256 - // bytes). - TruncatableString file_name = 3; - - // The line number in `file_name` where the function call appears. - int64 line_number = 4; - - // The column number where the function call appears, if available. - // This is important in JavaScript because of its anonymous functions. - int64 column_number = 5; - - // The binary module from where the code was loaded. - Module load_module = 6; - - // The version of the deployed source code (up to 128 bytes). - TruncatableString source_version = 7; - } - - // A collection of stack frames, which can be truncated. - message StackFrames { - // Stack frames in this call stack. - repeated StackFrame frame = 1; - - // The number of stack frames that were dropped because there - // were too many stack frames. - // If this value is 0, then no stack frames were dropped. - int32 dropped_frames_count = 2; - } - - // Stack frames in this stack trace. A maximum of 128 frames are allowed. - StackFrames stack_frames = 1; - - // The hash ID is used to conserve network bandwidth for duplicate - // stack traces within a single trace. - // - // Often multiple spans will have identical stack traces. - // The first occurrence of a stack trace should contain both the - // `stackFrame` content and a value in `stackTraceHashId`. - // - // Subsequent spans within the same request can refer - // to that stack trace by only setting `stackTraceHashId`. - int64 stack_trace_hash_id = 2; -} - -// Binary module. -message Module { - // For example: main binary, kernel modules, and dynamic libraries - // such as libc.so, sharedlib.so (up to 256 bytes). - TruncatableString module = 1; - - // A unique identifier for the module, usually a hash of its - // contents (up to 128 bytes). - TruncatableString build_id = 2; -} - -// Represents a string that might be shortened to a specified length. -message TruncatableString { - // The shortened string. For example, if the original string is 500 - // bytes long and the limit of the string is 128 bytes, then - // `value` contains the first 128 bytes of the 500-byte string. - // - // Truncation always happens on a UTF8 character boundary. If there - // are multi-byte characters in the string, then the length of the - // shortened string might be less than the size limit. - string value = 1; - - // The number of bytes removed from the original string. If this - // value is 0, then the string was not shortened. - int32 truncated_byte_count = 2; -} diff --git a/google/cloud/trace_v2/proto/tracing.proto b/google/cloud/trace_v2/proto/tracing.proto deleted file mode 100644 index a25a0dd7..00000000 --- a/google/cloud/trace_v2/proto/tracing.proto +++ /dev/null @@ -1,79 +0,0 @@ -// 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.devtools.cloudtrace.v2; - -import "google/api/annotations.proto"; -import "google/api/client.proto"; -import "google/api/field_behavior.proto"; -import "google/api/resource.proto"; -import "google/devtools/cloudtrace/v2/trace.proto"; -import "google/protobuf/empty.proto"; -import "google/protobuf/timestamp.proto"; - -option csharp_namespace = "Google.Cloud.Trace.V2"; -option go_package = "google.golang.org/genproto/googleapis/devtools/cloudtrace/v2;cloudtrace"; -option java_multiple_files = true; -option java_outer_classname = "TracingProto"; -option java_package = "com.google.devtools.cloudtrace.v2"; -option php_namespace = "Google\\Cloud\\Trace\\V2"; -option ruby_package = "Google::Cloud::Trace::V2"; - -// This file describes an API for collecting and viewing traces and spans -// within a trace. A Trace is a collection of spans corresponding to a single -// operation or set of operations for an application. A span is an individual -// timed event which forms a node of the trace tree. A single trace may -// contain span(s) from multiple services. -service TraceService { - option (google.api.default_host) = "cloudtrace.googleapis.com"; - option (google.api.oauth_scopes) = - "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/trace.append"; - - // Sends new spans to new or existing traces. You cannot update - // existing spans. - rpc BatchWriteSpans(BatchWriteSpansRequest) returns (google.protobuf.Empty) { - option (google.api.http) = { - post: "/v2/{name=projects/*}/traces:batchWrite" - body: "*" - }; - option (google.api.method_signature) = "name,spans"; - } - - // Creates a new span. - rpc CreateSpan(Span) returns (Span) { - option (google.api.http) = { - post: "/v2/{name=projects/*/traces/*/spans/*}" - body: "*" - }; - } -} - -// The request message for the `BatchWriteSpans` method. -message BatchWriteSpansRequest { - // Required. The name of the project where the spans belong. The format is - // `projects/[PROJECT_ID]`. - string name = 1 [ - (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference) = { - type: "cloudresourcemanager.googleapis.com/Project" - } - ]; - - // Required. A list of new spans. The span names must not match existing - // spans, or the results are undefined. - repeated Span spans = 2 [(google.api.field_behavior) = REQUIRED]; -} From 6f0bfad1ea11b550aa74a8fde51799bafa16f9d1 Mon Sep 17 00:00:00 2001 From: WhiteSource Renovate Date: Wed, 16 Jun 2021 15:14:02 +0200 Subject: [PATCH 02/10] chore(deps): update dependency google-cloud-trace to v1.2.0 (#89) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [google-cloud-trace](https://togithub.com/googleapis/python-trace) | `==1.1.0` -> `==1.2.0` | [![age](https://badges.renovateapi.com/packages/pypi/google-cloud-trace/1.2.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/google-cloud-trace/1.2.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/google-cloud-trace/1.2.0/compatibility-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/google-cloud-trace/1.2.0/confidence-slim/1.1.0)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes
googleapis/python-trace ### [`v1.2.0`](https://togithub.com/googleapis/python-trace/blob/master/CHANGELOG.md#​120-httpswwwgithubcomgoogleapispython-tracecomparev110v120-2021-05-27) [Compare Source](https://togithub.com/googleapis/python-trace/compare/v1.1.0...v1.2.0) ##### Features - add `from_service_account_info` ([e097a64](https://www.github.com/googleapis/python-trace/commit/e097a643c9584a50ae91b823f8dbd8df705001f6)) - add common resource path helpers ([#​70](https://www.github.com/googleapis/python-trace/issues/70)) ([e097a64](https://www.github.com/googleapis/python-trace/commit/e097a643c9584a50ae91b823f8dbd8df705001f6)) - support self-signed JWT flow for service accounts ([1055668](https://www.github.com/googleapis/python-trace/commit/105566818fe8f8930a8393ebfc827ef151b695df)) ##### Bug Fixes - add async client ([1055668](https://www.github.com/googleapis/python-trace/commit/105566818fe8f8930a8393ebfc827ef151b695df)) - **deps:** add packaging requirement ([#​84](https://www.github.com/googleapis/python-trace/issues/84)) ([792599f](https://www.github.com/googleapis/python-trace/commit/792599fc0e21f3e0d71acdaf9f0d4d6e3afabc5f)) - use correct retry deadlines ([e097a64](https://www.github.com/googleapis/python-trace/commit/e097a643c9584a50ae91b823f8dbd8df705001f6))
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻️ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/python-trace). --- samples/snippets/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index fe9f2237..efa3853c 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-trace==1.1.0 \ No newline at end of file +google-cloud-trace==1.2.0 \ No newline at end of file From 5f240d28bbbd949df9a6eb39de0e9cad948c89e2 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 17 Jun 2021 10:52:25 +0000 Subject: [PATCH 03/10] chore: new owl bot post processor docker image (#90) Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce --- .github/.OwlBot.lock.yaml | 2 +- docs/conf.py | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 4ef44149..ea06d395 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:c66ba3c8d7bc8566f47df841f98cd0097b28fff0b1864c86f5817f4c8c3e8600 \ No newline at end of file + digest: sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce diff --git a/docs/conf.py b/docs/conf.py index 349ba706..b6a01910 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -80,9 +80,9 @@ master_doc = "index" # General information about the project. -project = u"google-cloud-trace" -copyright = u"2019, Google" -author = u"Google APIs" +project = "google-cloud-trace" +copyright = "2019, Google" +author = "Google APIs" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -281,7 +281,7 @@ ( master_doc, "google-cloud-trace.tex", - u"google-cloud-trace Documentation", + "google-cloud-trace Documentation", author, "manual", ) @@ -313,13 +313,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ( - master_doc, - "google-cloud-trace", - u"google-cloud-trace Documentation", - [author], - 1, - ) + (master_doc, "google-cloud-trace", "google-cloud-trace Documentation", [author], 1,) ] # If true, show URL addresses after external links. @@ -335,7 +329,7 @@ ( master_doc, "google-cloud-trace", - u"google-cloud-trace Documentation", + "google-cloud-trace Documentation", author, "google-cloud-trace", "google-cloud-trace Library", From 5dcc16ca802dc2a8895389fabecd82e4ec739e54 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sat, 19 Jun 2021 01:46:08 +0000 Subject: [PATCH 04/10] docs: omit mention of Python 2.7 in 'CONTRIBUTING.rst' (#1127) (#91) Source-Link: https://github.com/googleapis/synthtool/commit/b91f129527853d5b756146a0b5044481fb4e09a8 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:b6169fc6a5207b11800a7c002d0c5c2bc6d82697185ca12e666f44031468cfcd --- .github/.OwlBot.lock.yaml | 2 +- CONTRIBUTING.rst | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index ea06d395..cc49c6a3 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:58c7342b0bccf85028100adaa3d856cb4a871c22ca9c01960d996e66c40548ce + digest: sha256:b6169fc6a5207b11800a7c002d0c5c2bc6d82697185ca12e666f44031468cfcd diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index de8d1d22..ef5507c1 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -69,7 +69,6 @@ We use `nox `__ to instrument our tests. - To test your changes, run unit tests with ``nox``:: - $ nox -s unit-2.7 $ nox -s unit-3.8 $ ... @@ -144,7 +143,6 @@ Running System Tests # Run all system tests $ nox -s system-3.8 - $ nox -s system-2.7 # Run a single system test $ nox -s system-3.8 -- -k @@ -152,9 +150,8 @@ Running System Tests .. note:: - System tests are only configured to run under Python 2.7 and - Python 3.8. For expediency, we do not run them in older versions - of Python 3. + System tests are only configured to run under Python 3.8. + For expediency, we do not run them in older versions of Python 3. This alone will not run the tests. You'll need to change some local auth settings and change some configuration in your project to From 3ff379fd4ebfcd2e184ff60697d218b9f46ee168 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Sun, 20 Jun 2021 01:00:23 +0000 Subject: [PATCH 05/10] chore: update precommit hook pre-commit/pre-commit-hooks to v4 (#1083) (#93) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [![WhiteSource Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [pre-commit/pre-commit-hooks](https://togithub.com/pre-commit/pre-commit-hooks) | repository | major | `v3.4.0` -> `v4.0.1` | --- ### Release Notes
pre-commit/pre-commit-hooks ### [`v4.0.1`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.1) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v4.0.0...v4.0.1) ##### Fixes - `check-shebang-scripts-are-executable` fix entry point. - [#​602](https://togithub.com/pre-commit/pre-commit-hooks/issues/602) issue by [@​Person-93](https://togithub.com/Person-93). - [#​603](https://togithub.com/pre-commit/pre-commit-hooks/issues/603) PR by [@​scop](https://togithub.com/scop). ### [`v4.0.0`](https://togithub.com/pre-commit/pre-commit-hooks/releases/v4.0.0) [Compare Source](https://togithub.com/pre-commit/pre-commit-hooks/compare/v3.4.0...v4.0.0) ##### Features - `check-json`: report duplicate keys. - [#​558](https://togithub.com/pre-commit/pre-commit-hooks/issues/558) PR by [@​AdityaKhursale](https://togithub.com/AdityaKhursale). - [#​554](https://togithub.com/pre-commit/pre-commit-hooks/issues/554) issue by [@​adamchainz](https://togithub.com/adamchainz). - `no-commit-to-branch`: add `main` to default blocked branches. - [#​565](https://togithub.com/pre-commit/pre-commit-hooks/issues/565) PR by [@​ndevenish](https://togithub.com/ndevenish). - `check-case-conflict`: check conflicts in directory names as well. - [#​575](https://togithub.com/pre-commit/pre-commit-hooks/issues/575) PR by [@​slsyy](https://togithub.com/slsyy). - [#​70](https://togithub.com/pre-commit/pre-commit-hooks/issues/70) issue by [@​andyjack](https://togithub.com/andyjack). - `check-vcs-permalinks`: forbid other branch names. - [#​582](https://togithub.com/pre-commit/pre-commit-hooks/issues/582) PR by [@​jack1142](https://togithub.com/jack1142). - [#​581](https://togithub.com/pre-commit/pre-commit-hooks/issues/581) issue by [@​jack1142](https://togithub.com/jack1142). - `check-shebang-scripts-are-executable`: new hook which ensures shebang'd scripts are executable. - [#​545](https://togithub.com/pre-commit/pre-commit-hooks/issues/545) PR by [@​scop](https://togithub.com/scop). ##### Fixes - `check-executables-have-shebangs`: Short circuit shebang lookup on windows. - [#​544](https://togithub.com/pre-commit/pre-commit-hooks/issues/544) PR by [@​scop](https://togithub.com/scop). - `requirements-txt-fixer`: Fix comments which have indentation - [#​549](https://togithub.com/pre-commit/pre-commit-hooks/issues/549) PR by [@​greshilov](https://togithub.com/greshilov). - [#​548](https://togithub.com/pre-commit/pre-commit-hooks/issues/548) issue by [@​greshilov](https://togithub.com/greshilov). - `pretty-format-json`: write to stdout using UTF-8 encoding. - [#​571](https://togithub.com/pre-commit/pre-commit-hooks/issues/571) PR by [@​jack1142](https://togithub.com/jack1142). - [#​570](https://togithub.com/pre-commit/pre-commit-hooks/issues/570) issue by [@​jack1142](https://togithub.com/jack1142). - Use more inclusive language. - [#​599](https://togithub.com/pre-commit/pre-commit-hooks/issues/599) PR by [@​asottile](https://togithub.com/asottile). ##### Breaking changes - Remove deprecated hooks: `flake8`, `pyflakes`, `autopep8-wrapper`. - [#​597](https://togithub.com/pre-commit/pre-commit-hooks/issues/597) PR by [@​asottile](https://togithub.com/asottile).
--- ### Configuration 📅 **Schedule**: At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻️ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box. --- This PR has been generated by [WhiteSource Renovate](https://renovate.whitesourcesoftware.com). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/synthtool). Source-Link: https://github.com/googleapis/synthtool/commit/333fd90856f1454380514bc59fc0936cdaf1c202 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3 --- .github/.OwlBot.lock.yaml | 2 +- .pre-commit-config.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index cc49c6a3..9602d540 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:b6169fc6a5207b11800a7c002d0c5c2bc6d82697185ca12e666f44031468cfcd + digest: sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4f00c7cf..62eb5a77 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ # See https://pre-commit.com/hooks.html for more hooks repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v3.4.0 + rev: v4.0.1 hooks: - id: trailing-whitespace - id: end-of-file-fixer From a4797a1d8249f53bdf666815011507783f8d1e45 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Mon, 21 Jun 2021 15:55:46 -0600 Subject: [PATCH 06/10] chore: add kokoro 3.9 config templates (#1128) (#95) fixes #907 Source-Link: https://github.com/googleapis/synthtool/commit/b0eb8a8b30b46a3c98d23c23107acb748c6601a1 Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 Co-authored-by: Owl Bot --- .github/.OwlBot.lock.yaml | 2 +- .kokoro/samples/python3.9/common.cfg | 40 +++++++++++++++++++++ .kokoro/samples/python3.9/continuous.cfg | 6 ++++ .kokoro/samples/python3.9/periodic-head.cfg | 11 ++++++ .kokoro/samples/python3.9/periodic.cfg | 6 ++++ .kokoro/samples/python3.9/presubmit.cfg | 6 ++++ 6 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .kokoro/samples/python3.9/common.cfg create mode 100644 .kokoro/samples/python3.9/continuous.cfg create mode 100644 .kokoro/samples/python3.9/periodic-head.cfg create mode 100644 .kokoro/samples/python3.9/periodic.cfg create mode 100644 .kokoro/samples/python3.9/presubmit.cfg diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 9602d540..0954585f 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:b8c131c558606d3cea6e18f8e87befbd448c1482319b0db3c5d5388fa6ea72e3 + digest: sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 diff --git a/.kokoro/samples/python3.9/common.cfg b/.kokoro/samples/python3.9/common.cfg new file mode 100644 index 00000000..56d95707 --- /dev/null +++ b/.kokoro/samples/python3.9/common.cfg @@ -0,0 +1,40 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Build logs will be here +action { + define_artifacts { + regex: "**/*sponge_log.xml" + } +} + +# Specify which tests to run +env_vars: { + key: "RUN_TESTS_SESSION" + value: "py-3.9" +} + +# Declare build specific Cloud project. +env_vars: { + key: "BUILD_SPECIFIC_GCLOUD_PROJECT" + value: "python-docs-samples-tests-py39" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-trace/.kokoro/test-samples.sh" +} + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker" +} + +# Download secrets for samples +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples" + +# Download trampoline resources. +gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" + +# Use the trampoline script to run in docker. +build_file: "python-trace/.kokoro/trampoline.sh" \ No newline at end of file diff --git a/.kokoro/samples/python3.9/continuous.cfg b/.kokoro/samples/python3.9/continuous.cfg new file mode 100644 index 00000000..a1c8d975 --- /dev/null +++ b/.kokoro/samples/python3.9/continuous.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.9/periodic-head.cfg b/.kokoro/samples/python3.9/periodic-head.cfg new file mode 100644 index 00000000..f9cfcd33 --- /dev/null +++ b/.kokoro/samples/python3.9/periodic-head.cfg @@ -0,0 +1,11 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} + +env_vars: { + key: "TRAMPOLINE_BUILD_FILE" + value: "github/python-pubsub/.kokoro/test-samples-against-head.sh" +} diff --git a/.kokoro/samples/python3.9/periodic.cfg b/.kokoro/samples/python3.9/periodic.cfg new file mode 100644 index 00000000..50fec964 --- /dev/null +++ b/.kokoro/samples/python3.9/periodic.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "False" +} \ No newline at end of file diff --git a/.kokoro/samples/python3.9/presubmit.cfg b/.kokoro/samples/python3.9/presubmit.cfg new file mode 100644 index 00000000..a1c8d975 --- /dev/null +++ b/.kokoro/samples/python3.9/presubmit.cfg @@ -0,0 +1,6 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +env_vars: { + key: "INSTALL_LIBRARY_FROM_SOURCE" + value: "True" +} \ No newline at end of file From e88837d7bc7ac180f87f4a5bb8a4cbd71f6e3449 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Wed, 23 Jun 2021 20:28:45 +0000 Subject: [PATCH 07/10] feat: add always_use_jwt_access (#96) ... chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0 Committer: @miraleung PiperOrigin-RevId: 380641501 Source-Link: https://github.com/googleapis/googleapis/commit/076f7e9f0b258bdb54338895d7251b202e8f0de3 Source-Link: https://github.com/googleapis/googleapis-gen/commit/27e4c88b4048e5f56508d4e1aa417d60a3380892 --- .coveragerc | 1 - .../services/trace_service/transports/base.py | 40 +++---- .../services/trace_service/transports/grpc.py | 7 +- .../trace_service/transports/grpc_asyncio.py | 7 +- .../services/trace_service/transports/base.py | 40 +++---- .../services/trace_service/transports/grpc.py | 7 +- .../trace_service/transports/grpc_asyncio.py | 7 +- setup.py | 2 +- testing/constraints-3.6.txt | 2 +- .../unit/gapic/trace_v1/test_trace_service.py | 106 +++--------------- .../unit/gapic/trace_v2/test_trace_service.py | 105 +++-------------- 11 files changed, 72 insertions(+), 252 deletions(-) diff --git a/.coveragerc b/.coveragerc index 054c95ee..073fbb53 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,7 +2,6 @@ branch = True [report] -fail_under = 100 show_missing = True omit = google/cloud/trace/__init__.py diff --git a/google/cloud/trace_v1/services/trace_service/transports/base.py b/google/cloud/trace_v1/services/trace_service/transports/base.py index 74e5a610..3c2b8a15 100644 --- a/google/cloud/trace_v1/services/trace_service/transports/base.py +++ b/google/cloud/trace_v1/services/trace_service/transports/base.py @@ -24,6 +24,7 @@ from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.trace_v1.types import trace from google.protobuf import empty_pb2 # type: ignore @@ -44,8 +45,6 @@ except pkg_resources.DistributionNotFound: # pragma: NO COVER _GOOGLE_AUTH_VERSION = None -_API_CORE_VERSION = google.api_core.__version__ - class TraceServiceTransport(abc.ABC): """Abstract transport class for TraceService.""" @@ -67,6 +66,7 @@ def __init__( scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, **kwargs, ) -> None: """Instantiate the transport. @@ -90,6 +90,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: @@ -118,13 +120,20 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) + # If the credentials is service account credentials, then always try to use self signed JWT. + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): + credentials = credentials.with_always_use_jwt_access(True) + # Save the credentials. self._credentials = credentials - # TODO(busunkim): These two class methods are in the base transport + # TODO(busunkim): This method is in the base transport # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-api-core - # and google-auth are increased. + # should be deleted once the minimum required versions of google-auth is increased. # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod @@ -145,27 +154,6 @@ def _get_scopes_kwargs( return scopes_kwargs - # TODO: Remove this function once google-api-core >= 1.26.0 is required - @classmethod - def _get_self_signed_jwt_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Union[Optional[Sequence[str]], str]]: - """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" - - self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} - - if _API_CORE_VERSION and ( - packaging.version.parse(_API_CORE_VERSION) - >= packaging.version.parse("1.26.0") - ): - self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES - self_signed_jwt_kwargs["scopes"] = scopes - self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST - else: - self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES - - return self_signed_jwt_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/trace_v1/services/trace_service/transports/grpc.py b/google/cloud/trace_v1/services/trace_service/transports/grpc.py index df75239d..737ceb5f 100644 --- a/google/cloud/trace_v1/services/trace_service/transports/grpc.py +++ b/google/cloud/trace_v1/services/trace_service/transports/grpc.py @@ -155,6 +155,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=True, ) if not self._grpc_channel: @@ -210,14 +211,14 @@ def create_channel( and ``credentials_file`` are passed. """ - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) diff --git a/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py b/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py index 6bc025e8..b57b0b91 100644 --- a/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py +++ b/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py @@ -84,14 +84,14 @@ def create_channel( aio.Channel: A gRPC AsyncIO channel object. """ - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) @@ -201,6 +201,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=True, ) if not self._grpc_channel: diff --git a/google/cloud/trace_v2/services/trace_service/transports/base.py b/google/cloud/trace_v2/services/trace_service/transports/base.py index 7fe0617c..afa0e665 100644 --- a/google/cloud/trace_v2/services/trace_service/transports/base.py +++ b/google/cloud/trace_v2/services/trace_service/transports/base.py @@ -24,6 +24,7 @@ from google.api_core import gapic_v1 # type: ignore from google.api_core import retry as retries # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.oauth2 import service_account # type: ignore from google.cloud.trace_v2.types import trace from google.cloud.trace_v2.types import tracing @@ -45,8 +46,6 @@ except pkg_resources.DistributionNotFound: # pragma: NO COVER _GOOGLE_AUTH_VERSION = None -_API_CORE_VERSION = google.api_core.__version__ - class TraceServiceTransport(abc.ABC): """Abstract transport class for TraceService.""" @@ -67,6 +66,7 @@ def __init__( scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, **kwargs, ) -> None: """Instantiate the transport. @@ -90,6 +90,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. """ # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: @@ -118,13 +120,20 @@ def __init__( **scopes_kwargs, quota_project_id=quota_project_id ) + # If the credentials is service account credentials, then always try to use self signed JWT. + if ( + always_use_jwt_access + and isinstance(credentials, service_account.Credentials) + and hasattr(service_account.Credentials, "with_always_use_jwt_access") + ): + credentials = credentials.with_always_use_jwt_access(True) + # Save the credentials. self._credentials = credentials - # TODO(busunkim): These two class methods are in the base transport + # TODO(busunkim): This method is in the base transport # to avoid duplicating code across the transport classes. These functions - # should be deleted once the minimum required versions of google-api-core - # and google-auth are increased. + # should be deleted once the minimum required versions of google-auth is increased. # TODO: Remove this function once google-auth >= 1.25.0 is required @classmethod @@ -145,27 +154,6 @@ def _get_scopes_kwargs( return scopes_kwargs - # TODO: Remove this function once google-api-core >= 1.26.0 is required - @classmethod - def _get_self_signed_jwt_kwargs( - cls, host: str, scopes: Optional[Sequence[str]] - ) -> Dict[str, Union[Optional[Sequence[str]], str]]: - """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" - - self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} - - if _API_CORE_VERSION and ( - packaging.version.parse(_API_CORE_VERSION) - >= packaging.version.parse("1.26.0") - ): - self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES - self_signed_jwt_kwargs["scopes"] = scopes - self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST - else: - self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES - - return self_signed_jwt_kwargs - def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { diff --git a/google/cloud/trace_v2/services/trace_service/transports/grpc.py b/google/cloud/trace_v2/services/trace_service/transports/grpc.py index 5badc0f6..5967fa93 100644 --- a/google/cloud/trace_v2/services/trace_service/transports/grpc.py +++ b/google/cloud/trace_v2/services/trace_service/transports/grpc.py @@ -156,6 +156,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=True, ) if not self._grpc_channel: @@ -211,14 +212,14 @@ def create_channel( and ``credentials_file`` are passed. """ - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) diff --git a/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py b/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py index 63dfacd1..54de3f6d 100644 --- a/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py +++ b/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py @@ -85,14 +85,14 @@ def create_channel( aio.Channel: A gRPC AsyncIO channel object. """ - self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) - return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, quota_project_id=quota_project_id, - **self_signed_jwt_kwargs, + default_scopes=cls.AUTH_SCOPES, + scopes=scopes, + default_host=cls.DEFAULT_HOST, **kwargs, ) @@ -202,6 +202,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, + always_use_jwt_access=True, ) if not self._grpc_channel: diff --git a/setup.py b/setup.py index 0403fd56..342eb933 100644 --- a/setup.py +++ b/setup.py @@ -29,7 +29,7 @@ # 'Development Status :: 5 - Production/Stable' release_status = "Development Status :: 5 - Production/Stable" dependencies = [ - "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", + "google-api-core[grpc] >= 1.26.0, <2.0.0dev", "proto-plus >= 1.4.0", "packaging >= 14.3", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 4aef616f..4fda4298 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -5,7 +5,7 @@ # # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 -google-api-core==1.22.2 +google-api-core==1.26.0 proto-plus==1.4.0 packaging==14.3 google-auth==1.24.0 # TODO: remove when google-auth>=1.25.0 si transitively required through google-api-core diff --git a/tests/unit/gapic/trace_v1/test_trace_service.py b/tests/unit/gapic/trace_v1/test_trace_service.py index 602c1ee4..7eaa80fd 100644 --- a/tests/unit/gapic/trace_v1/test_trace_service.py +++ b/tests/unit/gapic/trace_v1/test_trace_service.py @@ -35,9 +35,6 @@ from google.cloud.trace_v1.services.trace_service import TraceServiceClient from google.cloud.trace_v1.services.trace_service import pagers from google.cloud.trace_v1.services.trace_service import transports -from google.cloud.trace_v1.services.trace_service.transports.base import ( - _API_CORE_VERSION, -) from google.cloud.trace_v1.services.trace_service.transports.base import ( _GOOGLE_AUTH_VERSION, ) @@ -47,8 +44,9 @@ import google.auth -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: -# - Delete all the api-core and auth "less than" test cases +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases # - Delete these pytest markers (Make the "greater than or equal to" tests the default). requires_google_auth_lt_1_25_0 = pytest.mark.skipif( packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), @@ -59,16 +57,6 @@ reason="This test requires google-auth >= 1.25.0", ) -requires_api_core_lt_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), - reason="This test requires google-api-core < 1.26.0", -) - -requires_api_core_gte_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), - reason="This test requires google-api-core >= 1.26.0", -) - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -126,6 +114,16 @@ def test_trace_service_client_from_service_account_info(client_class): assert client.transport._host == "cloudtrace.googleapis.com:443" +@pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) +def test_trace_service_client_service_account_always_use_jwt(client_class): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + @pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) def test_trace_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -1270,7 +1268,6 @@ def test_trace_service_transport_auth_adc_old_google_auth(transport_class): (transports.TraceServiceGrpcAsyncIOTransport, grpc_helpers_async), ], ) -@requires_api_core_gte_1_26_0 def test_trace_service_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1303,83 +1300,6 @@ def test_trace_service_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.TraceServiceGrpcTransport, grpc_helpers), - (transports.TraceServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -@requires_api_core_lt_1_26_0 -def test_trace_service_transport_create_channel_old_api_core( - transport_class, grpc_helpers -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus") - - create_channel.assert_called_with( - "cloudtrace.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - "https://www.googleapis.com/auth/trace.readonly", - ), - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.TraceServiceGrpcTransport, grpc_helpers), - (transports.TraceServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -@requires_api_core_lt_1_26_0 -def test_trace_service_transport_create_channel_user_scopes( - transport_class, grpc_helpers -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "cloudtrace.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=["1", "2"], - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - @pytest.mark.parametrize( "transport_class", [transports.TraceServiceGrpcTransport, transports.TraceServiceGrpcAsyncIOTransport], diff --git a/tests/unit/gapic/trace_v2/test_trace_service.py b/tests/unit/gapic/trace_v2/test_trace_service.py index 81e985a6..eaa0c80f 100644 --- a/tests/unit/gapic/trace_v2/test_trace_service.py +++ b/tests/unit/gapic/trace_v2/test_trace_service.py @@ -34,9 +34,6 @@ from google.cloud.trace_v2.services.trace_service import TraceServiceAsyncClient from google.cloud.trace_v2.services.trace_service import TraceServiceClient from google.cloud.trace_v2.services.trace_service import transports -from google.cloud.trace_v2.services.trace_service.transports.base import ( - _API_CORE_VERSION, -) from google.cloud.trace_v2.services.trace_service.transports.base import ( _GOOGLE_AUTH_VERSION, ) @@ -50,8 +47,9 @@ import google.auth -# TODO(busunkim): Once google-api-core >= 1.26.0 is required: -# - Delete all the api-core and auth "less than" test cases +# TODO(busunkim): Once google-auth >= 1.25.0 is required transitively +# through google-api-core: +# - Delete the auth "less than" test cases # - Delete these pytest markers (Make the "greater than or equal to" tests the default). requires_google_auth_lt_1_25_0 = pytest.mark.skipif( packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), @@ -62,16 +60,6 @@ reason="This test requires google-auth >= 1.25.0", ) -requires_api_core_lt_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), - reason="This test requires google-api-core < 1.26.0", -) - -requires_api_core_gte_1_26_0 = pytest.mark.skipif( - packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), - reason="This test requires google-api-core >= 1.26.0", -) - def client_cert_source_callback(): return b"cert bytes", b"key bytes" @@ -129,6 +117,16 @@ def test_trace_service_client_from_service_account_info(client_class): assert client.transport._host == "cloudtrace.googleapis.com:443" +@pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) +def test_trace_service_client_service_account_always_use_jwt(client_class): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + client = client_class(credentials=creds) + use_jwt.assert_called_with(True) + + @pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) def test_trace_service_client_from_service_account_file(client_class): creds = ga_credentials.AnonymousCredentials() @@ -1066,7 +1064,6 @@ def test_trace_service_transport_auth_adc_old_google_auth(transport_class): (transports.TraceServiceGrpcAsyncIOTransport, grpc_helpers_async), ], ) -@requires_api_core_gte_1_26_0 def test_trace_service_transport_create_channel(transport_class, grpc_helpers): # If credentials and host are not provided, the transport class should use # ADC credentials. @@ -1098,82 +1095,6 @@ def test_trace_service_transport_create_channel(transport_class, grpc_helpers): ) -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.TraceServiceGrpcTransport, grpc_helpers), - (transports.TraceServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -@requires_api_core_lt_1_26_0 -def test_trace_service_transport_create_channel_old_api_core( - transport_class, grpc_helpers -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - transport_class(quota_project_id="octopus") - - create_channel.assert_called_with( - "cloudtrace.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - ), - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - -@pytest.mark.parametrize( - "transport_class,grpc_helpers", - [ - (transports.TraceServiceGrpcTransport, grpc_helpers), - (transports.TraceServiceGrpcAsyncIOTransport, grpc_helpers_async), - ], -) -@requires_api_core_lt_1_26_0 -def test_trace_service_transport_create_channel_user_scopes( - transport_class, grpc_helpers -): - # If credentials and host are not provided, the transport class should use - # ADC credentials. - with mock.patch.object( - google.auth, "default", autospec=True - ) as adc, mock.patch.object( - grpc_helpers, "create_channel", autospec=True - ) as create_channel: - creds = ga_credentials.AnonymousCredentials() - adc.return_value = (creds, None) - - transport_class(quota_project_id="octopus", scopes=["1", "2"]) - - create_channel.assert_called_with( - "cloudtrace.googleapis.com:443", - credentials=creds, - credentials_file=None, - quota_project_id="octopus", - scopes=["1", "2"], - ssl_credentials=None, - options=[ - ("grpc.max_send_message_length", -1), - ("grpc.max_receive_message_length", -1), - ], - ) - - @pytest.mark.parametrize( "transport_class", [transports.TraceServiceGrpcTransport, transports.TraceServiceGrpcAsyncIOTransport], From 85dd30de7d474b594ff90b0f1a0c1838edd8647f Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Fri, 25 Jun 2021 20:46:25 +0000 Subject: [PATCH 08/10] chore(python): simplify nox steps in CONTRIBUTING.rst (#98) Source-Link: https://github.com/googleapis/synthtool/commit/26558bae8976a985d73c2d98c31d8612273f907d Post-Processor: gcr.io/repo-automation-bots/owlbot-python:latest@sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719 --- .github/.OwlBot.lock.yaml | 2 +- CONTRIBUTING.rst | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 0954585f..e2b39f94 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,3 @@ docker: image: gcr.io/repo-automation-bots/owlbot-python:latest - digest: sha256:df50e8d462f86d6bcb42f27ecad55bb12c404f1c65de9c6fe4c4d25120080bd6 + digest: sha256:99d90d097e4a4710cc8658ee0b5b963f4426d0e424819787c3ac1405c9a26719 diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index ef5507c1..0324956e 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -68,14 +68,12 @@ Using ``nox`` We use `nox `__ to instrument our tests. - To test your changes, run unit tests with ``nox``:: + $ nox -s unit - $ nox -s unit-3.8 - $ ... +- To run a single unit test:: -- Args to pytest can be passed through the nox command separated by a `--`. For - example, to run a single test:: + $ nox -s unit-3.9 -- -k - $ nox -s unit-3.8 -- -k .. note:: @@ -142,7 +140,7 @@ Running System Tests - To run system tests, you can execute:: # Run all system tests - $ nox -s system-3.8 + $ nox -s system # Run a single system test $ nox -s system-3.8 -- -k @@ -215,8 +213,8 @@ Supported versions can be found in our ``noxfile.py`` `config`_. .. _config: https://github.com/googleapis/python-trace/blob/master/noxfile.py -We also explicitly decided to support Python 3 beginning with version -3.6. Reasons for this include: +We also explicitly decided to support Python 3 beginning with version 3.6. +Reasons for this include: - Encouraging use of newest versions of Python 3 - Taking the lead of `prominent`_ open-source `projects`_ From 110f692dace7b321d92033b1ccc1330deb859395 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Thu, 1 Jul 2021 02:24:12 +0000 Subject: [PATCH 09/10] fix: disable always_use_jwt_access (#100) Committer: @busunkim96 PiperOrigin-RevId: 382142900 Source-Link: https://github.com/googleapis/googleapis/commit/513440fda515f3c799c22a30e3906dcda325004e Source-Link: https://github.com/googleapis/googleapis-gen/commit/7b1e2c31233f79a704ec21ca410bf661d6bc68d0 --- .../services/trace_service/transports/base.py | 2 +- .../services/trace_service/transports/grpc.py | 5 ++- .../trace_service/transports/grpc_asyncio.py | 5 ++- .../services/trace_service/transports/base.py | 2 +- .../services/trace_service/transports/grpc.py | 5 ++- .../trace_service/transports/grpc_asyncio.py | 5 ++- .../unit/gapic/trace_v1/test_trace_service.py | 38 +++++++++++-------- .../unit/gapic/trace_v2/test_trace_service.py | 35 ++++++++++------- 8 files changed, 62 insertions(+), 35 deletions(-) diff --git a/google/cloud/trace_v1/services/trace_service/transports/base.py b/google/cloud/trace_v1/services/trace_service/transports/base.py index 3c2b8a15..03976afe 100644 --- a/google/cloud/trace_v1/services/trace_service/transports/base.py +++ b/google/cloud/trace_v1/services/trace_service/transports/base.py @@ -101,7 +101,7 @@ def __init__( scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES + self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. diff --git a/google/cloud/trace_v1/services/trace_service/transports/grpc.py b/google/cloud/trace_v1/services/trace_service/transports/grpc.py index 737ceb5f..2ba074e1 100644 --- a/google/cloud/trace_v1/services/trace_service/transports/grpc.py +++ b/google/cloud/trace_v1/services/trace_service/transports/grpc.py @@ -63,6 +63,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -103,6 +104,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -155,7 +158,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py b/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py index b57b0b91..360c73dc 100644 --- a/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py +++ b/google/cloud/trace_v1/services/trace_service/transports/grpc_asyncio.py @@ -109,6 +109,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -150,6 +151,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -201,7 +204,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/trace_v2/services/trace_service/transports/base.py b/google/cloud/trace_v2/services/trace_service/transports/base.py index afa0e665..2faddbb1 100644 --- a/google/cloud/trace_v2/services/trace_service/transports/base.py +++ b/google/cloud/trace_v2/services/trace_service/transports/base.py @@ -101,7 +101,7 @@ def __init__( scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) # Save the scopes. - self._scopes = scopes or self.AUTH_SCOPES + self._scopes = scopes # If no credentials are provided, then determine the appropriate # defaults. diff --git a/google/cloud/trace_v2/services/trace_service/transports/grpc.py b/google/cloud/trace_v2/services/trace_service/transports/grpc.py index 5967fa93..d74077c5 100644 --- a/google/cloud/trace_v2/services/trace_service/transports/grpc.py +++ b/google/cloud/trace_v2/services/trace_service/transports/grpc.py @@ -64,6 +64,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -104,6 +105,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport @@ -156,7 +159,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py b/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py index 54de3f6d..1e1822ff 100644 --- a/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py +++ b/google/cloud/trace_v2/services/trace_service/transports/grpc_asyncio.py @@ -110,6 +110,7 @@ def __init__( client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None, quota_project_id=None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, + always_use_jwt_access: Optional[bool] = False, ) -> None: """Instantiate the transport. @@ -151,6 +152,8 @@ def __init__( API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. + always_use_jwt_access (Optional[bool]): Whether self signed JWT should + be used for service account credentials. Raises: google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport @@ -202,7 +205,7 @@ def __init__( scopes=scopes, quota_project_id=quota_project_id, client_info=client_info, - always_use_jwt_access=True, + always_use_jwt_access=always_use_jwt_access, ) if not self._grpc_channel: diff --git a/tests/unit/gapic/trace_v1/test_trace_service.py b/tests/unit/gapic/trace_v1/test_trace_service.py index 7eaa80fd..2958536c 100644 --- a/tests/unit/gapic/trace_v1/test_trace_service.py +++ b/tests/unit/gapic/trace_v1/test_trace_service.py @@ -121,7 +121,25 @@ def test_trace_service_client_service_account_always_use_jwt(client_class): ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) - use_jwt.assert_called_with(True) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.TraceServiceGrpcTransport, "grpc"), + (transports.TraceServiceGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_trace_service_client_service_account_always_use_jwt_true( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) @pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) @@ -1319,11 +1337,7 @@ def test_trace_service_grpc_transport_client_cert_source_for_mtls(transport_clas "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - "https://www.googleapis.com/auth/trace.readonly", - ), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -1427,11 +1441,7 @@ def test_trace_service_transport_channel_mtls_with_client_cert_source(transport_ "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - "https://www.googleapis.com/auth/trace.readonly", - ), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -1475,11 +1485,7 @@ def test_trace_service_transport_channel_mtls_with_adc(transport_class): "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - "https://www.googleapis.com/auth/trace.readonly", - ), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ diff --git a/tests/unit/gapic/trace_v2/test_trace_service.py b/tests/unit/gapic/trace_v2/test_trace_service.py index eaa0c80f..0d670cc7 100644 --- a/tests/unit/gapic/trace_v2/test_trace_service.py +++ b/tests/unit/gapic/trace_v2/test_trace_service.py @@ -124,7 +124,25 @@ def test_trace_service_client_service_account_always_use_jwt(client_class): ) as use_jwt: creds = service_account.Credentials(None, None, None) client = client_class(credentials=creds) - use_jwt.assert_called_with(True) + use_jwt.assert_not_called() + + +@pytest.mark.parametrize( + "transport_class,transport_name", + [ + (transports.TraceServiceGrpcTransport, "grpc"), + (transports.TraceServiceGrpcAsyncIOTransport, "grpc_asyncio"), + ], +) +def test_trace_service_client_service_account_always_use_jwt_true( + transport_class, transport_name +): + with mock.patch.object( + service_account.Credentials, "with_always_use_jwt_access", create=True + ) as use_jwt: + creds = service_account.Credentials(None, None, None) + transport = transport_class(credentials=creds, always_use_jwt_access=True) + use_jwt.assert_called_once_with(True) @pytest.mark.parametrize("client_class", [TraceServiceClient, TraceServiceAsyncClient,]) @@ -1114,10 +1132,7 @@ def test_trace_service_grpc_transport_client_cert_source_for_mtls(transport_clas "squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - ), + scopes=None, ssl_credentials=mock_ssl_channel_creds, quota_project_id=None, options=[ @@ -1221,10 +1236,7 @@ def test_trace_service_transport_channel_mtls_with_client_cert_source(transport_ "mtls.squid.clam.whelk:443", credentials=cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - ), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ @@ -1268,10 +1280,7 @@ def test_trace_service_transport_channel_mtls_with_adc(transport_class): "mtls.squid.clam.whelk:443", credentials=mock_cred, credentials_file=None, - scopes=( - "https://www.googleapis.com/auth/cloud-platform", - "https://www.googleapis.com/auth/trace.append", - ), + scopes=None, ssl_credentials=mock_ssl_cred, quota_project_id=None, options=[ From 4668bdca5401e9f7c3968f33d28f1f1db669bd59 Mon Sep 17 00:00:00 2001 From: "release-please[bot]" <55107282+release-please[bot]@users.noreply.github.com> Date: Mon, 12 Jul 2021 23:26:30 +0000 Subject: [PATCH 10/10] chore: release 1.3.0 (#97) :robot: I have created a release \*beep\* \*boop\* --- ## [1.3.0](https://www.github.com/googleapis/python-trace/compare/v1.2.0...v1.3.0) (2021-07-01) ### Features * add always_use_jwt_access ([#96](https://www.github.com/googleapis/python-trace/issues/96)) ([e88837d](https://www.github.com/googleapis/python-trace/commit/e88837d7bc7ac180f87f4a5bb8a4cbd71f6e3449)) ### Bug Fixes * disable always_use_jwt_access ([#100](https://www.github.com/googleapis/python-trace/issues/100)) ([110f692](https://www.github.com/googleapis/python-trace/commit/110f692dace7b321d92033b1ccc1330deb859395)) ### Documentation * omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-trace/issues/1127)) ([#91](https://www.github.com/googleapis/python-trace/issues/91)) ([5dcc16c](https://www.github.com/googleapis/python-trace/commit/5dcc16ca802dc2a8895389fabecd82e4ec739e54)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). --- CHANGELOG.md | 17 +++++++++++++++++ setup.py | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 24dbd77a..7a3cbe02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ [1]: https://pypi.org/project/google-cloud-trace/#history +## [1.3.0](https://www.github.com/googleapis/python-trace/compare/v1.2.0...v1.3.0) (2021-07-01) + + +### Features + +* add always_use_jwt_access ([#96](https://www.github.com/googleapis/python-trace/issues/96)) ([e88837d](https://www.github.com/googleapis/python-trace/commit/e88837d7bc7ac180f87f4a5bb8a4cbd71f6e3449)) + + +### Bug Fixes + +* disable always_use_jwt_access ([#100](https://www.github.com/googleapis/python-trace/issues/100)) ([110f692](https://www.github.com/googleapis/python-trace/commit/110f692dace7b321d92033b1ccc1330deb859395)) + + +### Documentation + +* omit mention of Python 2.7 in 'CONTRIBUTING.rst' ([#1127](https://www.github.com/googleapis/python-trace/issues/1127)) ([#91](https://www.github.com/googleapis/python-trace/issues/91)) ([5dcc16c](https://www.github.com/googleapis/python-trace/commit/5dcc16ca802dc2a8895389fabecd82e4ec739e54)) + ## [1.2.0](https://www.github.com/googleapis/python-trace/compare/v1.1.0...v1.2.0) (2021-05-27) diff --git a/setup.py b/setup.py index 342eb933..b9cb227a 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-trace" description = "Cloud Trace API client library" -version = "1.2.0" +version = "1.3.0" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta'