Exemple #1
0
 public ChannelCreationOptions GetChannelCreationOptions()
 {
     return(new ChannelCreationOptions
     {
         Name = Name,
         Description = Description,
         EncodingType = EncodingType,
         Input = ChannelCreationOperations.ConfigureDefaultInput(StreamingProtocol, IPRange.ToSdk(IngestAllowList)),
         Preview = ChannelCreationOperations.ConfigureChannelPreview(IPRange.ToSdk(PreviewAllowList)),
         Output = new ChannelOutput(),
         Encoding = EncodingType != ChannelEncodingType.None ? ChannelCreationOperations.GetDefaultEncoding(EncodingPreset) : null,
         Slate = EncodingType != ChannelEncodingType.None && SlateAssetId != null?ChannelCreationOperations.GetDefaultSlate(SlateAssetId) : null
     });
 }
Exemple #2
0
        public void ChannelCRUDTest()
        {
            var account    = App.Config.Content.ContentProviders[0].MediaServicesSets[0].MediaServicesAccounts[0];
            var controller = new ChannelsController();
            var context    = account.GetContext();
            int chnlCount  = context.Channels.Count();
            var name       = string.Format("New-Channel-{0}", DateTime.UtcNow.ToOADate().ToString().Replace(".", "-"));
            var settings   = new Models.ChannelSettings
            {
                Name = name
            };
            var operation = controller.Create(account.AccountName, settings);

            while (operation.State == OperationState.InProgress)
            {
                Thread.Sleep(10000);
                operation = context.Operations.GetOperation(operation.Id);
            }
            Assert.AreEqual(chnlCount + 1, context.Channels.Count());

            var channel = context.Channels.ToList().First(c => c.Name == name);

            var range = new Models.IPRange
            {
                SubnetPrefixLength = 32,
                Address            = "127.0.0.1"
            };

            //update the channel.
            var updateSettings = new Models.ChannelUpdateSettings
            {
                IngestAllowList  = new Models.IPRange[] { range },
                PreviewAllowList = new Models.IPRange[] { range },
                Description      = "SomeDescription"
            };

            operation = controller.Update(account.AccountName, channel.Id.NimbusIdToRawGuid(), updateSettings);
            while (operation.State == OperationState.InProgress)
            {
                Thread.Sleep(10000);
                operation = context.Operations.GetOperation(operation.Id);
            }

            // create new context to avoid cache issue.
            context = account.GetContext();
            channel = context.Channels.Where(c => c.Id == channel.Id).FirstOrDefault();
            Assert.IsNotNull(channel);

            // verify ingest.
            Assert.AreEqual(1, channel.Input.AccessControl.IPAllowList.Count);
            Assert.AreEqual("Range0", channel.Input.AccessControl.IPAllowList[0].Name);
            Assert.AreEqual(range.SubnetPrefixLength, channel.Input.AccessControl.IPAllowList[0].SubnetPrefixLength);
            Assert.AreEqual(range.Address, channel.Input.AccessControl.IPAllowList[0].Address);

            // verify preview.
            Assert.AreEqual(1, channel.Preview.AccessControl.IPAllowList.Count);
            Assert.AreEqual("Range0", channel.Preview.AccessControl.IPAllowList[0].Name);
            Assert.AreEqual(range.SubnetPrefixLength, channel.Preview.AccessControl.IPAllowList[0].SubnetPrefixLength);
            Assert.AreEqual(range.Address, channel.Preview.AccessControl.IPAllowList[0].Address);

            operation = controller.Delete(account.AccountName, channel.Id.NimbusIdToRawGuid());
            while (operation.State == OperationState.InProgress)
            {
                Thread.Sleep(10000);
                operation = context.Operations.GetOperation(operation.Id);
            }
            Assert.AreEqual(chnlCount, context.Channels.Count());
        }
 public StreamingEndpointCreationOptions GetCreationOptions()
 {
     return(new StreamingEndpointCreationOptions
     {
         Name = Name,
         Description = Description,
         ScaleUnits = ScaleUnits,
         CacheControl = new StreamingEndpointCacheControl
         {
             MaxAge = TimeSpan.FromMinutes(MaxAge)
         },
         AccessControl = new StreamingEndpointAccessControl
         {
             IPAllowList = AllowList == null?ChannelCreationOperations.GetDefaultIpAllowList() : IPRange.ToSdk(AllowList)
         }
     });
 }
Exemple #4
0
        public void OriginCRUDTest()
        {
            var account     = App.Config.Content.ContentProviders[0].MediaServicesSets[0].MediaServicesAccounts[0];
            var controller  = new OriginsController();
            var context     = account.GetContext();
            int originCount = context.StreamingEndpoints.Count();
            var name        = string.Format("New-Origin-{0}", DateTime.UtcNow.ToOADate().ToString().Replace(".", "-"));
            var settings    = new Models.OriginSettings
            {
                Name = name
            };
            var operation = controller.Create(account.AccountName, settings);

            while (operation.State == OperationState.InProgress)
            {
                Thread.Sleep(10000);
                operation = context.Operations.GetOperation(operation.Id);
            }
            Assert.AreEqual(originCount + 1, context.StreamingEndpoints.Count());

            var origin = context.StreamingEndpoints.ToList().First(o => o.Name == name);

            var range = new Models.IPRange
            {
                SubnetPrefixLength = 32,
                Address            = "127.0.0.1"
            };

            //update the channel.
            var updateSettings = new Models.OriginUpdateSettings
            {
                AllowList   = new Models.IPRange[] { range },
                Description = "SomeDescription"
            };

            operation = controller.Update(account.AccountName, origin.Id.NimbusIdToRawGuid(), updateSettings);
            while (operation.State == OperationState.InProgress)
            {
                Thread.Sleep(10000);
                operation = context.Operations.GetOperation(operation.Id);
            }

            // create new context to avoid cache issue.
            context = account.GetContext();
            origin  = context.StreamingEndpoints.Where(o => o.Id == origin.Id).FirstOrDefault();
            Assert.IsNotNull(origin);

            Assert.AreEqual(updateSettings.Description, origin.Description);

            // verify access control.
            Assert.AreEqual(1, origin.AccessControl.IPAllowList.Count);
            Assert.AreEqual("Range0", origin.AccessControl.IPAllowList[0].Name);
            Assert.AreEqual(range.SubnetPrefixLength, origin.AccessControl.IPAllowList[0].SubnetPrefixLength);
            Assert.AreEqual(range.Address, origin.AccessControl.IPAllowList[0].Address);

            operation = controller.Delete(account.AccountName, origin.Id.NimbusIdToRawGuid());
            while (operation.State == OperationState.InProgress)
            {
                Thread.Sleep(10000);
                operation = context.Operations.GetOperation(operation.Id);
            }
            Assert.AreEqual(originCount, context.StreamingEndpoints.Count());
        }