Skip to content

Commit e3de342

Browse files
[POA-692|88] Update to V2 endpoints (#254)
* Updated in-use endpoints with their new `v2` endpoints * Marked old endpoints `Deprecated`, we can remove them while working on Akita Sunset Epic * Updated the telemetry endpoints, to not send any deployment type. We will redirect them to the correct endpoints in front adapters. This will also solve [POA-88](https://postmanlabs.atlassian.net/browse/POA-88). * Superstar service PR: postman-eng/observability-superstar-service#1814
1 parent 0ebb10a commit e3de342

File tree

5 files changed

+28
-23
lines changed

5 files changed

+28
-23
lines changed

apidump/apidump.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (a *apidump) SendInitialTelemetry() {
224224

225225
ctx, cancel := context.WithTimeout(context.Background(), telemetryTimeout)
226226
defer cancel()
227-
err := a.learnClient.PostInitialClientTelemetry(ctx, a.backendSvc, a.Deployment, req)
227+
err := a.learnClient.PostInitialClientTelemetry(ctx, a.backendSvc, req)
228228
if err != nil {
229229
// Log an error and continue.
230230
printer.Stderr.Errorf("Failed to send initial telemetry statistics: %s\n", err)
@@ -273,7 +273,7 @@ func (a *apidump) SendTelemetry(req *kgxapi.PostClientPacketCaptureStatsRequest)
273273

274274
ctx, cancel := context.WithTimeout(context.Background(), telemetryTimeout)
275275
defer cancel()
276-
err := a.learnClient.PostClientPacketCaptureStats(ctx, a.backendSvc, a.Deployment, *req)
276+
err := a.learnClient.PostClientPacketCaptureStats(ctx, a.backendSvc, *req)
277277
if err != nil {
278278
// Log an error and continue.
279279
printer.Stderr.Errorf("Failed to send telemetry statistics: %s\n", err)

integrations/nginx/backend.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (b *NginxBackend) SendInitialTelemetry() {
6868
}
6969
ctx, cancel := context.WithTimeout(context.Background(), telemetryTimeout)
7070
defer cancel()
71-
err := b.learnClient.PostInitialClientTelemetry(ctx, b.backendSvc, b.deployment, req)
71+
err := b.learnClient.PostInitialClientTelemetry(ctx, b.backendSvc, req)
7272
if err != nil {
7373
// Log an error and continue.
7474
printer.Stderr.Errorf("Failed to send initial telemetry statistics: %s\n", err)
@@ -83,7 +83,7 @@ func (b *NginxBackend) SendTelemetry(req *kgxapi.PostClientPacketCaptureStatsReq
8383

8484
ctx, cancel := context.WithTimeout(context.Background(), telemetryTimeout)
8585
defer cancel()
86-
err := b.learnClient.PostClientPacketCaptureStats(ctx, b.backendSvc, b.deployment, *req)
86+
err := b.learnClient.PostClientPacketCaptureStats(ctx, b.backendSvc, *req)
8787
if err != nil {
8888
// Log an error and continue.
8989
printer.Stderr.Errorf("Failed to send telemetry statistics: %s\n", err)

rest/front_client.go

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ func NewFrontClient(host string, cli akid.ClientID) *frontClientImpl {
2020
}
2121
}
2222

23+
// Deprecated: Replaced with GetService(), will be removed in the future.
2324
func (c *frontClientImpl) GetServices(ctx context.Context) ([]Service, error) {
2425
resp := []Service{}
2526
if err := c.Get(ctx, "/v1/services", &resp); err != nil {
@@ -43,6 +44,7 @@ func (c *frontClientImpl) GetUser(ctx context.Context) (PostmanUser, error) {
4344
return resp, err
4445
}
4546

47+
// Deprecated: Used in daemon command which is deprecated.
4648
func (c *frontClientImpl) DaemonHeartbeat(ctx context.Context, daemonName string) error {
4749
body := struct {
4850
DaemonName string `json:"daemon_name"`
@@ -53,6 +55,7 @@ func (c *frontClientImpl) DaemonHeartbeat(ctx context.Context, daemonName string
5355
return c.Post(ctx, "/v1/daemon/heartbeat", body, &resp)
5456
}
5557

58+
// Deprecated: Used in daemon command which is deprecated.
5659
func (c *frontClientImpl) LongPollActiveTracesForService(ctx context.Context, daemonName string, serviceID akid.ServiceID, activeTraces []akid.LearnSessionID) (daemon.ActiveTraceDiff, error) {
5760
body := struct {
5861
DaemonName string `json:"daemon_name"`

rest/interface.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ type LearnClient interface {
5757
GetSpecDiffTrie(context.Context, akid.APISpecID, akid.APISpecID) (*path_trie.PathTrie, error)
5858

5959
// Telemetry
60-
PostClientPacketCaptureStats(context.Context, akid.ServiceID, string, kgxapi.PostClientPacketCaptureStatsRequest) error
61-
PostInitialClientTelemetry(context.Context, akid.ServiceID, string, kgxapi.PostInitialClientTelemetryRequest) error
60+
PostClientPacketCaptureStats(context.Context, akid.ServiceID, kgxapi.PostClientPacketCaptureStatsRequest) error
61+
PostInitialClientTelemetry(context.Context, akid.ServiceID, kgxapi.PostInitialClientTelemetryRequest) error
6262
}
6363

6464
type FrontClient interface {

rest/learn_client.go

+19-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
kgxapi "github.com/akitasoftware/akita-libs/api_schema"
1414
"github.com/akitasoftware/akita-libs/path_trie"
1515
"github.com/akitasoftware/akita-libs/tags"
16-
"github.com/pkg/errors"
1716
)
1817

1918
var (
@@ -37,7 +36,7 @@ func NewLearnClient(host string, cli akid.ClientID, svc akid.ServiceID) *learnCl
3736
}
3837

3938
func (c *learnClientImpl) ListLearnSessions(ctx context.Context, svc akid.ServiceID, tags map[tags.Key]string, limit int, offset int) ([]*kgxapi.ListedLearnSession, error) {
40-
p := path.Join("/v1/services", akid.String(c.serviceID), "learn")
39+
p := path.Join("/v2/agent/services", akid.String(c.serviceID), "learn")
4140
q := url.Values{}
4241
q.Add("limit", strconv.Itoa(limit))
4342
q.Add("offset", strconv.Itoa(offset))
@@ -54,7 +53,7 @@ func (c *learnClientImpl) ListLearnSessions(ctx context.Context, svc akid.Servic
5453
}
5554

5655
func (c *learnClientImpl) ListLearnSessionsWithStats(ctx context.Context, svc akid.ServiceID, limit int) ([]*kgxapi.ListedLearnSession, error) {
57-
p := path.Join("/v1/services", akid.String(c.serviceID), "learn")
56+
p := path.Join("/v2/agent/services", akid.String(c.serviceID), "learn")
5857
q := url.Values{}
5958
q.Add("limit", fmt.Sprintf("%d", limit))
6059
q.Add("get_stats", "true")
@@ -67,6 +66,7 @@ func (c *learnClientImpl) ListLearnSessionsWithStats(ctx context.Context, svc ak
6766
return resp.Sessions, nil
6867
}
6968

69+
// Deprecated: Only used in learn command which is deprecated.
7070
func (c *learnClientImpl) GetLearnSession(ctx context.Context, svc akid.ServiceID, lrn akid.LearnSessionID) (*kgxapi.LearnSession, error) {
7171
p := path.Join("/v1/services", akid.String(c.serviceID), "learn", akid.String(lrn))
7272
var resp kgxapi.LearnSession
@@ -80,7 +80,7 @@ func (c *learnClientImpl) GetLearnSession(ctx context.Context, svc akid.ServiceI
8080
func (c *learnClientImpl) CreateLearnSession(ctx context.Context, baseSpecRef *kgxapi.APISpecReference, name string, tags map[tags.Key]string) (akid.LearnSessionID, error) {
8181
req := kgxapi.CreateLearnSessionRequest{BaseAPISpecRef: baseSpecRef, Tags: tags, Name: name}
8282
var resp kgxapi.LearnSession
83-
p := path.Join("/v1/services", akid.String(c.serviceID), "learn")
83+
p := path.Join("/v2/agent/services", akid.String(c.serviceID), "learn")
8484
err := c.Post(ctx, p, req, &resp)
8585
if err != nil {
8686
return akid.LearnSessionID{}, err
@@ -92,10 +92,11 @@ func (c *learnClientImpl) AsyncReportsUpload(ctx context.Context, lrn akid.Learn
9292
req.ClientID = c.clientID
9393
resp := map[string]interface{}{}
9494

95-
p := path.Join("/v1/services", akid.String(c.serviceID), "learn", akid.String(lrn), "async_reports")
95+
p := path.Join("/v2/agent/services", akid.String(c.serviceID), "learn", akid.String(lrn), "async_reports")
9696
return c.Post(ctx, p, req, &resp)
9797
}
9898

99+
// Deprecated: Function not used anywhere.
99100
func (c *learnClientImpl) CreateSpec(ctx context.Context, name string, lrns []akid.LearnSessionID, opts CreateSpecOptions) (akid.APISpecID, error) {
100101
// Go cannot marshal regexp into JSON unfortunately.
101102
pathExclusions := make([]string, len(opts.PathExclusions))
@@ -126,6 +127,7 @@ func (c *learnClientImpl) CreateSpec(ctx context.Context, name string, lrns []ak
126127
return resp.ID, err
127128
}
128129

130+
// Deprecated: Used in legacy and get command which is deprecated.
129131
func (c *learnClientImpl) GetSpec(ctx context.Context, api akid.APISpecID, opts GetSpecOptions) (kgxapi.GetSpecResponse, error) {
130132
qs := make(url.Values)
131133
if !opts.EnableRelatedTypes {
@@ -138,6 +140,7 @@ func (c *learnClientImpl) GetSpec(ctx context.Context, api akid.APISpecID, opts
138140
return resp, err
139141
}
140142

143+
// Deprecated: Used only in get command which is deprecated.
141144
func (c *learnClientImpl) ListSpecs(ctx context.Context) ([]kgxapi.SpecInfo, error) {
142145
qs := make(url.Values)
143146

@@ -152,6 +155,7 @@ func (c *learnClientImpl) ListSpecs(ctx context.Context) ([]kgxapi.SpecInfo, err
152155
return resp.Specs, err
153156
}
154157

158+
// Deprecated: Used in legacy commands which are deprecated.
155159
func (c *learnClientImpl) GetSpecVersion(ctx context.Context, version string) (kgxapi.APISpecVersion, error) {
156160
var resp kgxapi.APISpecVersion
157161
p := path.Join("/v1/services", akid.String(c.serviceID), "spec-versions", version)
@@ -162,13 +166,15 @@ func (c *learnClientImpl) GetSpecVersion(ctx context.Context, version string) (k
162166
return resp, nil
163167
}
164168

169+
// Deprecated: Used in upload command which is deprecated.
165170
func (c *learnClientImpl) UploadSpec(ctx context.Context, req kgxapi.UploadSpecRequest) (*kgxapi.UploadSpecResponse, error) {
166171
p := path.Join("/v1/services", akid.String(c.serviceID), "upload-spec")
167172
var resp kgxapi.UploadSpecResponse
168173
err := c.Post(ctx, p, req, &resp)
169174
return &resp, err
170175
}
171176

177+
// Deprecated: Used in apidiff, get and set command which are deprecated.
172178
func (c *learnClientImpl) GetAPISpecIDByName(ctx context.Context, n string) (akid.APISpecID, error) {
173179
resp := struct {
174180
ID akid.APISpecID `json:"id"`
@@ -187,6 +193,7 @@ func (c *learnClientImpl) GetLearnSessionIDByName(ctx context.Context, n string)
187193
return resp.ID, err
188194
}
189195

196+
// Deprecated: Used in apidiff command which is deprecated.
190197
func (c *learnClientImpl) GetSpecDiffTrie(ctx context.Context, baseID, newID akid.APISpecID) (*path_trie.PathTrie, error) {
191198
var resp path_trie.PathTrie
192199
path := fmt.Sprintf("/v1/services/%s/specs/%s/diff/%s/trie",
@@ -195,26 +202,19 @@ func (c *learnClientImpl) GetSpecDiffTrie(ctx context.Context, baseID, newID aki
195202
return &resp, err
196203
}
197204

198-
func (c *learnClientImpl) PostClientPacketCaptureStats(ctx context.Context, serviceID akid.ServiceID, deployment string, req kgxapi.PostClientPacketCaptureStatsRequest) error {
199-
if deployment == "" {
200-
return errors.Errorf("missing deployment tag")
201-
}
202-
203-
path := fmt.Sprintf("/v1/services/%s/telemetry/client/deployment/%s", serviceID, deployment)
205+
func (c *learnClientImpl) PostClientPacketCaptureStats(ctx context.Context, serviceID akid.ServiceID, req kgxapi.PostClientPacketCaptureStatsRequest) error {
206+
path := fmt.Sprintf("/v2/agent/services/%s/telemetry/client/deployment", serviceID)
204207
var resp struct{}
205208
return c.Post(ctx, path, req, &resp)
206209
}
207210

208-
func (c *learnClientImpl) PostInitialClientTelemetry(ctx context.Context, serviceID akid.ServiceID, deployment string, req kgxapi.PostInitialClientTelemetryRequest) error {
209-
if deployment == "" {
210-
return errors.Errorf("missing deployment tag")
211-
}
212-
213-
path := fmt.Sprintf("/v1/services/%s/telemetry/client/deployment/%s/start", serviceID, deployment)
211+
func (c *learnClientImpl) PostInitialClientTelemetry(ctx context.Context, serviceID akid.ServiceID, req kgxapi.PostInitialClientTelemetryRequest) error {
212+
path := fmt.Sprintf("/v2/agent/services/%s/telemetry/client/deployment/start", serviceID)
214213
var resp struct{}
215214
return c.Post(ctx, path, req, &resp)
216215
}
217216

217+
// Deprecated: Used in setversion command which is deprecated.
218218
func (c *learnClientImpl) SetSpecVersion(ctx context.Context, specID akid.APISpecID, versionName string) error {
219219
resp := struct {
220220
}{}
@@ -228,6 +228,7 @@ func (c *learnClientImpl) SetSpecVersion(ctx context.Context, specID akid.APISpe
228228
}
229229

230230
// Returns events aggregated in 1-minute intervals.
231+
// Deprecated: Used in get command which is deprecated.
231232
func (c *learnClientImpl) GetTimeline(ctx context.Context, serviceID akid.ServiceID, deployment string, start time.Time, end time.Time, limit int) (kgxapi.TimelineResponse, error) {
232233
path := fmt.Sprintf("/v1/services/%s/timeline/%s/query",
233234
akid.String(serviceID), deployment)
@@ -249,6 +250,7 @@ func (c *learnClientImpl) GetTimeline(ctx context.Context, serviceID akid.Servic
249250
}
250251

251252
// Return the edges of the service graph in the specified time window
253+
// Deprecated: Used in get command which is deprecated.
252254
func (c *learnClientImpl) GetGraphEdges(ctx context.Context, serviceID akid.ServiceID, deployment string, start time.Time, end time.Time, graphType string) (kgxapi.GraphResponse, error) {
253255
path := fmt.Sprintf("/v1/services/%s/servicegraph/%s/query",
254256
akid.String(serviceID), deployment)

0 commit comments

Comments
 (0)