From 0093c13f3d39df9c214a2abb2cb6b142fb4b6dec Mon Sep 17 00:00:00 2001 From: Maxim Babichev Date: Sat, 23 Mar 2024 19:10:44 +0300 Subject: [PATCH 1/2] Update changelog.yml Signed-off-by: Maxim Babichev --- .github/workflows/changelog.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index df3dfd1..e1723e8 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -11,4 +11,4 @@ jobs: permissions: contents: write secrets: inherit - uses: bavix/.github/.github/workflows/changelog.yml@0.2.4 + uses: bavix/.github/.github/workflows/changelog.yml@0.2.5 From fcbf37398d65d26b69b3b652b611fd1dfe7aa422 Mon Sep 17 00:00:00 2001 From: Github bot Date: Sat, 23 Mar 2024 16:11:14 +0000 Subject: [PATCH 2/2] sdk generated --- api.gen.go | 334 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) diff --git a/api.gen.go b/api.gen.go index d3fd57f..4a6a37d 100644 --- a/api.gen.go +++ b/api.gen.go @@ -31,6 +31,12 @@ type MessageOK struct { Time time.Time `json:"time"` } +// Method defines model for Method. +type Method struct { + Id string `json:"id"` + Name string `json:"name"` +} + // SearchRequest defines model for SearchRequest. type SearchRequest struct { Data interface{} `json:"data"` @@ -48,6 +54,14 @@ type SearchResponse struct { Headers map[string]string `json:"headers,omitempty"` } +// Service defines model for Service. +type Service struct { + Id string `json:"id"` + Methods []Method `json:"methods"` + Name string `json:"name"` + Package string `json:"package"` +} + // Stub defines model for Stub. type Stub struct { Headers StubHeaders `json:"headers,omitempty"` @@ -177,6 +191,12 @@ type ClientInterface interface { // Readiness request Readiness(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + // ServicesList request + ServicesList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ServiceMethodsList request + ServiceMethodsList(ctx context.Context, serviceID string, reqEditors ...RequestEditorFn) (*http.Response, error) + // PurgeStubs request PurgeStubs(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -206,6 +226,9 @@ type ClientInterface interface { // DeleteStubByID request DeleteStubByID(ctx context.Context, uuid ID, reqEditors ...RequestEditorFn) (*http.Response, error) + + // FindByID request + FindByID(ctx context.Context, uuid ID, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) Liveness(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -232,6 +255,30 @@ func (c *Client) Readiness(ctx context.Context, reqEditors ...RequestEditorFn) ( return c.Client.Do(req) } +func (c *Client) ServicesList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewServicesListRequest(c.Server) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) ServiceMethodsList(ctx context.Context, serviceID string, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewServiceMethodsListRequest(c.Server, serviceID) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) PurgeStubs(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewPurgeStubsRequest(c.Server) if err != nil { @@ -364,6 +411,18 @@ func (c *Client) DeleteStubByID(ctx context.Context, uuid ID, reqEditors ...Requ return c.Client.Do(req) } +func (c *Client) FindByID(ctx context.Context, uuid ID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFindByIDRequest(c.Server, uuid) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + // NewLivenessRequest generates requests for Liveness func NewLivenessRequest(server string) (*http.Request, error) { var err error @@ -418,6 +477,67 @@ func NewReadinessRequest(server string) (*http.Request, error) { return req, nil } +// NewServicesListRequest generates requests for ServicesList +func NewServicesListRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/services") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewServiceMethodsListRequest generates requests for ServiceMethodsList +func NewServiceMethodsListRequest(server string, serviceID string) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "serviceID", runtime.ParamLocationPath, serviceID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/services/%s/methods", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewPurgeStubsRequest generates requests for PurgeStubs func NewPurgeStubsRequest(server string) (*http.Request, error) { var err error @@ -680,6 +800,40 @@ func NewDeleteStubByIDRequest(server string, uuid ID) (*http.Request, error) { return req, nil } +// NewFindByIDRequest generates requests for FindByID +func NewFindByIDRequest(server string, uuid ID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "uuid", runtime.ParamLocationPath, uuid) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/stubs/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { for _, r := range c.RequestEditors { if err := r(ctx, req); err != nil { @@ -729,6 +883,12 @@ type ClientWithResponsesInterface interface { // ReadinessWithResponse request ReadinessWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ReadinessResponse, error) + // ServicesListWithResponse request + ServicesListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ServicesListResponse, error) + + // ServiceMethodsListWithResponse request + ServiceMethodsListWithResponse(ctx context.Context, serviceID string, reqEditors ...RequestEditorFn) (*ServiceMethodsListResponse, error) + // PurgeStubsWithResponse request PurgeStubsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PurgeStubsResponse, error) @@ -758,6 +918,9 @@ type ClientWithResponsesInterface interface { // DeleteStubByIDWithResponse request DeleteStubByIDWithResponse(ctx context.Context, uuid ID, reqEditors ...RequestEditorFn) (*DeleteStubByIDResponse, error) + + // FindByIDWithResponse request + FindByIDWithResponse(ctx context.Context, uuid ID, reqEditors ...RequestEditorFn) (*FindByIDResponse, error) } type LivenessResponse struct { @@ -804,6 +967,50 @@ func (r ReadinessResponse) StatusCode() int { return 0 } +type ServicesListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Service +} + +// Status returns HTTPResponse.Status +func (r ServicesListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ServicesListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type ServiceMethodsListResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Method +} + +// Status returns HTTPResponse.Status +func (r ServiceMethodsListResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r ServiceMethodsListResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type PurgeStubsResponse struct { Body []byte HTTPResponse *http.Response @@ -979,6 +1186,28 @@ func (r DeleteStubByIDResponse) StatusCode() int { return 0 } +type FindByIDResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Stub +} + +// Status returns HTTPResponse.Status +func (r FindByIDResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FindByIDResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + // LivenessWithResponse request returning *LivenessResponse func (c *ClientWithResponses) LivenessWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*LivenessResponse, error) { rsp, err := c.Liveness(ctx, reqEditors...) @@ -997,6 +1226,24 @@ func (c *ClientWithResponses) ReadinessWithResponse(ctx context.Context, reqEdit return ParseReadinessResponse(rsp) } +// ServicesListWithResponse request returning *ServicesListResponse +func (c *ClientWithResponses) ServicesListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*ServicesListResponse, error) { + rsp, err := c.ServicesList(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseServicesListResponse(rsp) +} + +// ServiceMethodsListWithResponse request returning *ServiceMethodsListResponse +func (c *ClientWithResponses) ServiceMethodsListWithResponse(ctx context.Context, serviceID string, reqEditors ...RequestEditorFn) (*ServiceMethodsListResponse, error) { + rsp, err := c.ServiceMethodsList(ctx, serviceID, reqEditors...) + if err != nil { + return nil, err + } + return ParseServiceMethodsListResponse(rsp) +} + // PurgeStubsWithResponse request returning *PurgeStubsResponse func (c *ClientWithResponses) PurgeStubsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PurgeStubsResponse, error) { rsp, err := c.PurgeStubs(ctx, reqEditors...) @@ -1093,6 +1340,15 @@ func (c *ClientWithResponses) DeleteStubByIDWithResponse(ctx context.Context, uu return ParseDeleteStubByIDResponse(rsp) } +// FindByIDWithResponse request returning *FindByIDResponse +func (c *ClientWithResponses) FindByIDWithResponse(ctx context.Context, uuid ID, reqEditors ...RequestEditorFn) (*FindByIDResponse, error) { + rsp, err := c.FindByID(ctx, uuid, reqEditors...) + if err != nil { + return nil, err + } + return ParseFindByIDResponse(rsp) +} + // ParseLivenessResponse parses an HTTP response from a LivenessWithResponse call func ParseLivenessResponse(rsp *http.Response) (*LivenessResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -1145,6 +1401,58 @@ func ParseReadinessResponse(rsp *http.Response) (*ReadinessResponse, error) { return response, nil } +// ParseServicesListResponse parses an HTTP response from a ServicesListWithResponse call +func ParseServicesListResponse(rsp *http.Response) (*ServicesListResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ServicesListResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Service + if err := jsonUnmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + +// ParseServiceMethodsListResponse parses an HTTP response from a ServiceMethodsListWithResponse call +func ParseServiceMethodsListResponse(rsp *http.Response) (*ServiceMethodsListResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ServiceMethodsListResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Method + if err := jsonUnmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +} + // ParsePurgeStubsResponse parses an HTTP response from a PurgeStubsWithResponse call func ParsePurgeStubsResponse(rsp *http.Response) (*PurgeStubsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -1324,3 +1632,29 @@ func ParseDeleteStubByIDResponse(rsp *http.Response) (*DeleteStubByIDResponse, e return response, nil } + +// ParseFindByIDResponse parses an HTTP response from a FindByIDWithResponse call +func ParseFindByIDResponse(rsp *http.Response) (*FindByIDResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FindByIDResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Stub + if err := jsonUnmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + } + + return response, nil +}