diff --git a/csharp/Svix/Message.cs b/csharp/Svix/Message.cs index e12229c3d..276e24b16 100644 --- a/csharp/Svix/Message.cs +++ b/csharp/Svix/Message.cs @@ -128,6 +128,7 @@ public List List(string appId, MessageListOptions options = null, st options?.Before, options?.After, options?.WithContent, + options?.Tag, options?.EventTypes ); @@ -156,6 +157,7 @@ public async Task> ListAsync(string appId, MessageListOptions o options?.Before, options?.After, options?.WithContent, + options?.Tag, options?.EventTypes, cancellationToken); diff --git a/csharp/Svix/Models/MessageListOptions.cs b/csharp/Svix/Models/MessageListOptions.cs index 7b273367d..290d9343c 100644 --- a/csharp/Svix/Models/MessageListOptions.cs +++ b/csharp/Svix/Models/MessageListOptions.cs @@ -14,5 +14,7 @@ public sealed class MessageListOptions : ListOptions public DateTime? After { get; set; } public bool? WithContent { get; set; } + + public string? Tag { get; set; } } } \ No newline at end of file diff --git a/csharp/Svix/Statistics.cs b/csharp/Svix/Statistics.cs index 3e99fee9f..447195ddb 100644 --- a/csharp/Svix/Statistics.cs +++ b/csharp/Svix/Statistics.cs @@ -22,7 +22,7 @@ public AppUsageStatsOut AggregateAppStats(AppUsageStatsIn appUsageStatsIn, strin { try { - var res = _statisticsApi.AggregateAppStats( + var res = _statisticsApi.V1StatisticsAggregateAppStats( appUsageStatsIn, idempotencyKey); @@ -43,7 +43,7 @@ public async Task AggregateAppStatsAsync(AppUsageStatsIn appUs { try { - var res = await _statisticsApi.AggregateAppStatsAsync( + var res = await _statisticsApi.V1StatisticsAggregateAppStatsAsync( appUsageStatsIn, idempotencyKey); @@ -64,7 +64,7 @@ public AggregateEventTypesOut AggregateEventTypes() { try { - var res = _statisticsApi.AggregateEventTypes(); + var res = _statisticsApi.V1StatisticsAggregateEventTypes(); return res; } @@ -83,7 +83,7 @@ public async Task AggregateEventTypesAsync() { try { - var res = await _statisticsApi.AggregateEventTypesAsync(); + var res = await _statisticsApi.V1StatisticsAggregateEventTypesAsync(); return res; } diff --git a/go/internal/openapi/api_message.go b/go/internal/openapi/api_message.go index 7d45e5267..f132d1f81 100644 --- a/go/internal/openapi/api_message.go +++ b/go/internal/openapi/api_message.go @@ -1046,6 +1046,7 @@ type ApiV1MessageListRequest struct { before *time.Time after *time.Time withContent *bool + tag *string eventTypes *[]string } @@ -1073,6 +1074,10 @@ func (r ApiV1MessageListRequest) WithContent(withContent bool) ApiV1MessageListR r.withContent = &withContent return r } +func (r ApiV1MessageListRequest) Tag(tag string) ApiV1MessageListRequest { + r.tag = &tag + return r +} func (r ApiV1MessageListRequest) EventTypes(eventTypes []string) ApiV1MessageListRequest { r.eventTypes = &eventTypes return r @@ -1156,6 +1161,9 @@ func (a *MessageApiService) V1MessageListExecute(r ApiV1MessageListRequest) (Lis if r.withContent != nil { localVarQueryParams.Add("with_content", parameterToString(*r.withContent, "")) } + if r.tag != nil { + localVarQueryParams.Add("tag", parameterToString(*r.tag, "")) + } if r.eventTypes != nil { t := *r.eventTypes if reflect.TypeOf(t).Kind() == reflect.Slice { diff --git a/go/internal/openapi/api_statistics.go b/go/internal/openapi/api_statistics.go index 8f496ab2b..6f2d2a3dd 100644 --- a/go/internal/openapi/api_statistics.go +++ b/go/internal/openapi/api_statistics.go @@ -28,37 +28,37 @@ var ( // StatisticsApiService StatisticsApi service type StatisticsApiService service -type ApiAggregateAppStatsRequest struct { +type ApiV1StatisticsAggregateAppStatsRequest struct { ctx _context.Context ApiService *StatisticsApiService appUsageStatsIn *AppUsageStatsIn idempotencyKey *string } -func (r ApiAggregateAppStatsRequest) AppUsageStatsIn(appUsageStatsIn AppUsageStatsIn) ApiAggregateAppStatsRequest { +func (r ApiV1StatisticsAggregateAppStatsRequest) AppUsageStatsIn(appUsageStatsIn AppUsageStatsIn) ApiV1StatisticsAggregateAppStatsRequest { r.appUsageStatsIn = &appUsageStatsIn return r } -func (r ApiAggregateAppStatsRequest) IdempotencyKey(idempotencyKey string) ApiAggregateAppStatsRequest { +func (r ApiV1StatisticsAggregateAppStatsRequest) IdempotencyKey(idempotencyKey string) ApiV1StatisticsAggregateAppStatsRequest { r.idempotencyKey = &idempotencyKey return r } -func (r ApiAggregateAppStatsRequest) Execute() (AppUsageStatsOut, *_nethttp.Response, error) { - return r.ApiService.AggregateAppStatsExecute(r) +func (r ApiV1StatisticsAggregateAppStatsRequest) Execute() (AppUsageStatsOut, *_nethttp.Response, error) { + return r.ApiService.V1StatisticsAggregateAppStatsExecute(r) } /* - * AggregateAppStats Aggregate App Stats + * V1StatisticsAggregateAppStats Aggregate App Stats * Creates a background task to calculate the message destinations for all applications in the environment. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation. * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @return ApiAggregateAppStatsRequest + * @return ApiV1StatisticsAggregateAppStatsRequest */ -func (a *StatisticsApiService) AggregateAppStats(ctx _context.Context) ApiAggregateAppStatsRequest { - return ApiAggregateAppStatsRequest{ +func (a *StatisticsApiService) V1StatisticsAggregateAppStats(ctx _context.Context) ApiV1StatisticsAggregateAppStatsRequest { + return ApiV1StatisticsAggregateAppStatsRequest{ ApiService: a, ctx: ctx, } @@ -68,7 +68,7 @@ func (a *StatisticsApiService) AggregateAppStats(ctx _context.Context) ApiAggreg * Execute executes the request * @return AppUsageStatsOut */ -func (a *StatisticsApiService) AggregateAppStatsExecute(r ApiAggregateAppStatsRequest) (AppUsageStatsOut, *_nethttp.Response, error) { +func (a *StatisticsApiService) V1StatisticsAggregateAppStatsExecute(r ApiV1StatisticsAggregateAppStatsRequest) (AppUsageStatsOut, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPost localVarPostBody interface{} @@ -78,7 +78,7 @@ func (a *StatisticsApiService) AggregateAppStatsExecute(r ApiAggregateAppStatsRe localVarReturnValue AppUsageStatsOut ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StatisticsApiService.AggregateAppStats") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StatisticsApiService.V1StatisticsAggregateAppStats") if err != nil { return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} } @@ -220,27 +220,27 @@ func (a *StatisticsApiService) AggregateAppStatsExecute(r ApiAggregateAppStatsRe return localVarReturnValue, localVarHTTPResponse, nil } -type ApiAggregateEventTypesRequest struct { +type ApiV1StatisticsAggregateEventTypesRequest struct { ctx _context.Context ApiService *StatisticsApiService } -func (r ApiAggregateEventTypesRequest) Execute() (AggregateEventTypesOut, *_nethttp.Response, error) { - return r.ApiService.AggregateEventTypesExecute(r) +func (r ApiV1StatisticsAggregateEventTypesRequest) Execute() (AggregateEventTypesOut, *_nethttp.Response, error) { + return r.ApiService.V1StatisticsAggregateEventTypesExecute(r) } /* - * AggregateEventTypes Aggregate Event Types + * V1StatisticsAggregateEventTypes Aggregate Event Types * Creates a background task to calculate the listed event types for all apps in the organization. Note that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to retrieve the results of the operation. * @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - * @return ApiAggregateEventTypesRequest + * @return ApiV1StatisticsAggregateEventTypesRequest */ -func (a *StatisticsApiService) AggregateEventTypes(ctx _context.Context) ApiAggregateEventTypesRequest { - return ApiAggregateEventTypesRequest{ +func (a *StatisticsApiService) V1StatisticsAggregateEventTypes(ctx _context.Context) ApiV1StatisticsAggregateEventTypesRequest { + return ApiV1StatisticsAggregateEventTypesRequest{ ApiService: a, ctx: ctx, } @@ -250,7 +250,7 @@ func (a *StatisticsApiService) AggregateEventTypes(ctx _context.Context) ApiAggr * Execute executes the request * @return AggregateEventTypesOut */ -func (a *StatisticsApiService) AggregateEventTypesExecute(r ApiAggregateEventTypesRequest) (AggregateEventTypesOut, *_nethttp.Response, error) { +func (a *StatisticsApiService) V1StatisticsAggregateEventTypesExecute(r ApiV1StatisticsAggregateEventTypesRequest) (AggregateEventTypesOut, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodPut localVarPostBody interface{} @@ -260,7 +260,7 @@ func (a *StatisticsApiService) AggregateEventTypesExecute(r ApiAggregateEventTyp localVarReturnValue AggregateEventTypesOut ) - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StatisticsApiService.AggregateEventTypes") + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "StatisticsApiService.V1StatisticsAggregateEventTypes") if err != nil { return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} } diff --git a/go/internal/openapi/model_message_in.go b/go/internal/openapi/model_message_in.go index 233a801d1..899958d9d 100644 --- a/go/internal/openapi/model_message_in.go +++ b/go/internal/openapi/model_message_in.go @@ -25,6 +25,8 @@ type MessageIn struct { EventType string `json:"eventType"` Payload map[string]interface{} `json:"payload"` PayloadRetentionPeriod *int64 `json:"payloadRetentionPeriod,omitempty"` + // List of free-form tags that can be filtered by when listing messages + Tags []string `json:"tags,omitempty"` } // NewMessageIn instantiates a new MessageIn object @@ -237,6 +239,39 @@ func (o *MessageIn) SetPayloadRetentionPeriod(v int64) { o.PayloadRetentionPeriod = &v } +// GetTags returns the Tags field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *MessageIn) GetTags() []string { + if o == nil { + var ret []string + return ret + } + return o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned +func (o *MessageIn) GetTagsOk() (*[]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return &o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *MessageIn) HasTags() bool { + if o != nil && o.Tags != nil { + return true + } + + return false +} + +// SetTags gets a reference to the given []string and assigns it to the Tags field. +func (o *MessageIn) SetTags(v []string) { + o.Tags = v +} + func (o MessageIn) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} if o.Application != nil { @@ -257,6 +292,9 @@ func (o MessageIn) MarshalJSON() ([]byte, error) { if o.PayloadRetentionPeriod != nil { toSerialize["payloadRetentionPeriod"] = o.PayloadRetentionPeriod } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } return json.Marshal(toSerialize) } diff --git a/go/statistics.go b/go/statistics.go index 0677fcdbf..d7dd43058 100644 --- a/go/statistics.go +++ b/go/statistics.go @@ -17,7 +17,7 @@ type ( ) func (s *Statistics) AggregateAppStats(ctx context.Context, appUsageStatsIn *AppUsageStatsIn, options *PostOptions) (*AppUsageStatsOut, error) { - req := s.api.StatisticsApi.AggregateAppStats(ctx) + req := s.api.StatisticsApi.V1StatisticsAggregateAppStats(ctx) if appUsageStatsIn != nil { req = req.AppUsageStatsIn(*appUsageStatsIn) } @@ -35,7 +35,7 @@ func (s *Statistics) AggregateAppStats(ctx context.Context, appUsageStatsIn *App } func (s *Statistics) AggregateEventTypes(ctx context.Context) (*AggregateEventTypesOut, error) { - req := s.api.StatisticsApi.AggregateEventTypes(ctx) + req := s.api.StatisticsApi.V1StatisticsAggregateEventTypes(ctx) out, res, err := req.Execute() if err != nil { diff --git a/java/lib/src/main/java/com/svix/Message.java b/java/lib/src/main/java/com/svix/Message.java index 6e8642dba..f7922e81c 100644 --- a/java/lib/src/main/java/com/svix/Message.java +++ b/java/lib/src/main/java/com/svix/Message.java @@ -26,6 +26,7 @@ public ListResponseMessageOut list(final String appId, final MessageListOptions options.getBefore(), options.getAfter(), options.getWithContent(), + options.getTag(), new HashSet<>(options.getEventTypes()) ); } catch (com.svix.internal.ApiException e) { diff --git a/java/lib/src/main/java/com/svix/MessageListOptions.java b/java/lib/src/main/java/com/svix/MessageListOptions.java index dfb3871a8..7a4d82444 100644 --- a/java/lib/src/main/java/com/svix/MessageListOptions.java +++ b/java/lib/src/main/java/com/svix/MessageListOptions.java @@ -9,6 +9,7 @@ public class MessageListOptions extends ListOptions { private OffsetDateTime after; private String channel; private Boolean withContent; + private String tag; public MessageListOptions eventTypes(final List eventTypes) { this.eventTypes = eventTypes; @@ -74,4 +75,17 @@ public MessageListOptions withContent(final Boolean withContent) { this.withContent = withContent; return this; } + + public String getTag() { + return tag; + } + + public MessageListOptions tag(final String tag) { + this.tag = tag; + return this; + } + + public void setTag(final String tag) { + this.tag = tag; + } } diff --git a/java/lib/src/main/java/com/svix/Statistics.java b/java/lib/src/main/java/com/svix/Statistics.java index e99b60a8a..021ba9fe7 100644 --- a/java/lib/src/main/java/com/svix/Statistics.java +++ b/java/lib/src/main/java/com/svix/Statistics.java @@ -15,7 +15,7 @@ public class Statistics { public AppUsageStatsOut aggregateAppStats(final AppUsageStatsIn appUsageStatsIn, final PostOptions options) throws ApiException { try { - return api.aggregateAppStats(appUsageStatsIn, options.getIdempotencyKey()); + return api.v1StatisticsAggregateAppStats(appUsageStatsIn, options.getIdempotencyKey()); } catch (com.svix.internal.ApiException e) { throw Utils.wrapInternalApiException(e); } @@ -23,7 +23,7 @@ public AppUsageStatsOut aggregateAppStats(final AppUsageStatsIn appUsageStatsIn, public AggregateEventTypesOut aggregateEventTypes() throws com.svix.internal.ApiException { try { - return api.aggregateEventTypes(); + return api.v1StatisticsAggregateEventTypes(); } catch (com.svix.internal.ApiException e) { throw Utils.wrapInternalApiException(e); } diff --git a/javascript/src/index.ts b/javascript/src/index.ts index 79065ca68..67dfc1cee 100644 --- a/javascript/src/index.ts +++ b/javascript/src/index.ts @@ -890,14 +890,14 @@ class Statistics { } public aggregateEventTypes(): Promise { - return this.api.aggregateEventTypes({}); + return this.api.v1StatisticsAggregateEventTypes({}); } public aggregateAppStats( appUsageStatsIn: AppUsageStatsIn, options?: PostOptions ): Promise { - return this.api.aggregateAppStats({ + return this.api.v1StatisticsAggregateAppStats({ appUsageStatsIn, ...options, }); diff --git a/kotlin/lib/src/main/kotlin/Message.kt b/kotlin/lib/src/main/kotlin/Message.kt index 3cdc688e8..03bbc6484 100644 --- a/kotlin/lib/src/main/kotlin/Message.kt +++ b/kotlin/lib/src/main/kotlin/Message.kt @@ -26,6 +26,7 @@ class Message internal constructor(token: String, options: SvixOptions) { options.before, options.after, options.withContent, + options.tag, HashSet(options.eventTypes) ) } catch (e: Exception) { diff --git a/kotlin/lib/src/main/kotlin/MessageListOptions.kt b/kotlin/lib/src/main/kotlin/MessageListOptions.kt index 06e86d2b2..6fd9450a7 100644 --- a/kotlin/lib/src/main/kotlin/MessageListOptions.kt +++ b/kotlin/lib/src/main/kotlin/MessageListOptions.kt @@ -8,6 +8,7 @@ class MessageListOptions : ListOptions() { var after: OffsetDateTime? = null var channel: String? = null var withContent: Boolean? = null + var tag: String? = null fun eventTypes(eventTypes: List) = apply { this.eventTypes = eventTypes } @@ -21,4 +22,5 @@ class MessageListOptions : ListOptions() { override fun limit(limit: Int) = apply { super.limit(limit) } fun withContent(withContent: Boolean) = apply { this.withContent = withContent } + fun tag(tag: String) = apply { this.tag = tag } } diff --git a/kotlin/lib/src/main/kotlin/Statistics.kt b/kotlin/lib/src/main/kotlin/Statistics.kt index 945ceb186..7334bc872 100644 --- a/kotlin/lib/src/main/kotlin/Statistics.kt +++ b/kotlin/lib/src/main/kotlin/Statistics.kt @@ -18,7 +18,7 @@ class Statistics internal constructor(token: String, options: SvixOptions) { suspend fun aggregateAppStats(appUsageStatsIn: AppUsageStatsIn, options: PostOptions = PostOptions()): AppUsageStatsOut { try { - return api.aggregateAppStats(appUsageStatsIn, options.idempotencyKey) + return api.v1StatisticsAggregateAppStats(appUsageStatsIn, options.idempotencyKey) } catch (e: Exception) { throw ApiException.wrap(e) } @@ -26,7 +26,7 @@ class Statistics internal constructor(token: String, options: SvixOptions) { suspend fun aggregateEventTypes(): AggregateEventTypesOut { try { - return api.aggregateEventTypes() + return api.v1StatisticsAggregateEventTypes() } catch (e: Exception) { throw ApiException.wrap(e) } diff --git a/openapi.json b/openapi.json index 2c82e13ac..a7078cec5 100644 --- a/openapi.json +++ b/openapi.json @@ -2960,6 +2960,24 @@ "maximum": 90, "minimum": 5, "type": "integer" + }, + "tags": { + "description": "List of free-form tags that can be filtered by when listing messages", + "example": [ + "my_tag", + "other" + ], + "items": { + "example": "project_1337", + "maxLength": 128, + "pattern": "^[a-zA-Z0-9\\-_.]+$", + "type": "string" + }, + "maxItems": 5, + "minItems": 1, + "nullable": true, + "type": "array", + "uniqueItems": true } }, "required": [ @@ -11193,6 +11211,20 @@ }, "style": "form" }, + { + "description": "Filter messages matching the provided tag", + "in": "query", + "name": "tag", + "schema": { + "description": "Filter messages matching the provided tag", + "example": "project_1337", + "maxLength": 128, + "nullable": true, + "pattern": "^[a-zA-Z0-9\\-_.]+$", + "type": "string" + }, + "style": "form" + }, { "description": "Filter response based on the event type", "in": "query", @@ -11522,62 +11554,62 @@ { "label": "JavaScript", "lang": "JavaScript", - "source": "const messageOut = await svix.message.create(\"app_id\", {\n eventId: \"unique-msg-identifier\",\n eventType: \"user.signup\",\n payload: {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n channels: [\"project_123\", \"group_2\"],\n payloadRetentionPeriod: 90,\n application: null\n});" + "source": "const messageOut = await svix.message.create(\"app_id\", {\n eventId: \"unique-msg-identifier\",\n eventType: \"user.signup\",\n payload: {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n channels: [\"project_123\", \"group_2\"],\n payloadRetentionPeriod: 90,\n application: null,\n tags: [\"my_tag\", \"other\"]\n});" }, { "label": "TypeScript", "lang": "JavaScript", - "source": "const messageOut = await svix.message.create(\"app_id\", {\n eventId: \"unique-msg-identifier\",\n eventType: \"user.signup\",\n payload: {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n channels: [\"project_123\", \"group_2\"],\n payloadRetentionPeriod: 90,\n application: null\n});" + "source": "const messageOut = await svix.message.create(\"app_id\", {\n eventId: \"unique-msg-identifier\",\n eventType: \"user.signup\",\n payload: {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n channels: [\"project_123\", \"group_2\"],\n payloadRetentionPeriod: 90,\n application: null,\n tags: [\"my_tag\", \"other\"]\n});" }, { "label": "Python", "lang": "Python", - "source": "message_out = svix.message.create(\"app_id\", MessageIn(\n event_id=\"unique-msg-identifier\",\n event_type=\"user.signup\",\n payload={\"email\": \"test@example.com\", \"type\": \"user.created\", \"username\": \"test_user\"},\n channels=[\"project_123\", \"group_2\"],\n payload_retention_period=90,\n application=None\n), None)" + "source": "message_out = svix.message.create(\"app_id\", MessageIn(\n event_id=\"unique-msg-identifier\",\n event_type=\"user.signup\",\n payload={\"email\": \"test@example.com\", \"type\": \"user.created\", \"username\": \"test_user\"},\n channels=[\"project_123\", \"group_2\"],\n payload_retention_period=90,\n application=None,\n tags=[\"my_tag\", \"other\"]\n), None)" }, { "label": "Python (Async)", "lang": "Python", - "source": "message_out = await svix.message.create(\"app_id\", MessageIn(\n event_id=\"unique-msg-identifier\",\n event_type=\"user.signup\",\n payload={\"email\": \"test@example.com\", \"type\": \"user.created\", \"username\": \"test_user\"},\n channels=[\"project_123\", \"group_2\"],\n payload_retention_period=90,\n application=None\n), None)" + "source": "message_out = await svix.message.create(\"app_id\", MessageIn(\n event_id=\"unique-msg-identifier\",\n event_type=\"user.signup\",\n payload={\"email\": \"test@example.com\", \"type\": \"user.created\", \"username\": \"test_user\"},\n channels=[\"project_123\", \"group_2\"],\n payload_retention_period=90,\n application=None,\n tags=[\"my_tag\", \"other\"]\n), None)" }, { "label": "Go", "lang": "Go", - "source": "messageOut, err := svixClient.Message.Create(ctx, \"app_id\", &MessageIn{\n EventId: \"unique-msg-identifier\",\n EventType: \"user.signup\",\n Payload: map[string]interface{}{\"email\": \"test@example.com\", \"type\": \"user.created\", \"username\": \"test_user\"},\n Channels: []string{\"project_123\", \"group_2\"},\n PayloadRetentionPeriod: 90,\n Application: nil,\n})" + "source": "messageOut, err := svixClient.Message.Create(ctx, \"app_id\", &MessageIn{\n EventId: \"unique-msg-identifier\",\n EventType: \"user.signup\",\n Payload: map[string]interface{}{\"email\": \"test@example.com\", \"type\": \"user.created\", \"username\": \"test_user\"},\n Channels: []string{\"project_123\", \"group_2\"},\n PayloadRetentionPeriod: 90,\n Application: nil,\n Tags: []string{\"my_tag\", \"other\"},\n})" }, { "label": "Kotlin", "lang": "Kotlin", - "source": "val messageOut = svix.message.create(\"app_id\", MessageIn()\n .eventId(\"unique-msg-identifier\")\n .eventType(\"user.signup\")\n .payload(\"\"\"{\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"}\"\"\")\n .channels(arrayOf(\"project_123\", \"group_2\"))\n .payloadRetentionPeriod(90)\n .application(null)\n)" + "source": "val messageOut = svix.message.create(\"app_id\", MessageIn()\n .eventId(\"unique-msg-identifier\")\n .eventType(\"user.signup\")\n .payload(\"\"\"{\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"}\"\"\")\n .channels(arrayOf(\"project_123\", \"group_2\"))\n .payloadRetentionPeriod(90)\n .application(null)\n .tags(arrayOf(\"my_tag\", \"other\"))\n)" }, { "label": "Java", "lang": "Java", - "source": "MessageOut messageOut = svix.getMessage().create(\"app_id\", new MessageIn()\n .eventId(\"unique-msg-identifier\")\n .eventType(\"user.signup\")\n .payload(\"{\\\"email\\\":\\\"test@example.com\\\",\\\"type\\\":\\\"user.created\\\",\\\"username\\\":\\\"test_user\\\"}\")\n .channels(new String[]{\"project_123\", \"group_2\"})\n .payloadRetentionPeriod(90)\n .application(null)\n)" + "source": "MessageOut messageOut = svix.getMessage().create(\"app_id\", new MessageIn()\n .eventId(\"unique-msg-identifier\")\n .eventType(\"user.signup\")\n .payload(\"{\\\"email\\\":\\\"test@example.com\\\",\\\"type\\\":\\\"user.created\\\",\\\"username\\\":\\\"test_user\\\"}\")\n .channels(new String[]{\"project_123\", \"group_2\"})\n .payloadRetentionPeriod(90)\n .application(null)\n .tags(new String[]{\"my_tag\", \"other\"})\n)" }, { "label": "Ruby", "lang": "Ruby", - "source": "message_out = svix.message.create(\"app_id\", Svix::MessageIn.new({\n \"event_id\": \"unique-msg-identifier\",\n \"event_type\": \"user.signup\",\n \"payload\": {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n \"channels\": [\"project_123\", \"group_2\"],\n \"payload_retention_period\": 90,\n \"application\": nil\n}))" + "source": "message_out = svix.message.create(\"app_id\", Svix::MessageIn.new({\n \"event_id\": \"unique-msg-identifier\",\n \"event_type\": \"user.signup\",\n \"payload\": {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n \"channels\": [\"project_123\", \"group_2\"],\n \"payload_retention_period\": 90,\n \"application\": nil,\n \"tags\": [\"my_tag\", \"other\"]\n}))" }, { "label": "Rust", "lang": "Rust", - "source": "let message_out = svix.message().create(\"app_id\", MessageIn {\n event_id: Some(\"unique-msg-identifier\".to_string()),\n event_type: \"user.signup\".to_string(),\n payload: json!({\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"}),\n channels: Some(vec![\"project_123\".to_string(), \"group_2\".to_string()]),\n payload_retention_period: Some(90),\n application: None,\n}, None).await?;" + "source": "let message_out = svix.message().create(\"app_id\", MessageIn {\n event_id: Some(\"unique-msg-identifier\".to_string()),\n event_type: \"user.signup\".to_string(),\n payload: json!({\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"}),\n channels: Some(vec![\"project_123\".to_string(), \"group_2\".to_string()]),\n payload_retention_period: Some(90),\n application: None,\n tags: Some(vec![\"my_tag\".to_string(), \"other\".to_string()]),\n}, None).await?;" }, { "label": "C#", "lang": "C#", - "source": "var messageOut = await svix.Message.CreateAsync(\"app_id\", new MessageIn{\n eventId: \"unique-msg-identifier\",\n eventType: \"user.signup\",\n payload: new {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n channels: new string[] {\"project_123\", \"group_2\"},\n payloadRetentionPeriod: 90,\n application: null\n})" + "source": "var messageOut = await svix.Message.CreateAsync(\"app_id\", new MessageIn{\n eventId: \"unique-msg-identifier\",\n eventType: \"user.signup\",\n payload: new {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n channels: new string[] {\"project_123\", \"group_2\"},\n payloadRetentionPeriod: 90,\n application: null,\n tags: new string[] {\"my_tag\", \"other\"}\n})" }, { "label": "CLI", "lang": "Shell", - "source": "svix message create \"app_id\" '{\n \"eventId\": \"unique-msg-identifier\",\n \"eventType\": \"user.signup\",\n \"payload\": {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n \"channels\": [\"project_123\", \"group_2\"],\n \"payloadRetentionPeriod\": 90,\n \"application\": null\n}'" + "source": "svix message create \"app_id\" '{\n \"eventId\": \"unique-msg-identifier\",\n \"eventType\": \"user.signup\",\n \"payload\": {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n \"channels\": [\"project_123\", \"group_2\"],\n \"payloadRetentionPeriod\": 90,\n \"application\": null,\n \"tags\": [\"my_tag\", \"other\"]\n}'" }, { "label": "cURL", "lang": "Shell", - "source": "curl -X 'POST' \\\n 'https://api.eu.svix.com/api/v1/app/{app_id}/msg/' \\\n -H 'Authorization: Bearer AUTH_TOKEN' \\\n -H 'Accept: application/json' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"eventId\": \"unique-msg-identifier\",\n \"eventType\": \"user.signup\",\n \"payload\": {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n \"channels\": [\"project_123\", \"group_2\"],\n \"payloadRetentionPeriod\": 90,\n \"application\": null\n }'" + "source": "curl -X 'POST' \\\n 'https://api.eu.svix.com/api/v1/app/{app_id}/msg/' \\\n -H 'Authorization: Bearer AUTH_TOKEN' \\\n -H 'Accept: application/json' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"eventId\": \"unique-msg-identifier\",\n \"eventType\": \"user.signup\",\n \"payload\": {\"email\":\"test@example.com\",\"type\":\"user.created\",\"username\":\"test_user\"},\n \"channels\": [\"project_123\", \"group_2\"],\n \"payloadRetentionPeriod\": 90,\n \"application\": null,\n \"tags\": [\"my_tag\", \"other\"]\n }'" } ] } @@ -18025,7 +18057,7 @@ "/api/v1/stats/usage/app/": { "post": { "description": "Creates a background task to calculate the message destinations for all applications in the environment.\n\nNote that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to\nretrieve the results of the operation.", - "operationId": "aggregate_app_stats", + "operationId": "v1.statistics.aggregate-app-stats", "parameters": [ { "description": "The request's idempotency key", @@ -18137,13 +18169,75 @@ "summary": "Aggregate App Stats", "tags": [ "Statistics" + ], + "x-codeSamples": [ + { + "label": "JavaScript", + "lang": "JavaScript", + "source": "const appUsageStatsOut = await svix.statistics.aggregateAppStats({\n appIds: null\n});" + }, + { + "label": "TypeScript", + "lang": "JavaScript", + "source": "const appUsageStatsOut = await svix.statistics.aggregateAppStats({\n appIds: null\n});" + }, + { + "label": "Python", + "lang": "Python", + "source": "app_usage_stats_out = svix.statistics.aggregate_app_stats(AppUsageStatsIn(\n app_ids=None\n), None)" + }, + { + "label": "Python (Async)", + "lang": "Python", + "source": "app_usage_stats_out = await svix.statistics.aggregate_app_stats(AppUsageStatsIn(\n app_ids=None\n), None)" + }, + { + "label": "Go", + "lang": "Go", + "source": "appUsageStatsOut, err := svixClient.Statistics.AggregateAppStats(ctx, &AppUsageStatsIn{\n AppIds: nil,\n})" + }, + { + "label": "Kotlin", + "lang": "Kotlin", + "source": "val appUsageStatsOut = svix.statistics.aggregateAppStats(AppUsageStatsIn()\n .appIds(null)\n)" + }, + { + "label": "Java", + "lang": "Java", + "source": "AppUsageStatsOut appUsageStatsOut = svix.getStatistics().aggregateAppStats(new AppUsageStatsIn()\n .appIds(null)\n)" + }, + { + "label": "Ruby", + "lang": "Ruby", + "source": "app_usage_stats_out = svix.statistics.aggregate_app_stats(Svix::AppUsageStatsIn.new({\n \"app_ids\": nil\n}))" + }, + { + "label": "Rust", + "lang": "Rust", + "source": "let app_usage_stats_out = svix.statistics().aggregate_app_stats(AppUsageStatsIn {\n app_ids: None,\n}, None).await?;" + }, + { + "label": "C#", + "lang": "C#", + "source": "var appUsageStatsOut = await svix.Statistics.AggregateAppStatsAsync(new AppUsageStatsIn{\n appIds: null\n})" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "svix statistics aggregate-app-stats '{\n \"appIds\": null\n}'" + }, + { + "label": "cURL", + "lang": "Shell", + "source": "curl -X 'POST' \\\n 'https://api.eu.svix.com/api/v1/stats/usage/app/' \\\n -H 'Authorization: Bearer AUTH_TOKEN' \\\n -H 'Accept: application/json' \\\n -H 'Content-Type: application/json' \\\n -d '{\n \"appIds\": null\n }'" + } ] } }, "/api/v1/stats/usage/event-types/": { "put": { "description": "Creates a background task to calculate the listed event types for all apps in the organization.\n\nNote that this endpoint is asynchronous. You will need to poll the `Get Background Task` endpoint to\nretrieve the results of the operation.", - "operationId": "aggregate_event_types", + "operationId": "v1.statistics.aggregate-event-types", "responses": { "202": { "content": { @@ -18234,6 +18328,68 @@ "summary": "Aggregate Event Types", "tags": [ "Statistics" + ], + "x-codeSamples": [ + { + "label": "JavaScript", + "lang": "JavaScript", + "source": "const aggregateEventTypesOut = await svix.statistics.aggregateEventTypes();" + }, + { + "label": "TypeScript", + "lang": "JavaScript", + "source": "const aggregateEventTypesOut = await svix.statistics.aggregateEventTypes();" + }, + { + "label": "Python", + "lang": "Python", + "source": "aggregate_event_types_out = svix.statistics.aggregate_event_types()" + }, + { + "label": "Python (Async)", + "lang": "Python", + "source": "aggregate_event_types_out = await svix.statistics.aggregate_event_types()" + }, + { + "label": "Go", + "lang": "Go", + "source": "aggregateEventTypesOut, err := svixClient.Statistics.AggregateEventTypes(ctx)" + }, + { + "label": "Kotlin", + "lang": "Kotlin", + "source": "val aggregateEventTypesOut = svix.statistics.aggregateEventTypes()" + }, + { + "label": "Java", + "lang": "Java", + "source": "AggregateEventTypesOut aggregateEventTypesOut = svix.getStatistics().aggregateEventTypes()" + }, + { + "label": "Ruby", + "lang": "Ruby", + "source": "aggregate_event_types_out = svix.statistics.aggregate_event_types()" + }, + { + "label": "Rust", + "lang": "Rust", + "source": "let aggregate_event_types_out = svix.statistics().aggregate_event_types().await?;" + }, + { + "label": "C#", + "lang": "C#", + "source": "var aggregateEventTypesOut = await svix.Statistics.AggregateEventTypesAsync()" + }, + { + "label": "CLI", + "lang": "Shell", + "source": "svix statistics aggregate-event-types " + }, + { + "label": "cURL", + "lang": "Shell", + "source": "curl -X 'PUT' \\\n 'https://api.eu.svix.com/api/v1/stats/usage/event-types/' \\\n -H 'Authorization: Bearer AUTH_TOKEN' \\\n -H 'Accept: application/json' \\\n -H 'Content-Type: application/json'" + } ] } }, diff --git a/python/svix/api.py b/python/svix/api.py index 586b241e2..f88eeefa3 100644 --- a/python/svix/api.py +++ b/python/svix/api.py @@ -75,7 +75,7 @@ v1_message_attempt_list_by_msg, v1_message_attempt_resend, ) -from .internal.openapi_client.api.statistics import aggregate_app_stats, aggregate_event_types +from .internal.openapi_client.api.statistics import v1_statistics_aggregate_app_stats, v1_statistics_aggregate_event_types from .internal.openapi_client.client import AuthenticatedClient from .internal.openapi_client.models.app_portal_access_in import AppPortalAccessIn from .internal.openapi_client.models.app_portal_access_out import AppPortalAccessOut @@ -1043,28 +1043,28 @@ class StatisticsAsync(ApiBase): async def aggregate_app_stats( self, app_usage_stats_in: AppUsageStatsIn, options: PostOptions = PostOptions() ) -> AppUsageStatsOut: - return await aggregate_app_stats.asyncio( + return await v1_statistics_aggregate_app_stats.asyncio( client=self._client, json_body=app_usage_stats_in, **options.to_dict(), ) async def aggregate_event_types(self, task_id: str) -> AggregateEventTypesOut: - return await aggregate_event_types.asyncio(client=self._client) + return await v1_statistics_aggregate_event_types.asyncio(client=self._client) class Statistics(ApiBase): def aggregate_app_stats( self, app_usage_stats_in: AppUsageStatsIn, options: PostOptions = PostOptions() ) -> AppUsageStatsOut: - return aggregate_app_stats.sync( + return v1_statistics_aggregate_app_stats.sync( client=self._client, json_body=app_usage_stats_in, **options.to_dict(), ) def aggregate_event_types(self, task_id: str) -> AggregateEventTypesOut: - return aggregate_event_types.sync(client=self._client) + return v1_statistics_aggregate_event_types.sync(client=self._client) class ClientBase: diff --git a/rust/src/api.rs b/rust/src/api.rs index e236fae64..38eddcd08 100644 --- a/rust/src/api.rs +++ b/rust/src/api.rs @@ -803,6 +803,7 @@ pub struct MessageListOptions { pub after: Option, pub channel: Option, pub with_content: Option, + pub tag: Option, } pub struct Message<'a> { @@ -827,6 +828,7 @@ impl<'a> Message<'a> { after, channel, with_content, + tag, } = options.unwrap_or_default(); Ok(message_api::v1_message_list( self.cfg, @@ -839,6 +841,7 @@ impl<'a> Message<'a> { after, channel, with_content, + tag, }, ) .await?) @@ -1223,7 +1226,7 @@ impl<'a> Statistics<'a> { options: Option, ) -> Result { let options = options.unwrap_or_default(); - let params = statistics_api::AggregateAppStatsParams { + let params = statistics_api::V1StatisticsAggregateAppStatsParams { app_usage_stats_in: AppUsageStatsIn { app_ids, since, @@ -1231,10 +1234,10 @@ impl<'a> Statistics<'a> { }, idempotency_key: options.idempotency_key, }; - Ok(statistics_api::aggregate_app_stats(self.cfg, params).await?) + Ok(statistics_api::v1_statistics_aggregate_app_stats(self.cfg, params).await?) } pub async fn aggregate_event_types(&self) -> Result { - Ok(statistics_api::aggregate_event_types(self.cfg).await?) + Ok(statistics_api::v1_statistics_aggregate_event_types(self.cfg).await?) } }