Beispiel #1
0
        public void PerformOperation()
        {
            NapackClientSettings settings = Serializer.Deserialize <NapackClientSettings>(File.ReadAllText(this.NapackSettingsFile));

            string      userId     = this.UserId;
            List <Guid> accessKeys = this.AuthorizationKeys?.Split(';').Select(key => Guid.Parse(key)).ToList();

            if (string.IsNullOrWhiteSpace(this.UserId) || accessKeys == null || accessKeys.Count == 0)
            {
                DefaultCredentials defaultCredentials = Serializer.Deserialize <DefaultCredentials>(File.ReadAllText(NapackClient.GetDefaultCredentialFilePath()));
                userId     = defaultCredentials.UserId;
                accessKeys = defaultCredentials.Secrets;
            }

            UserSecret userSecret = new UserSecret()
            {
                UserId  = userId,
                Secrets = accessKeys
            };

            string packageName = Path.GetFileNameWithoutExtension(this.PackageFile);
            NapackLocalDescriptor napackDescriptor = Serializer.Deserialize <NapackLocalDescriptor>(File.ReadAllText(this.PackageFile));

            napackDescriptor.Validate(userId, true);

            using (NapackServerClient client = new NapackServerClient(settings.NapackFrameworkServer))
            {
                CreateOrUpdateNapackAsync(packageName, napackDescriptor, userSecret, client).GetAwaiter().GetResult();
            }
        }
Beispiel #2
0
        public void PerformOperation()
        {
            NapackClient.Log("Reading in the Napack settings file...");
            NapackClientSettings settings = Serializer.Deserialize <NapackClientSettings>(File.ReadAllText(this.NapackSettingsFile));

            string      userId     = this.UserId;
            List <Guid> accessKeys = this.AuthorizationKeys?.Split(';').Select(key => Guid.Parse(key)).ToList();

            if (string.IsNullOrWhiteSpace(this.UserId) || accessKeys == null || accessKeys.Count == 0)
            {
                DefaultCredentials defaultCredentials = Serializer.Deserialize <DefaultCredentials>(File.ReadAllText(NapackClient.GetDefaultCredentialFilePath()));
                userId     = defaultCredentials.UserId;
                accessKeys = defaultCredentials.Secrets;
            }

            UserSecret userSecret = new UserSecret()
            {
                UserId  = userId,
                Secrets = accessKeys
            };

            string packageName = Path.GetFileNameWithoutExtension(this.PackageFile);
            NapackLocalDescriptor napackDescriptor = Serializer.Deserialize <NapackLocalDescriptor>(File.ReadAllText(this.PackageFile));

            napackDescriptor.Validate(userId, false);

            using (NapackServerClient client = new NapackServerClient(settings.NapackFrameworkServer))
            {
                NewNapackMetadata metadata = new NewNapackMetadata()
                {
                    AuthorizedUserIds = napackDescriptor.AuthorizedUserIds,
                    Description       = napackDescriptor.Description,
                    MoreInformation   = napackDescriptor.MoreInformation,
                    Tags = napackDescriptor.Tags
                };

                string response = client.UpdatePackageMetadataAsync(packageName, metadata, userSecret).GetAwaiter().GetResult();
                NapackClient.Log($"Package metadata update result: {response}");
            }
        }