go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/analysis/frontend/ui/src/services/services.ts (about) 1 // Copyright 2024 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 import { ClustersClientImpl } from '@/proto/go.chromium.org/luci/analysis/proto/v1/clusters.pb'; 16 import { MetricsClientImpl } from '@/proto/go.chromium.org/luci/analysis/proto/v1/metrics.pb'; 17 import { ProjectsClientImpl } from '@/proto/go.chromium.org/luci/analysis/proto/v1/projects.pb'; 18 import { RulesClientImpl } from '@/proto/go.chromium.org/luci/analysis/proto/v1/rules.pb'; 19 import { TestVariantsClientImpl } from '@/proto/go.chromium.org/luci/analysis/proto/v1/test_variants.pb'; 20 21 import { PrpcClient } from './prpc_client'; 22 import { getSessionAccessToken } from './auth_token'; 23 24 export const getClustersService = () => { 25 const insecure = document.location.protocol === 'http:'; 26 const client = new ClustersClientImpl( 27 new PrpcClient({ 28 insecure: insecure, 29 getAuthToken: getSessionAccessToken, 30 }), 31 ); 32 return client; 33 }; 34 35 export const getMetricsService = () => { 36 const insecure = document.location.protocol === 'http:'; 37 const client = new MetricsClientImpl( 38 new PrpcClient({ 39 insecure: insecure, 40 getAuthToken: getSessionAccessToken, 41 }), 42 ); 43 return client; 44 }; 45 46 export const getProjectsService = () => { 47 const insecure = document.location.protocol === 'http:'; 48 const client = new ProjectsClientImpl( 49 new PrpcClient({ 50 insecure: insecure, 51 getAuthToken: getSessionAccessToken, 52 }), 53 ); 54 return client; 55 }; 56 57 export const getRulesService = () => { 58 const insecure = document.location.protocol === 'http:'; 59 const client = new RulesClientImpl( 60 new PrpcClient({ 61 insecure: insecure, 62 getAuthToken: getSessionAccessToken, 63 }), 64 ); 65 return client; 66 }; 67 68 export const getTestVariantsService = () => { 69 const insecure = document.location.protocol === 'http:'; 70 const client = new TestVariantsClientImpl( 71 new PrpcClient({ 72 insecure: insecure, 73 getAuthToken: getSessionAccessToken, 74 }), 75 ); 76 return client; 77 };