protected override void ProcessRecordInternal()
        {
            var putParameters = new LogProfileCreateOrUpdateParameters();

            if (this.Categories == null)
            {
                this.Categories = new List<string>(ValidCategories);
            }

            putParameters.Categories = this.Categories;
            putParameters.Locations = this.Locations;
            putParameters.RetentionPolicy = new RetentionPolicy
            {
                Days = this.RetentionInDays.HasValue ? this.RetentionInDays.Value : 0,
                Enabled = this.RetentionInDays.HasValue
            };
            putParameters.ServiceBusRuleId = this.ServiceBusRuleId;
            putParameters.StorageAccountId = this.StorageAccountId;

            LogProfileResource result = this.InsightsManagementClient.LogProfiles.CreateOrUpdateAsync(logProfileName: this.Name, parameters: putParameters, cancellationToken: CancellationToken.None).Result;
            WriteObject(new PSLogProfile(result));
        }
Exemple #2
0
        protected override void ProcessRecordInternal()
        {
            var putParameters = new LogProfileCreateOrUpdateParameters();

            if (this.Categories == null)
            {
                this.Categories = new List <string>(ValidCategories);
            }

            putParameters.Categories      = this.Categories;
            putParameters.Locations       = this.Locations;
            putParameters.RetentionPolicy = new RetentionPolicy
            {
                Days    = this.RetentionInDays.HasValue ? this.RetentionInDays.Value : 0,
                Enabled = this.RetentionInDays.HasValue
            };
            putParameters.ServiceBusRuleId = this.ServiceBusRuleId;
            putParameters.StorageAccountId = this.StorageAccountId;

            LogProfileResource result = this.InsightsManagementClient.LogProfiles.CreateOrUpdateAsync(logProfileName: this.Name, parameters: putParameters, cancellationToken: CancellationToken.None).Result;

            WriteObject(new PSLogProfile(result));
        }
        public AddAzureRmLogProfileTests(ITestOutputHelper output)
        {
            // XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
            insightsLogProfileOperationsMock = new Mock<ILogProfilesOperations>();
            insightsManagementClientMock = new Mock<InsightsManagementClient>();
            commandRuntimeMock = new Mock<ICommandRuntime>();
            cmdlet = new AddAzureRmLogProfileCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                InsightsManagementClient = insightsManagementClientMock.Object
            };

            response = Utilities.InitializeLogProfileResponse();

            insightsLogProfileOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny<string>(), It.IsAny<LogProfileCreateOrUpdateParameters>(), It.IsAny<Dictionary<string, List<string>>>(), It.IsAny<CancellationToken>()))
                .Returns(Task.FromResult<Rest.Azure.AzureOperationResponse<LogProfileResource>>(response))
                .Callback((string logProfileName, LogProfileCreateOrUpdateParameters createOrUpdateParams, Dictionary<string, List<string>> headers, CancellationToken t) =>
                {
                    this.logProfileName = logProfileName;
                    createOrUpdatePrms = createOrUpdateParams;
                });

            insightsManagementClientMock.SetupGet(f => f.LogProfiles).Returns(this.insightsLogProfileOperationsMock.Object);
        }
        public AddAzureRmLogProfileTests(ITestOutputHelper output)
        {
            // XunitTracingInterceptor.AddToContext(new XunitTracingInterceptor(output));
            insightsLogProfileOperationsMock = new Mock <ILogProfilesOperations>();
            insightsManagementClientMock     = new Mock <InsightsManagementClient>();
            commandRuntimeMock = new Mock <ICommandRuntime>();
            cmdlet             = new AddAzureRmLogProfileCommand()
            {
                CommandRuntime           = commandRuntimeMock.Object,
                InsightsManagementClient = insightsManagementClientMock.Object
            };

            response = Utilities.InitializeLogProfileResponse();

            insightsLogProfileOperationsMock.Setup(f => f.CreateOrUpdateWithHttpMessagesAsync(It.IsAny <string>(), It.IsAny <LogProfileCreateOrUpdateParameters>(), It.IsAny <Dictionary <string, List <string> > >(), It.IsAny <CancellationToken>()))
            .Returns(Task.FromResult <Rest.Azure.AzureOperationResponse <LogProfileResource> >(response))
            .Callback((string logProfileName, LogProfileCreateOrUpdateParameters createOrUpdateParams, Dictionary <string, List <string> > headers, CancellationToken t) =>
            {
                this.logProfileName = logProfileName;
                createOrUpdatePrms  = createOrUpdateParams;
            });

            insightsManagementClientMock.SetupGet(f => f.LogProfiles).Returns(this.insightsLogProfileOperationsMock.Object);
        }