Skip to content

Commit 4968d63

Browse files
authored
fix(dart): Move HTTP client creation to _gax (#2672)
Paired with googleapis/google-cloud-dart#56
1 parent 572ae4f commit 4968d63

File tree

5 files changed

+1
-11
lines changed

5 files changed

+1
-11
lines changed

internal/sidekick/internal/dart/annotate.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,6 @@ func calculateImports(imports map[string]bool) []string {
500500
func (annotate *annotateModel) annotateService(s *api.Service) {
501501
// Add a package:http import if we're generating a service.
502502
annotate.imports[httpImport] = true
503-
annotate.imports[authImport] = true
504503

505504
// Some methods are skipped.
506505
methods := language.FilterSlice(s.Methods, func(m *api.Method) bool {

internal/sidekick/internal/dart/annotate_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ var (
2727
requiredConfig = map[string]string{
2828
"api-keys-environment-variables": "GOOGLE_API_KEY,GEMINI_API_KEY",
2929
"issue-tracker-url": "http://www.example.com/issues",
30-
"package:googleapis_auth": "^2.0.0",
3130
"package:google_cloud_gax": "^1.2.3",
3231
"package:http": "^4.5.6",
3332
"package:google_cloud_protobuf": "^7.8.9",
@@ -153,7 +152,6 @@ func TestAnnotateModel_Options(t *testing.T) {
153152
if diff := cmp.Diff(map[string]string{
154153
"google_cloud_gax": "^1.2.3",
155154
"google_cloud_protobuf": "^7.8.9",
156-
"googleapis_auth": "^2.0.0",
157155
"http": "1.2.0"},
158156
am.dependencyConstraints); diff != "" {
159157
t.Errorf("mismatch in annotateModel.dependencyConstraints (-want, +got)\n:%s", diff)

internal/sidekick/internal/dart/dart.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
)
2727

2828
var typedDataImport = "dart:typed_data"
29-
var authImport = "package:googleapis_auth/auth_io.dart as auth"
3029
var httpImport = "package:http/http.dart as http"
3130
var gaxImport = "package:google_cloud_gax/gax.dart"
3231
var encodingImport = "package:google_cloud_protobuf/src/encoding.dart"

internal/sidekick/internal/dart/generate_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ func TestFromProtobuf(t *testing.T) {
5353
"not-for-publication": "true",
5454
"version": "0.1.0",
5555
"skip-format": "true",
56-
"package:googleapis_auth": "^2.0.0",
5756
"package:google_cloud_gax": "^1.2.3",
5857
"package:http": "^4.5.6",
5958
"package:google_cloud_location": "^7.8.9",

internal/sidekick/internal/dart/templates/lib/service.mustache

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,7 @@ final class {{Codec.Name}} {
4444
///
4545
/// See [API Keys Overview](https://cloud.google.com/api-keys/docs/overview).
4646
factory {{Codec.Name}}.fromApiKey([String? apiKey]) {
47-
apiKey ??= _apiKeys.map(environmentVariable).nonNulls.firstOrNull;
48-
if (apiKey == null) {
49-
throw ArgumentError('apiKey or one of these environment variables must '
50-
'be set to an API key: ${_apiKeys.join(', ')}');
51-
}
52-
return {{Codec.Name}}(client: auth.clientViaApiKey(apiKey));
47+
return {{Codec.Name}}(client: httpClientFromApiKey(apiKey, _apiKeys));
5348
}
5449

5550
{{#Codec.Methods}}

0 commit comments

Comments
 (0)