@@ -41,6 +41,30 @@ public class AuthenticationLogoutOptions : SvixOptionsBase
4141 }
4242 }
4343
44+ public class AuthenticationStreamPortalAccessOptions : SvixOptionsBase
45+ {
46+ public string ? IdempotencyKey { get ; set ; }
47+
48+ public new Dictionary < string , string > HeaderParams ( )
49+ {
50+ return SerializeParams (
51+ new Dictionary < string , object ? > { { "idempotency-key" , IdempotencyKey } }
52+ ) ;
53+ }
54+ }
55+
56+ public class AuthenticationRotateStreamPollerTokenOptions : SvixOptionsBase
57+ {
58+ public string ? IdempotencyKey { get ; set ; }
59+
60+ public new Dictionary < string , string > HeaderParams ( )
61+ {
62+ return SerializeParams (
63+ new Dictionary < string , object ? > { { "idempotency-key" , IdempotencyKey } }
64+ ) ;
65+ }
66+ }
67+
4468 public class Authentication ( SvixClient client )
4569 {
4670 readonly SvixClient _client = client ;
@@ -280,5 +304,202 @@ public bool Logout(AuthenticationLogoutOptions? options = null)
280304 throw ;
281305 }
282306 }
307+
308+ /// <summary>
309+ /// Use this function to get magic links (and authentication codes) for connecting your users to the Stream Consumer Portal.
310+ /// </summary>
311+ public async Task < AppPortalAccessOut > StreamPortalAccessAsync (
312+ string streamId ,
313+ StreamPortalAccessIn streamPortalAccessIn ,
314+ AuthenticationStreamPortalAccessOptions ? options = null ,
315+ CancellationToken cancellationToken = default
316+ )
317+ {
318+ streamPortalAccessIn =
319+ streamPortalAccessIn
320+ ?? throw new ArgumentNullException ( nameof ( streamPortalAccessIn ) ) ;
321+ try
322+ {
323+ var response = await _client . SvixHttpClient . SendRequestAsync < AppPortalAccessOut > (
324+ method : HttpMethod . Post ,
325+ path : "/api/v1/auth/stream-portal-access/{stream_id}" ,
326+ pathParams : new Dictionary < string , string > { { "stream_id" , streamId } } ,
327+ queryParams : options ? . QueryParams ( ) ,
328+ headerParams : options ? . HeaderParams ( ) ,
329+ content : streamPortalAccessIn ,
330+ cancellationToken : cancellationToken
331+ ) ;
332+ return response . Data ;
333+ }
334+ catch ( ApiException e )
335+ {
336+ _client . Logger ? . LogError ( e , $ "{ nameof ( StreamPortalAccessAsync ) } failed") ;
337+
338+ throw ;
339+ }
340+ }
341+
342+ /// <summary>
343+ /// Use this function to get magic links (and authentication codes) for connecting your users to the Stream Consumer Portal.
344+ /// </summary>
345+ public AppPortalAccessOut StreamPortalAccess (
346+ string streamId ,
347+ StreamPortalAccessIn streamPortalAccessIn ,
348+ AuthenticationStreamPortalAccessOptions ? options = null
349+ )
350+ {
351+ streamPortalAccessIn =
352+ streamPortalAccessIn
353+ ?? throw new ArgumentNullException ( nameof ( streamPortalAccessIn ) ) ;
354+ try
355+ {
356+ var response = _client . SvixHttpClient . SendRequest < AppPortalAccessOut > (
357+ method : HttpMethod . Post ,
358+ path : "/api/v1/auth/stream-portal-access/{stream_id}" ,
359+ pathParams : new Dictionary < string , string > { { "stream_id" , streamId } } ,
360+ queryParams : options ? . QueryParams ( ) ,
361+ headerParams : options ? . HeaderParams ( ) ,
362+ content : streamPortalAccessIn
363+ ) ;
364+ return response . Data ;
365+ }
366+ catch ( ApiException e )
367+ {
368+ _client . Logger ? . LogError ( e , $ "{ nameof ( StreamPortalAccess ) } failed") ;
369+
370+ throw ;
371+ }
372+ }
373+
374+ /// <summary>
375+ /// Get the current auth token for the stream poller.
376+ /// </summary>
377+ public async Task < ApiTokenOut > GetStreamPollerTokenAsync (
378+ string streamId ,
379+ string sinkId ,
380+ CancellationToken cancellationToken = default
381+ )
382+ {
383+ try
384+ {
385+ var response = await _client . SvixHttpClient . SendRequestAsync < ApiTokenOut > (
386+ method : HttpMethod . Get ,
387+ path : "/api/v1/auth/stream/{stream_id}/sink/{sink_id}/poller/token" ,
388+ pathParams : new Dictionary < string , string >
389+ {
390+ { "stream_id" , streamId } ,
391+ { "sink_id" , sinkId } ,
392+ } ,
393+ cancellationToken : cancellationToken
394+ ) ;
395+ return response . Data ;
396+ }
397+ catch ( ApiException e )
398+ {
399+ _client . Logger ? . LogError ( e , $ "{ nameof ( GetStreamPollerTokenAsync ) } failed") ;
400+
401+ throw ;
402+ }
403+ }
404+
405+ /// <summary>
406+ /// Get the current auth token for the stream poller.
407+ /// </summary>
408+ public ApiTokenOut GetStreamPollerToken ( string streamId , string sinkId )
409+ {
410+ try
411+ {
412+ var response = _client . SvixHttpClient . SendRequest < ApiTokenOut > (
413+ method : HttpMethod . Get ,
414+ path : "/api/v1/auth/stream/{stream_id}/sink/{sink_id}/poller/token" ,
415+ pathParams : new Dictionary < string , string >
416+ {
417+ { "stream_id" , streamId } ,
418+ { "sink_id" , sinkId } ,
419+ }
420+ ) ;
421+ return response . Data ;
422+ }
423+ catch ( ApiException e )
424+ {
425+ _client . Logger ? . LogError ( e , $ "{ nameof ( GetStreamPollerToken ) } failed") ;
426+
427+ throw ;
428+ }
429+ }
430+
431+ /// <summary>
432+ /// Create a new auth token for the stream poller API.
433+ /// </summary>
434+ public async Task < ApiTokenOut > RotateStreamPollerTokenAsync (
435+ string streamId ,
436+ string sinkId ,
437+ RotatePollerTokenIn rotatePollerTokenIn ,
438+ AuthenticationRotateStreamPollerTokenOptions ? options = null ,
439+ CancellationToken cancellationToken = default
440+ )
441+ {
442+ rotatePollerTokenIn =
443+ rotatePollerTokenIn ?? throw new ArgumentNullException ( nameof ( rotatePollerTokenIn ) ) ;
444+ try
445+ {
446+ var response = await _client . SvixHttpClient . SendRequestAsync < ApiTokenOut > (
447+ method : HttpMethod . Post ,
448+ path : "/api/v1/auth/stream/{stream_id}/sink/{sink_id}/poller/token/rotate" ,
449+ pathParams : new Dictionary < string , string >
450+ {
451+ { "stream_id" , streamId } ,
452+ { "sink_id" , sinkId } ,
453+ } ,
454+ queryParams : options ? . QueryParams ( ) ,
455+ headerParams : options ? . HeaderParams ( ) ,
456+ content : rotatePollerTokenIn ,
457+ cancellationToken : cancellationToken
458+ ) ;
459+ return response . Data ;
460+ }
461+ catch ( ApiException e )
462+ {
463+ _client . Logger ? . LogError ( e , $ "{ nameof ( RotateStreamPollerTokenAsync ) } failed") ;
464+
465+ throw ;
466+ }
467+ }
468+
469+ /// <summary>
470+ /// Create a new auth token for the stream poller API.
471+ /// </summary>
472+ public ApiTokenOut RotateStreamPollerToken (
473+ string streamId ,
474+ string sinkId ,
475+ RotatePollerTokenIn rotatePollerTokenIn ,
476+ AuthenticationRotateStreamPollerTokenOptions ? options = null
477+ )
478+ {
479+ rotatePollerTokenIn =
480+ rotatePollerTokenIn ?? throw new ArgumentNullException ( nameof ( rotatePollerTokenIn ) ) ;
481+ try
482+ {
483+ var response = _client . SvixHttpClient . SendRequest < ApiTokenOut > (
484+ method : HttpMethod . Post ,
485+ path : "/api/v1/auth/stream/{stream_id}/sink/{sink_id}/poller/token/rotate" ,
486+ pathParams : new Dictionary < string , string >
487+ {
488+ { "stream_id" , streamId } ,
489+ { "sink_id" , sinkId } ,
490+ } ,
491+ queryParams : options ? . QueryParams ( ) ,
492+ headerParams : options ? . HeaderParams ( ) ,
493+ content : rotatePollerTokenIn
494+ ) ;
495+ return response . Data ;
496+ }
497+ catch ( ApiException e )
498+ {
499+ _client . Logger ? . LogError ( e , $ "{ nameof ( RotateStreamPollerToken ) } failed") ;
500+
501+ throw ;
502+ }
503+ }
283504 }
284505}
0 commit comments