| |
| package openmeter |
|
|
| import ( |
| "context" |
| "fmt" |
| "net/http" |
| ) |
|
|
| func NewAuthClientWithResponses(server string, apiSecret string, opts ...ClientOption) (*ClientWithResponses, error) { |
| o := []ClientOption{WithRequestEditorFn(func(ctx context.Context, req *http.Request) error { |
| req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiSecret)) |
| return nil |
| })} |
| o = append(opts, o...) |
|
|
| return NewClientWithResponses(server, o...) |
| } |
|
|
| func NewAuthClient(server string, apiSecret string, opts ...ClientOption) (*Client, error) { |
| o := []ClientOption{WithRequestEditorFn(func(ctx context.Context, req *http.Request) error { |
| req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", apiSecret)) |
| return nil |
| })} |
| o = append(opts, o...) |
|
|
| return NewClient(server, o...) |
| } |
|
|
| |
| func (c *Client) IngestEvent(ctx context.Context, event Event, reqEditors ...RequestEditorFn) (*http.Response, error) { |
| return c.IngestEventsWithApplicationCloudeventsPlusJSONBody(ctx, event, reqEditors...) |
| } |
|
|
| |
| func (c *Client) IngestEventBatch(ctx context.Context, events []Event, reqEditors ...RequestEditorFn) (*http.Response, error) { |
| return c.IngestEventsWithApplicationCloudeventsBatchPlusJSONBody(ctx, events, reqEditors...) |
| } |
|
|
| |
| func (c *ClientWithResponses) IngestEventWithResponse(ctx context.Context, event Event, reqEditors ...RequestEditorFn) (*IngestEventsResponse, error) { |
| return c.IngestEventsWithApplicationCloudeventsPlusJSONBodyWithResponse(ctx, event, reqEditors...) |
| } |
|
|
| |
| func (c *ClientWithResponses) IngestEventBatchWithResponse(ctx context.Context, events []Event, reqEditors ...RequestEditorFn) (*IngestEventsResponse, error) { |
| return c.IngestEventsWithApplicationCloudeventsBatchPlusJSONBodyWithResponse(ctx, events, reqEditors...) |
| } |
|
|