Skip to content

Commit

Permalink
[create-pull-request] automated change (#285)
Browse files Browse the repository at this point in the history
Co-authored-by: nicolasparada <[email protected]>
  • Loading branch information
calyptia-ci and nicolasparada authored May 23, 2024
1 parent cade88a commit d399f41
Show file tree
Hide file tree
Showing 8 changed files with 689 additions and 189 deletions.
48 changes: 48 additions & 0 deletions client/processing_rule_legacy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package client

import (
"context"
"net/http"
"net/url"
"strconv"

"github.com/calyptia/api/types"
"github.com/calyptia/api/types/legacy"
)

func (c *Client) CreateProcessingRuleV1(ctx context.Context, in legacy.CreateProcessingRule) (legacy.CreatedProcessingRule, error) {
var out legacy.CreatedProcessingRule
return out, c.do(ctx, http.MethodPost, "/v1/pipelines/"+url.PathEscape(in.PipelineID)+"/processing_rules", in, &out)
}

func (c *Client) ProcessingRulesV1(ctx context.Context, params legacy.ProcessingRulesParams) (legacy.ProcessingRules, error) {
var out legacy.ProcessingRules
q := url.Values{}
if params.Last != nil {
q.Set("last", strconv.FormatUint(uint64(*params.Last), uintBase))
}
if params.Before != nil {
q.Set("before", *params.Before)
}
path := "/v1/pipelines/" + url.PathEscape(params.PipelineID) + "/processing_rules?" + q.Encode()
return out, c.do(ctx, http.MethodGet, path, nil, &out.Items, withCursor(&out.EndCursor))
}

func (c *Client) ProcessingRuleV1(ctx context.Context, processingRuleID string) (legacy.ProcessingRule, error) {
var out legacy.ProcessingRule
return out, c.do(ctx, http.MethodGet, "/v1/processing_rules/"+url.PathEscape(processingRuleID), nil, &out)
}

func (c *Client) UpdateProcessingRuleV1(ctx context.Context, in legacy.UpdateProcessingRule) (types.Updated, error) {
var out types.Updated
return out, c.do(ctx, http.MethodPatch, "/v1/processing_rules/"+url.PathEscape(in.ProcessingRuleID), in, &out)
}

func (c *Client) DeleteProcessingRuleV1(ctx context.Context, processingRuleID string) error {
return c.do(ctx, http.MethodDelete, "/v1/processing_rules/"+url.PathEscape(processingRuleID), nil, nil)
}

func (c *Client) PreviewProcessingRuleV1(ctx context.Context, in legacy.PreviewProcessingRule) ([]types.FluentBitLog, error) {
var out []types.FluentBitLog
return out, c.do(ctx, http.MethodPost, "/v1/preview_processing_rule", in, &out)
}
16 changes: 11 additions & 5 deletions client/processing_rule_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import (

func (c *Client) CreateProcessingRuleTemplate(ctx context.Context, in types.CreateProcessingRuleTemplate) (types.Created, error) {
var out types.Created
path := "/v1/projects/" + url.PathEscape(in.ProjectID) + "/processing_rule_templates"
path := "/v2/projects/" + url.PathEscape(in.ProjectID) + "/processing_rule_templates"
return out, c.do(ctx, http.MethodPost, path, in, &out)
}

func (c *Client) ProcessingRuleTemplates(ctx context.Context, in types.ListProcessingRuleTemplates) (types.ProcessingRuleTemplates, error) {
var out types.ProcessingRuleTemplates
path := "/v1/projects/" + url.PathEscape(in.ProjectID) + "/processing_rule_templates"
path := "/v2/projects/" + url.PathEscape(in.ProjectID) + "/processing_rule_templates"
q := url.Values{}
if in.Name != nil {
q.Set("name", *in.Name)
Expand All @@ -32,14 +32,20 @@ func (c *Client) ProcessingRuleTemplates(ctx context.Context, in types.ListProce
return out, c.do(ctx, http.MethodGet, path, nil, &out)
}

func (c *Client) ProcessingRuleTemplate(ctx context.Context, id string) (types.ProcessingRuleTemplate, error) {
var out types.ProcessingRuleTemplate
path := "/v2/processing_rule_templates/" + url.PathEscape(id)
return out, c.do(ctx, http.MethodGet, path, nil, &out)
}

func (c *Client) UpdateProcessingRuleTemplate(ctx context.Context, in types.UpdateProcessingRuleTemplate) (types.Updated, error) {
var out types.Updated
path := "/v1/processing_rule_templates/" + url.PathEscape(in.TemplateID)
path := "/v2/processing_rule_templates/" + url.PathEscape(in.ID)
return out, c.do(ctx, http.MethodPatch, path, in, &out)
}

func (c *Client) DeleteProcessingRuleTemplate(ctx context.Context, templateID string) (types.Deleted, error) {
func (c *Client) DeleteProcessingRuleTemplate(ctx context.Context, id string) (types.Deleted, error) {
var out types.Deleted
path := "/v1/processing_rule_templates/" + url.PathEscape(templateID)
path := "/v2/processing_rule_templates/" + url.PathEscape(id)
return out, c.do(ctx, http.MethodDelete, path, nil, &out)
}
Loading

0 comments on commit d399f41

Please sign in to comment.