// this file is @generated #nullable enable using Microsoft.Extensions.Logging; using Svix.Models; namespace Svix { public class IngestAuthenticationConsumerPortalAccessOptions : SvixOptionsBase { public string? IdempotencyKey { get; set; } public new Dictionary HeaderParams() { return SerializeParams( new Dictionary { { "idempotency-key", IdempotencyKey } } ); } } public class IngestAuthentication(SvixClient client) { readonly SvixClient _client = client; /// /// Get access to the Ingest Source Consumer Portal. /// public async Task ConsumerPortalAccessAsync( string sourceId, IngestSourceConsumerPortalAccessIn ingestSourceConsumerPortalAccessIn, IngestAuthenticationConsumerPortalAccessOptions? options = null, CancellationToken cancellationToken = default ) { if (options == null) { options = new IngestAuthenticationConsumerPortalAccessOptions(); } ingestSourceConsumerPortalAccessIn = ingestSourceConsumerPortalAccessIn ?? throw new ArgumentNullException(nameof(ingestSourceConsumerPortalAccessIn)); try { var response = await _client.SvixHttpClient.SendRequestAsync( method: HttpMethod.Post, path: "/ingest/api/v1/source/{source_id}/dashboard", pathParams: new Dictionary { { "source_id", sourceId } }, queryParams: options.QueryParams(), headerParams: options.HeaderParams(), content: ingestSourceConsumerPortalAccessIn, cancellationToken: cancellationToken ); return response.Data; } catch (ApiException e) { _client.Logger?.LogError(e, $"{nameof(ConsumerPortalAccessAsync)} failed"); throw; } } /// /// Get access to the Ingest Source Consumer Portal. /// public AppPortalAccessOut ConsumerPortalAccess( string sourceId, IngestSourceConsumerPortalAccessIn ingestSourceConsumerPortalAccessIn, IngestAuthenticationConsumerPortalAccessOptions? options = null ) { if (options == null) { options = new IngestAuthenticationConsumerPortalAccessOptions(); } ingestSourceConsumerPortalAccessIn = ingestSourceConsumerPortalAccessIn ?? throw new ArgumentNullException(nameof(ingestSourceConsumerPortalAccessIn)); try { var response = _client.SvixHttpClient.SendRequest( method: HttpMethod.Post, path: "/ingest/api/v1/source/{source_id}/dashboard", pathParams: new Dictionary { { "source_id", sourceId } }, queryParams: options.QueryParams(), headerParams: options.HeaderParams(), content: ingestSourceConsumerPortalAccessIn ); return response.Data; } catch (ApiException e) { _client.Logger?.LogError(e, $"{nameof(ConsumerPortalAccess)} failed"); throw; } } } }