コード例 #1
0
 public ConflictingVersionRequirementsException(string message, AppIdentifier dependency,
     IDictionary<AppIdentifier, string> requiredVersionsByDependent)
     : base(message)
 {
     Dependency = dependency;
     RequiredVersionsByDependent = new ReadOnlyDictionary<AppIdentifier, string>(requiredVersionsByDependent);
 }
コード例 #2
0
        public void Constructor_sets_value()
        {
            Guid id         = Guid.NewGuid();
            var  identifier = new AppIdentifier(id);

            identifier.Id.ShouldBe(id);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
        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();
        }
コード例 #5
0
 public static ResourceNotFoundException WithApp(this ResourceNotFoundException @this, AppIdentifier id)
 {
     return new Builder
     {
         Vendor = id.Vendor,
         App = id.Name
     }.Build(@this);
 }
コード例 #6
0
 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;
 }
コード例 #7
0
        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);
        }
コード例 #8
0
 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);
 }
コード例 #9
0
        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);
        }
コード例 #10
0
ファイル: InstalledApp.cs プロジェクト: vtex/apps-client-net
 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;
 }
コード例 #11
0
        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);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
 private string SandboxFor(AppIdentifier id) => this.sandboxes.GetSandboxFor(id)?.Name;
コード例 #15
0
 public Task<IReadOnlyList<AppFileDescriptor>> ListFilesAsync(AppIdentifier id,
     CancellationToken cancellationToken)
 {
     var meta = this.GetApp(id);
     return this.ListFilesAsync(meta.Id, meta.Version, cancellationToken);
 }
コード例 #16
0
        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());
        }
コード例 #17
0
 public static string App(string account, string workspace, AppIdentifier app)
     => $"/{account}/workspaces/{workspace}/apps/{app}";
コード例 #18
0
        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);
            }
        }
コード例 #19
0
ファイル: AppFile.cs プロジェクト: vtex/gallery-context-net
 public AppFile(AppIdentifier app, string path, byte[] content)
     : base(path, content)
 {
     this.App = app;
 }
コード例 #20
0
 public static AppFileDescriptor WithApp(this FileDescriptor @this, AppIdentifier app)
     => new AppFileDescriptor(app, @this.Path, @this.Hash, @this.Size);
コード例 #21
0
        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);
            }
        }
コード例 #22
0
 public static string RootFolders(string account, string workspace, AppIdentifier app)
     => $"/{account}/workspaces/{workspace}/apps/{app}/files";
コード例 #23
0
 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");
 }
コード例 #24
0
                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");
                }
コード例 #25
0
 public static string File(string account, string workspace, AppIdentifier app, string service, string path)
     => $"/{account}/workspaces/{workspace}/apps/{app}/files/{service}/{path}";
コード例 #26
0
 public Task<App> GetMetadataAsync(AppIdentifier id) => Task.FromResult(this.GetApp(id));
コード例 #27
0
 public static string AppDependencies(string account, string workspace, AppIdentifier app, string service)
     => $"/{account}/workspaces/{workspace}/apps/{app}/dependencies?service={service}";
コード例 #28
0
 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);
 }
コード例 #29
0
 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);
 }
コード例 #30
0
 public TestableAppsContextConnector WithArchive(AppIdentifier id, string appVersion, FileList archive)
 {
     this.archives[string.Join(":", id, appVersion)] = archive;
     return this;
 }
コード例 #31
0
 public Task<IReadOnlyList<AppFileDescriptor>> AppListFilesAsync(AppIdentifier id,
     CancellationToken cancellationToken)
     => this.apps.ListFilesAsync(id, cancellationToken);
コード例 #32
0
 public TestableAppsContextConnector WithFileInAppOrSandbox(AppIdentifier id, string appVersion,
     string filePath, byte[] fileContent)
 {
     var key = Tuple.Create(id, appVersion, filePath);
     this.files[key] = fileContent;
     return this;
 }
コード例 #33
0
 public Task<App> AppGetMetadataAsync(AppIdentifier id) => this.apps.GetMetadataAsync(id);
コード例 #34
0
                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);
                }
コード例 #35
0
 public Task<AppFile> AppGetFileAsync(AppIdentifier id, string path, CancellationToken cancellationToken)
     => this.apps.GetFileAsync(id, path, cancellationToken);