-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
220 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package file | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"encoding/json" | ||
pb "github.com/openconfig/gnoi/file" | ||
"github.com/sonic-net/sonic-gnmi/gnoi_client/utils" | ||
"github.com/sonic-net/sonic-gnmi/gnoi_client/config" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func Stat(conn *grpc.ClientConn, ctx context.Context) { | ||
fmt.Println("File Stat") | ||
ctx = utils.SetUserCreds(ctx) | ||
fc := pb.NewFileClient(conn) | ||
req := &pb.StatRequest{} | ||
err := json.Unmarshal([]byte(*config.Args), req) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
resp, err := fc.Stat(ctx, req) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
respstr, err := json.Marshal(resp) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
fmt.Println(string(respstr)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package sonic | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"encoding/json" | ||
pb "github.com/sonic-net/sonic-gnmi/proto/gnoi/jwt" | ||
"github.com/sonic-net/sonic-gnmi/gnoi_client/utils" | ||
"github.com/sonic-net/sonic-gnmi/gnoi_client/config" | ||
"google.golang.org/grpc" | ||
) | ||
|
||
func Authenticate(conn *grpc.ClientConn, ctx context.Context) { | ||
fmt.Println("Sonic Authenticate") | ||
ctx = utils.SetUserCreds(ctx) | ||
sc := pb.NewSonicJwtServiceClient(conn) | ||
req := &pb.AuthenticateRequest{} | ||
json.Unmarshal([]byte(*config.Args), req) | ||
|
||
resp, err := sc.Authenticate(ctx, req) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
respstr, err := json.Marshal(resp) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
fmt.Println(string(respstr)) | ||
} | ||
|
||
func Refresh(conn *grpc.ClientConn, ctx context.Context) { | ||
fmt.Println("Sonic Refresh") | ||
ctx = utils.SetUserCreds(ctx) | ||
sc := pb.NewSonicJwtServiceClient(conn) | ||
req := &pb.RefreshRequest{} | ||
json.Unmarshal([]byte(*config.Args), req) | ||
resp, err := sc.Refresh(ctx, req) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
respstr, err := json.Marshal(resp) | ||
if err != nil { | ||
panic(err.Error()) | ||
} | ||
fmt.Println(string(respstr)) | ||
} |
Oops, something went wrong.