/// <summary> /// Initializes a new instance of the <see cref="ControlPanelMutation"/> class. /// </summary> /// <param name="controlPanelService">The application layer ControlPanelService.</param> /// <param name="logger">The NLog logger instance.</param> public ControlPanelMutation(IControlPanelService controlPanelService, ILogger logger) { this.AuthorizeWith(AuthorizationPolicyName.AuthenticatedPolicy); this.FieldAsync <BooleanGraphType>( "Reboot", resolve: async context => { logger.Info("Reboot mutation"); return(await controlPanelService.RebootAsync()); }) .AuthorizeWith(AuthorizationPolicyName.SuperUserPolicy); this.FieldAsync <BooleanGraphType>( "Shutdown", resolve: async context => { logger.Info("Shutdown mutation"); return(await controlPanelService.ShutdownAsync()); }) .AuthorizeWith(AuthorizationPolicyName.SuperUserPolicy); this.FieldAsync <BooleanGraphType>( "Update", resolve: async context => { logger.Info("Update mutation"); return(await controlPanelService.UpdateAsync()); }) .AuthorizeWith(AuthorizationPolicyName.SuperUserPolicy); this.FieldAsync <BooleanGraphType>( "Kill", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IntGraphType> > { Name = "ProcessId" }), resolve: async context => { logger.Info("Kill mutation"); var graphQLUserContext = context.UserContext as GraphQLUserContext; var userContext = graphQLUserContext.GetUserContext(); var processId = context.GetArgument <int>("processId"); return(await controlPanelService.KillAsync(userContext, processId)); }) .AuthorizeWith(AuthorizationPolicyName.AuthenticatedPolicy); this.FieldAsync <BooleanGraphType>( "Overclock", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <CpuMaxFrequencyLevelType> > { Name = "CpuMaxFrequencyLevel" }), resolve: async context => { logger.Info("Overclock mutation"); var cpuMaxFrequencyLevel = context.GetArgument <CpuMaxFrequencyLevel>("cpuMaxFrequencyLevel"); return(await controlPanelService.OverclockAsync(cpuMaxFrequencyLevel)); }) .AuthorizeWith(AuthorizationPolicyName.SuperUserPolicy); this.FieldAsync <BooleanGraphType>( "StartSsh", resolve: async context => { logger.Info("StartSsh mutation"); return(await controlPanelService.StartSshAsync()); }) .AuthorizeWith(AuthorizationPolicyName.SuperUserPolicy); }
public ControlPanelController(IControlPanelService controlPanelService) { _controlPanelService = controlPanelService; }
public ControlPanelController(IErrorService errorService, IControlPanelService controlPanelService) : base(errorService) { this._controlPanelService = controlPanelService; }