go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/led/ledcmd/clients.go (about) 1 // Copyright 2020 The LUCI Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package ledcmd 16 17 import ( 18 "fmt" 19 "net/http" 20 21 bbpb "go.chromium.org/luci/buildbucket/proto" 22 swarmbucket "go.chromium.org/luci/common/api/buildbucket/swarmbucket/v1" 23 "go.chromium.org/luci/grpc/prpc" 24 swarmingpb "go.chromium.org/luci/swarming/proto/api_v2" 25 ) 26 27 func newSwarmTasksClient(authClient *http.Client, host string) swarmingpb.TasksClient { 28 return swarmingpb.NewTasksClient(&prpc.Client{ 29 C: authClient, 30 Host: host, 31 }) 32 } 33 34 func newSwarmbucketClient(authClient *http.Client, host string) *swarmbucket.Service { 35 // TODO(iannucci): Switch this to prpc endpoints 36 sbucket, err := swarmbucket.New(authClient) 37 if err != nil { 38 panic(err) 39 } 40 sbucket.BasePath = fmt.Sprintf("https://%s/_ah/api/swarmbucket/v1/", host) 41 return sbucket 42 } 43 44 func newBuildbucketClient(authClient *http.Client, host string) bbpb.BuildsClient { 45 return bbpb.NewBuildsPRPCClient(&prpc.Client{ 46 C: authClient, 47 Host: host, 48 }) 49 }