...
1 package examples
2
3 import (
4 "context"
5 "fmt"
6
7 "github.com/shurcooL/graphql"
8
9 "edge-infra.dev/pkg/edge/api/client"
10 "edge-infra.dev/pkg/edge/api/graph/model"
11 )
12
13 type Cluster struct {
14 ClusterEdgeID string `graphql:"clusterEdgeId" json:"clusterEdgeId"`
15 ClusterName string `graphql:"name" json:"clusterName"`
16 ClusterNetworkServices []*model.ClusterNetworkServiceInfo `graphql:"clusterNetworkServices" json:"clusterNetworkServices"`
17 }
18
19 func ClusterQuery() {
20 username := "username"
21 password := "123456"
22 organization := "edge-dev1-retail-b526aa"
23 bannerEdgeID := "3b4c9826-ffdc-42b4-8319-7aa29f7fa407"
24 cl, err := client.New(client.WithCredentials(username, password, organization))
25 if err != nil {
26 fmt.Println("err: ", err)
27 }
28 var clustersQuery struct {
29 Clusters []Cluster `graphql:"clusters(bannerEdgeId: $bannerEdgeId)"`
30 }
31 if err := cl.Query(context.Background(), &clustersQuery, map[string]any{
32 "bannerEdgeId": graphql.String(bannerEdgeID),
33 }); err != nil {
34 fmt.Println("err: ", err)
35 }
36 fmt.Printf("Cluster Response: %v\n", clustersQuery)
37 }
38
View as plain text