From 2ce442f556640b8923976fa290f82e047e83de0a Mon Sep 17 00:00:00 2001 From: Jonas Platte Date: Thu, 30 Jan 2025 12:59:27 +0100 Subject: [PATCH] csharp: Adjust to changes of the lower-level generated code --- csharp/Svix/BackgroundTask.cs | 8 +- csharp/Svix/MessageAttempt.cs | 164 +++++++--------------- csharp/Svix/OperationalWebhookEndpoint.cs | 28 ++-- 3 files changed, 70 insertions(+), 130 deletions(-) diff --git a/csharp/Svix/BackgroundTask.cs b/csharp/Svix/BackgroundTask.cs index 8e8b7ccee..dcef6db39 100644 --- a/csharp/Svix/BackgroundTask.cs +++ b/csharp/Svix/BackgroundTask.cs @@ -26,7 +26,7 @@ public BackgroundTaskOut Get(string taskId, string idempotencyKey = default) { try { - var lBackgroundTask = _backgroundTaskApi.GetBackgroundTask(taskId); + var lBackgroundTask = _backgroundTaskApi.V1BackgroundTaskGet(taskId); return lBackgroundTask; } @@ -45,7 +45,7 @@ public async Task GetAsync(string taskId, string idempotencyK { try { - var lBackgroundTask = await _backgroundTaskApi.GetBackgroundTaskAsync(taskId); + var lBackgroundTask = await _backgroundTaskApi.V1BackgroundTaskGetAsync(taskId); return lBackgroundTask; } @@ -64,7 +64,7 @@ public ListResponseBackgroundTaskOut List(BackgroundTaskListOptions options = nu { try { - var lResponse = _backgroundTaskApi.ListBackgroundTasks( + var lResponse = _backgroundTaskApi.V1BackgroundTaskList( options?.Status, options?.Task, options?.Limit, @@ -88,7 +88,7 @@ public async Task ListAsync(BackgroundTaskListOpt { try { - var lResponse = await _backgroundTaskApi.ListBackgroundTasksAsync( + var lResponse = await _backgroundTaskApi.V1BackgroundTaskListAsync( options?.Status, options?.Task, options?.Limit, diff --git a/csharp/Svix/MessageAttempt.cs b/csharp/Svix/MessageAttempt.cs index 9472f5b74..f17a8d067 100644 --- a/csharp/Svix/MessageAttempt.cs +++ b/csharp/Svix/MessageAttempt.cs @@ -266,139 +266,79 @@ public async Task ListAttemptsByMessageAsync(stri // Deprecated [Obsolete("Use ListAttemptsByMessage instead, passing the endpoint ID through options")] - public ListResponseMessageAttemptEndpointOut ListAttemptsForEndpoint(string appId, string messageId, + public ListResponseMessageAttemptOut ListAttemptsForEndpoint(string appId, string messageId, string endpointId, AttemptsByEndpointListOptions options = null, string idempotencyKey = default) { - try - { - var lResults = _messageAttemptApi.V1MessageAttemptListByEndpointDeprecated( - appId, - messageId, - endpointId, - options?.Limit, - options?.Iterator, - options?.Channel, - options?.Tag, - (Svix.Model.MessageStatus?)options?.Status, - options?.Before, - options?.After, - options?.EventTypes); - - return lResults; - } - catch (ApiException e) - { - Logger?.LogError(e, $"{nameof(ListAttemptsForEndpoint)} failed"); - - if (Throw) - throw; - - return new ListResponseMessageAttemptEndpointOut(); - } + var listByMessageOptions = new AttemptsByMessageListOptions( + Limit: options?.Limit, + Iterator: options?.Iterator, + Channel: options?.Channel, + Tag: options?.Tag, + Status: options?.Status, + Before: options?.Before, + After: options?.After, + EventTypes: options?.EventTypes, + EndpointId: endpointId + ); + return ListAttemptsByMessage(appId, messageId, listByMessageOptions, idempotencyKey); } // Deprecated [Obsolete("Use ListAttemptsByMessageAsync instead, passing the endpoint ID through options")] - public async Task ListAttemptsForEndpointAsync(string appId, + public async Task ListAttemptsForEndpointAsync(string appId, string messageId, string endpointId, AttemptsByEndpointListOptions options = null, string idempotencyKey = default, CancellationToken cancellationToken = default) { - try - { - var lResults = await _messageAttemptApi.V1MessageAttemptListByEndpointDeprecatedAsync( - appId, - messageId, - endpointId, - options?.Limit, - options?.Iterator, - options?.Channel, - options?.Tag, - (Svix.Model.MessageStatus?)options?.Status, - options?.Before, - options?.After, - options?.EventTypes?.ToList(), - cancellationToken); - - return lResults; - } - catch (ApiException e) - { - Logger?.LogError(e, $"{nameof(ListAttemptsForEndpointAsync)} failed"); - - if (Throw) - throw; - - return new ListResponseMessageAttemptEndpointOut(); - } + var listByMessageOptions = new AttemptsByMessageListOptions( + Limit: options?.Limit, + Iterator: options?.Iterator, + Channel: options?.Channel, + Tag: options?.Tag, + Status: options?.Status, + Before: options?.Before, + After: options?.After, + EventTypes: options?.EventTypes, + EndpointId: endpointId + ); + return await ListAttemptsByMessageAsync(appId, messageId, listByMessageOptions, idempotencyKey); } // Deprecated - [Obsolete("Use ListAttemptsByEndpoint or ListAttemptsByMessage instead")] + [Obsolete("Use ListAttemptsByMessage instead")] public ListResponseMessageAttemptOut ListAttempts(string appId, string messageId, MessageAttemptListOptions options = null, string idempotencyKey = default) { - try - { - var lResults = _messageAttemptApi.V1MessageAttemptListByMsgDeprecated( - appId, - messageId, - options?.Limit, - options?.Iterator, - options?.EndpointId, - options?.Channel, - options?.Tag, - (Svix.Model.MessageStatus?)options?.Status, - options?.Before, - options?.After, - null, - options?.EventTypes); - - return lResults; - } - catch (ApiException e) - { - Logger?.LogError(e, $"{nameof(ListAttempts)} failed"); - - if (Throw) - throw; - - return new ListResponseMessageAttemptOut(); - } + ListResponseTemplateOut listByMessageOptions = new AttemptsByMessageListOptions( + Limit: options?.Limit, + Iterator: options?.Iterator, + EndpointId: options?.EndpointId, + Channel: options?.Channel, + Tag: options?.Tag, + Status: options?.Status, + Before: options?.Before, + After: options?.After, + EventTypes: options?.EventTypes + ); + return ListAttemptsByMessage(appId, messageId, listByMessageOptions, idempotencyKey); } // Deprecated - [Obsolete("Use ListAttemptsByEndpointAsync or ListAttemptsByMessageAsync instead")] + [Obsolete("Use ListAttemptsByMessageAsync instead")] public async Task ListAttemptsAsync(string appId, string messageId, MessageAttemptListOptions options = null, string idempotencyKey = default, CancellationToken cancellationToken = default) { - try - { - var lResults = await _messageAttemptApi.V1MessageAttemptListByMsgDeprecatedAsync( - appId, - messageId, - options?.Limit, - options?.Iterator, - options?.EndpointId, - options?.Channel, - options?.Tag, - (Svix.Model.MessageStatus?)options?.Status, - options?.Before, - options?.After, - null, - options?.EventTypes, - cancellationToken); - - return lResults; - } - catch (ApiException e) - { - Logger?.LogError(e, $"{nameof(ListAttemptsAsync)} failed"); - - if (Throw) - throw; - - return new ListResponseMessageAttemptOut(); - } + ListResponseTemplateOut listByMessageOptions = new AttemptsByMessageListOptions( + limit: options?.Limit, + iterator: options?.Iterator, + endpointId: options?.EndpointId, + channel: options?.Channel, + tag: options?.Tag, + status: options?.Status, + before: options?.Before, + after: options?.After, + eventTypes: options?.EventTypes + ); + return await ListAttemptsByMessageAsync(appId, messageId, listByMessageOptions, idempotencyKey); } public ListResponseMessageEndpointOut ListAttemptedDestinations(string appId, string messageId, ListOptions options = null, diff --git a/csharp/Svix/OperationalWebhookEndpoint.cs b/csharp/Svix/OperationalWebhookEndpoint.cs index b73444f1c..872193544 100644 --- a/csharp/Svix/OperationalWebhookEndpoint.cs +++ b/csharp/Svix/OperationalWebhookEndpoint.cs @@ -27,7 +27,7 @@ public OperationalWebhookEndpointOut Create( { try { - var lEndpoint = _opWebhookEndpointApi.CreateOperationalWebhookEndpoint( + var lEndpoint = _opWebhookEndpointApi.V1OperationalWebhookEndpointCreate( endpoint, idempotencyKey); @@ -50,7 +50,7 @@ public async Task CreateAsync( { try { - var lEndpoint = await _opWebhookEndpointApi.CreateOperationalWebhookEndpointAsync( + var lEndpoint = await _opWebhookEndpointApi.V1OperationalWebhookEndpointCreateAsync( endpoint, idempotencyKey, cancellationToken); @@ -72,7 +72,7 @@ public bool Delete(string endpointId, string idempotencyKey = default) { try { - var lResponse = _opWebhookEndpointApi.DeleteOperationalWebhookEndpointWithHttpInfo( + var lResponse = _opWebhookEndpointApi.V1OperationalWebhookEndpointDeleteWithHttpInfo( endpointId); return lResponse.StatusCode == HttpStatusCode.NoContent; @@ -93,7 +93,7 @@ public async Task DeleteAsync(string endpointId, string idempotencyKey = d { try { - var lResponse = await _opWebhookEndpointApi.DeleteOperationalWebhookEndpointWithHttpInfoAsync( + var lResponse = await _opWebhookEndpointApi.V1OperationalWebhookEndpointDeleteWithHttpInfoAsync( endpointId, cancellationToken); @@ -114,7 +114,7 @@ public OperationalWebhookEndpointOut Get(string endpointId, string idempotencyKe { try { - var lEndpoint = _opWebhookEndpointApi.GetOperationalWebhookEndpoint(endpointId); + var lEndpoint = _opWebhookEndpointApi.V1OperationalWebhookEndpointGet(endpointId); return lEndpoint; } catch (ApiException e) @@ -133,7 +133,7 @@ public async Task GetAsync(string endpointId, str { try { - var lEndpoint = await _opWebhookEndpointApi.GetOperationalWebhookEndpointAsync( + var lEndpoint = await _opWebhookEndpointApi.V1OperationalWebhookEndpointGetAsync( endpointId, cancellationToken); @@ -154,7 +154,7 @@ public string GetSecret(string endpointId, string idempotencyKey = default) { try { - var lSecret = _opWebhookEndpointApi.GetOperationalWebhookEndpointSecret( + var lSecret = _opWebhookEndpointApi.V1OperationalWebhookEndpointGetSecret( endpointId); return lSecret?.Key; @@ -175,7 +175,7 @@ public async Task GetSecretAsync(string endpointId, string idempotencyKe { try { - var lSecret = await _opWebhookEndpointApi.GetOperationalWebhookEndpointSecretAsync( + var lSecret = await _opWebhookEndpointApi.V1OperationalWebhookEndpointGetSecretAsync( endpointId, cancellationToken); @@ -197,7 +197,7 @@ public ListResponseOperationalWebhookEndpointOut List(ListOptions options = null { try { - var lEndpoints = _opWebhookEndpointApi.ListOperationalWebhookEndpoints( + var lEndpoints = _opWebhookEndpointApi.V1OperationalWebhookEndpointList( options?.Limit, options?.Iterator, options?.Order); @@ -221,7 +221,7 @@ public async Task ListAsync( { try { - var lEndpoints = await _opWebhookEndpointApi.ListOperationalWebhookEndpointsAsync( + var lEndpoints = await _opWebhookEndpointApi.V1OperationalWebhookEndpointListAsync( options?.Limit, options?.Iterator, options?.Order, @@ -244,7 +244,7 @@ public bool RotateSecret(string endpointId, OperationalWebhookEndpointSecretIn s { try { - var lResponse = _opWebhookEndpointApi.RotateOperationalWebhookEndpointSecretWithHttpInfo( + var lResponse = _opWebhookEndpointApi.V1OperationalWebhookEndpointRotateSecretWithHttpInfo( endpointId, secret, idempotencyKey); @@ -267,7 +267,7 @@ public async Task RotateSecretAsync(string endpointId, OperationalWebhookE { try { - var lResponse = await _opWebhookEndpointApi.RotateOperationalWebhookEndpointSecretWithHttpInfoAsync( + var lResponse = await _opWebhookEndpointApi.V1OperationalWebhookEndpointRotateSecretWithHttpInfoAsync( endpointId, secret, idempotencyKey); @@ -290,7 +290,7 @@ public OperationalWebhookEndpointOut Update(string endpointId, { try { - var lEndpoint = _opWebhookEndpointApi.UpdateOperationalWebhookEndpoint( + var lEndpoint = _opWebhookEndpointApi.V1OperationalWebhookEndpointUpdate( endpointId, endpoint); @@ -313,7 +313,7 @@ public async Task UpdateAsync(string endpointId, { try { - var lEndpoint = await _opWebhookEndpointApi.UpdateOperationalWebhookEndpointAsync( + var lEndpoint = await _opWebhookEndpointApi.V1OperationalWebhookEndpointUpdateAsync( endpointId, endpoint, cancellationToken);