Beispiel #1
0
 public ClaraJobsApi(
     IJobsClient jobsClient,
     ILogger <ClaraJobsApi> iLogger)
 {
     _jobsClient = jobsClient ?? throw new ArgumentNullException(nameof(jobsClient));
     _logger     = iLogger ?? throw new ArgumentNullException(nameof(iLogger));
 }
 public JobViewModel(Job job, Action onRemove, IJobsClient jobsClient)
 {
     this.onRemove = onRemove ?? throw new ArgumentNullException(nameof(onRemove));
     canCancel     = true;
     Remove        = new EnumCommand <JobCommand>(JobCommand.Remove, this);
     Cancel        = new EnumCommand <JobCommand>(JobCommand.Cancel, this);
     Update(job, jobsClient);
 }
        public void SetUp()
        {
            var container = new IndicoTestContainerBuilder().Build();

            _jobsClient        = container.Resolve <IJobsClient>();
            _submissionsClient = container.Resolve <ISubmissionsClient>();
            _dataHelper        = container.Resolve <DataHelper>();
        }
Beispiel #4
0
        public async Task InitialQuery(IJobsClient jobsClient, CancellationToken cancellationToken)
        {
            var jobs = await jobsClient.ListActive(cancellationToken).ConfigureAwait(false);

            lock (trackedJobs)
                foreach (var I in jobs)
                {
                    RegisterJob(I);
                }
        }
Beispiel #5
0
        /// <summary>
        /// Construct a <see cref="InstanceClient"/>
        /// </summary>
        /// <param name="apiClient">The value of <see cref="apiClient"/></param>
        /// <param name="instance">The value of <see cref="Metadata"/></param>
        public InstanceClient(IApiClient apiClient, Instance instance)
        {
            this.apiClient = apiClient ?? throw new ArgumentNullException(nameof(apiClient));
            Metadata       = instance ?? throw new ArgumentNullException(nameof(instance));

            Byond         = new ByondClient(apiClient, instance);
            Repository    = new RepositoryClient(apiClient, instance);
            DreamDaemon   = new DreamDaemonClient(apiClient, instance);
            Configuration = new ConfigurationClient(apiClient, instance);
            Users         = new InstanceUserClient(apiClient, instance);
            ChatBots      = new ChatBotsClient(apiClient, instance);
            DreamMaker    = new DreamMakerClient(apiClient, instance);
            Jobs          = new JobsClient(apiClient, instance);
        }
        public void Update(Job job, IJobsClient jobsClient)
        {
            this.job        = job ?? throw new ArgumentNullException(nameof(job));
            this.jobsClient = jobsClient ?? throw new ArgumentNullException(nameof(jobsClient));

            this.RaisePropertyChanged(nameof(Finished));
            this.RaisePropertyChanged(nameof(ErrorDetails));
            this.RaisePropertyChanged(nameof(Progress));
            this.RaisePropertyChanged(nameof(HasProgress));
            this.RaisePropertyChanged(nameof(Background));
            this.RaisePropertyChanged(nameof(Error));
            this.RaisePropertyChanged(nameof(Title));
            Remove.Recheck();
            Cancel.Recheck();
        }
Beispiel #7
0
        public IObservable <Job> UpdateJobs(IJobsClient jobsClient, CancellationToken cancellationToken)
        {
            var linkedSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationTokenSource.Token, cancellationToken);
            var tokenToUse   = linkedSource.Token;

            async Task <Job> WrapJobDisconnected(Job job)
            {
                try
                {
                    return(await jobsClient.GetId(job, tokenToUse).ConfigureAwait(false));
                }
                //caught exceptions here indicate
                //lost access to instance, will be refreshed when regained
                catch (InsufficientPermissionsException)
                {
                    return(null);
                }
                catch (HttpRequestException)
                {
                    return(null);
                }
                catch (OperationCanceledException)
                {
                    return(null);
                }
                catch (ObjectDisposedException)
                {
                    return(null);
                }
            }

            var tasks = new List <Task <Job> >();

            lock (trackedJobs)
                foreach (var I in trackedJobs)
                {
                    tasks.Add(WrapJobDisconnected(I.Value));
                }

            Task.WhenAll(tasks).ContinueWith((a) => linkedSource.Dispose());

            return(tasks.Select(x => x.ToObservable()).Merge());
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="InstanceClient"/> class.
        /// </summary>
        /// <param name="apiClient">The <see cref="IApiClient"/> used to construct component clients.</param>
        /// <param name="instance">The value of <see cref="Metadata"/>.</param>
        public InstanceClient(IApiClient apiClient, Instance instance)
        {
            if (apiClient == null)
            {
                throw new ArgumentNullException(nameof(apiClient));
            }
            if (!instance.Id.HasValue)
            {
                throw new ArgumentException("Instance missing ID!", nameof(instance));
            }

            Metadata = instance ?? throw new ArgumentNullException(nameof(instance));

            Byond          = new ByondClient(apiClient, instance);
            Repository     = new RepositoryClient(apiClient, instance);
            DreamDaemon    = new DreamDaemonClient(apiClient, instance);
            Configuration  = new ConfigurationClient(apiClient, instance);
            PermissionSets = new InstancePermissionSetClient(apiClient, instance);
            ChatBots       = new ChatBotsClient(apiClient, instance);
            DreamMaker     = new DreamMakerClient(apiClient, instance);
            Jobs           = new JobsClient(apiClient, instance);
        }
 public ByondTest(IByondClient byondClient, IJobsClient jobsClient, Api.Models.Instance metadata)
     : base(jobsClient)
 {
     this.byondClient = byondClient ?? throw new ArgumentNullException(nameof(byondClient));
     this.metadata    = metadata ?? throw new ArgumentNullException(nameof(metadata));
 }
Beispiel #10
0
 public RepositoryTest(IRepositoryClient repositoryClient, IJobsClient jobsClient)
     : base(jobsClient)
 {
     this.repositoryClient = repositoryClient ?? throw new ArgumentNullException(nameof(repositoryClient));
 }
 public DeploymentTest(IDreamMakerClient dreamMakerClient, IDreamDaemonClient dreamDaemonClient, IJobsClient jobsClient) : base(jobsClient)
 {
     this.dreamMakerClient  = dreamMakerClient ?? throw new ArgumentNullException(nameof(dreamMakerClient));
     this.dreamDaemonClient = dreamDaemonClient ?? throw new ArgumentNullException(nameof(dreamDaemonClient));
 }
 public JobAwaiter(IJobsClient jobsClient) => _jobsClient = jobsClient;
 public void Dispose()
 {
     _jobsClient = null;
     GC.Collect();
 }
Beispiel #14
0
 public JobsRequiredTest(IJobsClient jobsClient)
 {
     this.JobsClient = jobsClient;
 }
 public ByondTest(IByondClient byondClient, IJobsClient jobsClient)
 {
     this.byondClient = byondClient ?? throw new ArgumentNullException(nameof(byondClient));
     this.jobsClient  = jobsClient ?? throw new ArgumentNullException(nameof(jobsClient));
 }