public ConflictingVersionRequirementsException(string message, AppIdentifier dependency, IDictionary<AppIdentifier, string> requiredVersionsByDependent) : base(message) { Dependency = dependency; RequiredVersionsByDependent = new ReadOnlyDictionary<AppIdentifier, string>(requiredVersionsByDependent); }
public void Constructor_sets_value() { Guid id = Guid.NewGuid(); var identifier = new AppIdentifier(id); identifier.Id.ShouldBe(id); }
protected virtual Task<byte[]> GetFileFromAppOrSandbox(AppIdentifier id, string appVersion, string path, CancellationToken cancellationToken) { var sandboxName = this.SandboxFor(id); return sandboxName == null ? this.appsClient.GetFileAsync(id, appVersion, path, cancellationToken) : this.sandboxesClient.GetFileAsync(id.Vendor, sandboxName, id.Name, path, cancellationToken); }
public void Equals_different_references_can_still_be_equal() { Guid id = Guid.NewGuid(); var identifier1 = new AppIdentifier(id); var identifier2 = new AppIdentifier(id); identifier1.Equals(identifier2).ShouldBeTrue(); }
public static ResourceNotFoundException WithApp(this ResourceNotFoundException @this, AppIdentifier id) { return new Builder { Vendor = id.Vendor, App = id.Name }.Build(@this); }
public static IAppsClient ThatGetsFileList(this IAppsClient @this, AppIdentifier app, string version, FileListingOptions options, FileList fileList) { Mock.Get(@this).Setup(x => x.ListFilesAsync(app, version, It.Is<FileListingOptions>(arg => arg.Equals(options)), It.IsAny<CancellationToken>())) .ReturnsAsync(fileList); return @this; }
public void Constructor_parameterless_constructor_generates_new_identifier() { var identifier1 = new AppIdentifier(); identifier1.Id.ShouldNotBe(Guid.Empty); var identifier2 = new AppIdentifier(); identifier1.Id.ShouldNotBe(identifier2.Id); }
public static ResourceNotFoundException WithApp(this ResourceNotFoundException @this, AppIdentifier id, string version, string path) { return new Builder { Vendor = id.Vendor, App = id.Name, Version = version, Path = path }.Build(@this); }
private static void GetEngineObjects(string centralNodeHostname, TelemetryMetadata metadata, int engineRequestTimeoutMS) { TelemetryDashboardMain.Logger.Log(string.Format("Engine request timeout set to: {0} ms (default is: 30000 ms)", engineRequestTimeoutMS.ToString()), LogLevel.Info); Qlik.Sense.JsonRpc.RpcConnection.Timeout = engineRequestTimeoutMS; string wssPath = "https://" + centralNodeHostname + ":4747"; ILocation location = Location.FromUri(new Uri(wssPath)); X509Certificate2Collection certificateCollection = new X509Certificate2Collection(CertificateConfigHelpers.Certificate); // Defining the location as a direct connection to Qlik Sense Server location.AsDirectConnection("INTERNAL", "sa_api", certificateCollection: certificateCollection); int totalApps = metadata.Apps.Count; int currentApp = 0; TelemetryDashboardMain.Logger.Log("Will start to fetch all app objects from the engine.", LogLevel.Info); foreach (KeyValuePair <Guid, QRSApp> appTuple in metadata.Apps) { currentApp++; TelemetryDashboardMain.Logger.Log(string.Format("App {0} of {1} - Checking to see if visualaizations fetch is needed for app '{2}' with ID '{3}' ", currentApp, totalApps, appTuple.Value.Name, appTuple.Key.ToString()), LogLevel.Debug); if (appTuple.Value.VisualizationUpdateNeeded) { TelemetryDashboardMain.Logger.Log(string.Format("Getting visualizations for app '{0}' with ID '{1}' ", appTuple.Value.Name, appTuple.Key.ToString()), LogLevel.Info); try { IAppIdentifier appIdentifier = new AppIdentifier() { AppId = appTuple.Key.ToString() }; using (IApp app = location.App(appIdentifier, null, true)) { IEnumerable <ISheet> sheetList = app.GetSheets(); foreach (ISheet sheet in sheetList) { ISheetLayout sheetObject = (SheetLayout)sheet.GetLayout(); IList <Visualization> vizs = new List <Visualization>(); sheetObject.Cells.ToList().ForEach(c => vizs.Add(new Visualization(c.Name, c.Type))); metadata.Apps[appTuple.Key].Sheets.FirstOrDefault(s => s.Value.EngineObjectID == sheetObject.Info.Id).Value.SetSheetsList(vizs); } } } catch (Exception e) { TelemetryDashboardMain.Logger.Log("Failed to get engine objects from App: " + appTuple.Key.ToString() + ". Message: " + e.Message, LogLevel.Error); TelemetryDashboardMain.Logger.Log("Skipping app: " + appTuple.Key.ToString(), LogLevel.Error); } } } TelemetryDashboardMain.Logger.Log("Done getting all app objects from the engine.", LogLevel.Info); }
public InstalledApp(AppIdentifier id, string version, string dependencyVersion, string sandbox, string title, string description, IReadOnlyDictionary<AppIdentifier, string> dependencies, IReadOnlyDictionary<string, string> npmDependencies, AppSettings settings, string main, IReadOnlyDictionary<AppIdentifier, string> resolvedDependencies) { Id = id; Version = version; DependencyVersion = dependencyVersion; Sandbox = sandbox; Title = title; Main = main; Description = description; Dependencies = dependencies; NpmDependencies = npmDependencies; Settings = settings; ResolvedDependencies = resolvedDependencies; }
public App GetByIdentifier(AppIdentifier identifier) { if (applicationDictionary.ContainsKey(identifier)) { var application = applicationDictionary [identifier]; var dto = new AppDto { Id = application.Identifier.Id, Name = application.Metadata.Name, Description = application.Metadata.Description, BaseUrl = application.Url.BaseUrl }; return(new App(dto)); } return(null); }
public async Task<AppFile> GetFileAsync(AppIdentifier id, string path, CancellationToken cancellationToken) { var cacheKey = id + ":" + path; AppFile file; if (this.CachedFiles.TryGetValue(cacheKey, out file)) return file; var app = this.GetApp(id); if (IsInArchive(path)) return this.CachedFiles[cacheKey] = await GetFileFromArchiveAsync(app, path, cancellationToken) .ConfigureAwait(false); var content = await this.GetFileFromAppOrSandbox(id, app.Version, path, cancellationToken) .ConfigureAwait(false); return this.CachedFiles[cacheKey] = new AppFile(app.Id, path, content); }
protected virtual async Task<FileList> GetArchiveAsync(AppIdentifier id, string appVersion, CancellationToken cancellationToken) { FileList archive; if (this.CachedArchives.TryGetValue(id, out archive)) return archive; var sandboxName = this.SandboxFor(id); var archiveTask = sandboxName == null ? this.appsClient.ListFilesAsync(id, appVersion, this.OptionsWithContent, cancellationToken) : this.sandboxesClient.ListFilesAsync(id.Vendor, sandboxName, id.Name, this.OptionsWithContent, cancellationToken); return this.CachedArchives[id] = await archiveTask.ConfigureAwait(false); }
private string SandboxFor(AppIdentifier id) => this.sandboxes.GetSandboxFor(id)?.Name;
public Task<IReadOnlyList<AppFileDescriptor>> ListFilesAsync(AppIdentifier id, CancellationToken cancellationToken) { var meta = this.GetApp(id); return this.ListFilesAsync(meta.Id, meta.Version, cancellationToken); }
protected async Task<IReadOnlyList<AppFileDescriptor>> ListFilesAsync(AppIdentifier id, string appVersion, CancellationToken cancellationToken) { IReadOnlyList<AppFileDescriptor> files; if (this.CachedFileLists.TryGetValue(id, out files)) return files; var sandboxName = this.SandboxFor(id); var task = sandboxName == null ? this.appsClient.ListFilesAsync(id, appVersion, this.OptionsForListing, cancellationToken) : this.sandboxesClient.ListFilesAsync(id.Vendor, sandboxName, id.Name, this.OptionsForListing, cancellationToken); var archive = await task.ConfigureAwait(false); return (this.CachedFileLists[id] = archive.AsFileDescriptors() .Select(descriptor => descriptor.WithApp(id)).ToList()); }
public static string App(string account, string workspace, AppIdentifier app) => $"/{account}/workspaces/{workspace}/apps/{app}";
public async Task<byte[]> GetFileAsync(string account, string workspace, AppIdentifier app, IEnumerable<AppIdentifier> context, string service, string path, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(account)) throw new ArgumentNullException(nameof(account), $"{nameof(account)} cannot be null or white space"); if (string.IsNullOrWhiteSpace(workspace)) throw new ArgumentNullException(nameof(workspace), $"{nameof(workspace)} cannot be null or white space"); if (app == null) throw new ArgumentNullException(nameof(app)); if (string.IsNullOrWhiteSpace(service)) throw new ArgumentNullException(nameof(service), $"{nameof(service)} cannot be null or white space"); if (string.IsNullOrWhiteSpace(path)) throw new ArgumentNullException(nameof(path), $"{nameof(path)} cannot be null or white space"); var url = Routes.File(account, workspace, app, service, path).AsRelativeUri(context); try { return await _connector.GetByteArrayAsync(url, null, cancellationToken).ConfigureAwait(false); } catch (ResourceNotFoundException e) { throw e.WithWorkspace(account, workspace, app, service, path); } }
public AppFile(AppIdentifier app, string path, byte[] content) : base(path, content) { this.App = app; }
public static AppFileDescriptor WithApp(this FileDescriptor @this, AppIdentifier app) => new AppFileDescriptor(app, @this.Path, @this.Hash, @this.Size);
public async Task<PagedResponse<File>> ListFilesAsync(string account, string workspace, AppIdentifier app, IEnumerable<AppIdentifier> context, string service, AppFileListingOptions options, CancellationToken cancellationToken) { if (string.IsNullOrWhiteSpace(account)) throw new ArgumentNullException(nameof(account), $"{nameof(account)} cannot be null or white space"); if (string.IsNullOrWhiteSpace(workspace)) throw new ArgumentNullException(nameof(workspace), $"{nameof(workspace)} cannot be null or white space"); if (app == null) throw new ArgumentNullException(nameof(app)); if (string.IsNullOrWhiteSpace(service)) throw new ArgumentNullException(nameof(service), $"{nameof(service)} cannot be null or white space"); options = options ?? AppFileListingOptions.Default; var url = Routes.Files(account, workspace, app, service).AsRelativeUri(options, context); try { return await _connector.GetJsonAsync<PagedResponse<File>>(url, null, cancellationToken) .ConfigureAwait(false); } catch (ResourceNotFoundException e) { throw e.WithWorkspace(account, workspace, app, service); } }
public static string RootFolders(string account, string workspace, AppIdentifier app) => $"/{account}/workspaces/{workspace}/apps/{app}/files";
protected override Task<byte[]> GetFileFromAppOrSandbox(AppIdentifier id, string appVersion, string path, CancellationToken cancellationToken) { var key = Tuple.Create(id, appVersion, path); byte[] content; if (this.files.TryGetValue(key, out content)) return Task.FromResult(content); throw new ResourceNotFoundException("some_error", "file not found"); }
protected override Task<FileList> GetArchiveAsync(AppIdentifier id, string appVersion, CancellationToken cancellationToken) { FileList archive; if (this.archives.TryGetValue(string.Join(":", id, appVersion), out archive)) return Task.FromResult(archive); throw new ResourceNotFoundException("archive_not_found"); }
public static string File(string account, string workspace, AppIdentifier app, string service, string path) => $"/{account}/workspaces/{workspace}/apps/{app}/files/{service}/{path}";
public Task<App> GetMetadataAsync(AppIdentifier id) => Task.FromResult(this.GetApp(id));
public static string AppDependencies(string account, string workspace, AppIdentifier app, string service) => $"/{account}/workspaces/{workspace}/apps/{app}/dependencies?service={service}";
public static ResourceNotFoundException WithWorkspace(this ResourceNotFoundException @this, string account, string workspace, AppIdentifier app, string service, string filePath) { return new Builder { Account = account, Workspace = workspace, App = app.ToString(), Service = service, Path = filePath }.Build(@this); }
public static ResourceNotFoundException WithWorkspace(this ResourceNotFoundException @this, string account, string workspace, AppIdentifier app) { return new Builder { Account = account, Workspace = workspace, App = app.ToString() }.Build(@this); }
public TestableAppsContextConnector WithArchive(AppIdentifier id, string appVersion, FileList archive) { this.archives[string.Join(":", id, appVersion)] = archive; return this; }
public Task<IReadOnlyList<AppFileDescriptor>> AppListFilesAsync(AppIdentifier id, CancellationToken cancellationToken) => this.apps.ListFilesAsync(id, cancellationToken);
public TestableAppsContextConnector WithFileInAppOrSandbox(AppIdentifier id, string appVersion, string filePath, byte[] fileContent) { var key = Tuple.Create(id, appVersion, filePath); this.files[key] = fileContent; return this; }
public Task<App> AppGetMetadataAsync(AppIdentifier id) => this.apps.GetMetadataAsync(id);
protected override App GetApp(AppIdentifier id) { App app; if (this.mockedApps.TryGetValue(id, out app)) return app; throw new ResourceNotFoundException("app_not_installed", "The requested app is not installed: " + id); }
public Task<AppFile> AppGetFileAsync(AppIdentifier id, string path, CancellationToken cancellationToken) => this.apps.GetFileAsync(id, path, cancellationToken);