client side methods
This commit is contained in:
Родитель
7c54d3959f
Коммит
ed4680c7ba
1
go.mod
1
go.mod
|
@ -22,6 +22,7 @@ replace (
|
|||
github.com/Azure/go-autorest v11.1.2+incompatible => github.com/Azure/go-autorest/autorest v0.10.0
|
||||
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.1.0
|
||||
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2
|
||||
github.com/microsoft/moc => github.com/abhadoriya26/moc v0.0.0-20230417050604-4741422a4a7b
|
||||
github.com/miekg/dns => github.com/miekg/dns v1.1.25
|
||||
golang.org/x/net => golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c
|
||||
golang.org/x/sys => golang.org/x/sys v0.0.0-20220823224334-20c2bfdbfe24
|
||||
|
|
8
go.sum
8
go.sum
|
@ -404,6 +404,8 @@ github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbt
|
|||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/abhadoriya26/moc v0.0.0-20230417050604-4741422a4a7b h1:QOsh4s6MucSU5Kgy0TYv9yUL8FPHLS7ShzqGyFXLyzQ=
|
||||
github.com/abhadoriya26/moc v0.0.0-20230417050604-4741422a4a7b/go.mod h1:gvxuYApVO2jbL+mjOC1/gseLW5An2iDvm0lckLwBuLI=
|
||||
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
|
@ -577,8 +579,6 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
|||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/lyft/protoc-gen-star v0.6.0/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
|
||||
github.com/lyft/protoc-gen-star v0.6.1/go.mod h1:TGAoBVkt8w7MPG72TrKIu85MIdXwDuzJYeZuUPFPNwA=
|
||||
github.com/microsoft/moc v0.11.0-alpha.3 h1:EW85jOFEbKT4508HajbmCirL9bAFkXFuWMxi7Wvy+Ng=
|
||||
github.com/microsoft/moc v0.11.0-alpha.3/go.mod h1:lqa/DfD6BK5XpAsfRCgCRfgIgtGvJeOlkskUX+mfyIY=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
|
@ -740,8 +740,9 @@ golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
|||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
|
@ -883,6 +884,7 @@ google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvx
|
|||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200128133413-58ce757ed39b/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
|
|
|
@ -5,6 +5,7 @@ package logging
|
|||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/microsoft/moc-sdk-for-go/services/admin/logging/internal"
|
||||
"github.com/microsoft/moc/pkg/auth"
|
||||
)
|
||||
|
@ -12,6 +13,8 @@ import (
|
|||
// Service interfacetype Service interface {
|
||||
type Service interface {
|
||||
GetLogFile(context.Context, string, string) error
|
||||
SetVerbosityLevel(context.Context, int32, bool) error
|
||||
GetVerbosityLevel(context.Context) (string, error)
|
||||
}
|
||||
|
||||
// Client structure
|
||||
|
@ -29,3 +32,11 @@ func NewLoggingClient(cloudFQDN string, authorizer auth.Authorizer) (*LoggingCli
|
|||
func (c *LoggingClient) GetLogFile(ctx context.Context, location string, filename string) error {
|
||||
return c.internal.GetLogFile(ctx, location, filename)
|
||||
}
|
||||
|
||||
func (c *LoggingClient) SetVerbosityLevel(ctx context.Context, verbositylevel int32, include_nodeagents bool) error {
|
||||
return c.internal.SetVerbosityLevel(ctx, verbositylevel, include_nodeagents)
|
||||
}
|
||||
|
||||
func (c *LoggingClient) GetVerbosityLevel(ctx context.Context) (string, error) {
|
||||
return c.internal.GetVerbosityLevel(ctx)
|
||||
}
|
||||
|
|
|
@ -6,14 +6,16 @@ package internal
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
wssdclient "github.com/microsoft/moc-sdk-for-go/pkg/client"
|
||||
"github.com/microsoft/moc/pkg/auth"
|
||||
loggingHelpers "github.com/microsoft/moc/pkg/logging"
|
||||
wssdadmin "github.com/microsoft/moc/rpc/cloudagent/admin"
|
||||
"io"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
wssdclient "github.com/microsoft/moc-sdk-for-go/pkg/client"
|
||||
"github.com/microsoft/moc/pkg/auth"
|
||||
loggingHelpers "github.com/microsoft/moc/pkg/logging"
|
||||
wssdadmin "github.com/microsoft/moc/rpc/cloudagent/admin"
|
||||
wssdcomadmin "github.com/microsoft/moc/rpc/common/admin"
|
||||
)
|
||||
|
||||
type client struct {
|
||||
|
@ -66,8 +68,39 @@ func (c *client) GetLogFile(ctx context.Context, location, filename string) erro
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *client) SetVerbosityLevel(ctx context.Context, verbositylevel int32, include_nodeagents bool) error {
|
||||
|
||||
if verbositylevel < int32(wssdcomadmin.VerboseLevel_Min_Level) || verbositylevel > int32(wssdcomadmin.VerboseLevel_Max_Level) {
|
||||
return errors.New(`can not set provided verbositylevel, provided level should be within the range of 0-9 including 0 and 9`)
|
||||
}
|
||||
request := setVerbosityLevelRequest(verbositylevel, include_nodeagents)
|
||||
|
||||
_, err := c.LogAgentClient.Set(ctx, request)
|
||||
return err
|
||||
|
||||
}
|
||||
|
||||
func (c *client) GetVerbosityLevel(ctx context.Context) (string, error) {
|
||||
|
||||
request := getLevelRequest()
|
||||
res, err := c.LogAgentClient.GetLevel(ctx, request)
|
||||
return res.Level, err
|
||||
|
||||
}
|
||||
|
||||
func getLoggingRequest(location string) *wssdadmin.LogRequest {
|
||||
return &wssdadmin.LogRequest{
|
||||
Location: location,
|
||||
}
|
||||
}
|
||||
|
||||
func setVerbosityLevelRequest(verbositylevel int32, include_nodeagents bool) *wssdadmin.SetRequest {
|
||||
return &wssdadmin.SetRequest{
|
||||
Verbositylevel: verbositylevel,
|
||||
IncludeNodeagents: include_nodeagents,
|
||||
}
|
||||
}
|
||||
|
||||
func getLevelRequest() *wssdadmin.GetRequest {
|
||||
return &wssdadmin.GetRequest{}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче