Exemplo n.º 1
0
        public async Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, OverwriteMode overwriteMode)
        {
            if (string.IsNullOrWhiteSpace(packageId))
            {
                throw new ArgumentException("A package Id must be supplied", nameof(packageId));
            }
            if (string.IsNullOrWhiteSpace(version))
            {
                throw new ArgumentException("A version must be supplied", nameof(version));
            }

            var resource = new OctopusPackageMetadataVersionResource
            {
                PackageId = packageId,
                Version   = version,
                OctopusPackageMetadata = octopusMetadata
            };

            var link = await repository.Link("PackageMetadata");

            // if the link contains overwriteMode then we're connected to a new server, if not use the old `replace` parameter
            if (link.Contains(OverwriteModeLink.Link))
            {
                return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { overwriteMode = overwriteMode }));
            }
            else
            {
                return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { replace = overwriteMode == OverwriteMode.OverwriteExisting }));
            }
        }
Exemplo n.º 2
0
        public async Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, OverwriteMode overwriteMode)
        {
            if (string.IsNullOrWhiteSpace(packageId))
            {
                throw new ArgumentException("A package Id must be supplied", nameof(packageId));
            }
            if (string.IsNullOrWhiteSpace(version))
            {
                throw new ArgumentException("A version must be supplied", nameof(version));
            }

            var resource = new OctopusPackageMetadataVersionResource
            {
                PackageId = packageId,
                Version   = version,
                OctopusPackageMetadata = octopusMetadata
            };

            if (await repository.HasLink("BuildInformation"))
            {
                Logger.Warn("Connected to an Octopus server that supports the BuildInformation API. It is recommended you move to using the BuildInformationRepository as the PackageMetadataRepository is deprecated.");
            }

            if (!(await repository.HasLink("PackageMetadata")))
            {
                throw new OperationNotSupportedByOctopusServerException(
                          OctopusPackageMetadata.PackageMetadataRequiresOctopusVersionMessage,
                          OctopusPackageMetadata.PackageMetadataRequiresOctopusVersion);
            }

            var link = await repository.Link("PackageMetadata");

            // if the link contains overwriteMode then we're connected to a new server, if not use the old `replace` parameter
            if (link.Contains(OverwriteModeLink.Link))
            {
                return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { overwriteMode = overwriteMode }));
            }
            else
            {
                return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { replace = overwriteMode.ConvertToLegacyReplaceFlag(Logger) }));
            }
        }
Exemplo n.º 3
0
        public OctopusPackageMetadataMappedResource Push(string packageId, string version, OctopusPackageMetadata octopusMetadata)
        {
            if (string.IsNullOrWhiteSpace(packageId))
            {
                throw new ArgumentException("A package Id must be supplied", nameof(packageId));
            }
            if (string.IsNullOrWhiteSpace(version))
            {
                throw new ArgumentException("A version must be supplied", nameof(version));
            }

            var resource = new OctopusPackageMetadataVersionResource
            {
                PackageId = packageId,
                Version   = version,
                OctopusPackageMetadata = octopusMetadata,
            };

            var link = repository.Link("PackageMetadata");

            return(repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource));
        }
        public async Task <OctopusPackageMetadataMappedResource> Push(string packageId, string version, OctopusPackageMetadata octopusMetadata, bool replaceExisting)
        {
            if (string.IsNullOrWhiteSpace(packageId))
            {
                throw new ArgumentException("A package Id must be supplied", nameof(packageId));
            }
            if (string.IsNullOrWhiteSpace(version))
            {
                throw new ArgumentException("A version must be supplied", nameof(version));
            }

            var resource = new OctopusPackageMetadataVersionResource
            {
                PackageId = packageId,
                Version   = version,
                OctopusPackageMetadata = octopusMetadata
            };

            var link = await repository.Link("PackageMetadata");

            return(await repository.Client.Post <OctopusPackageMetadataVersionResource, OctopusPackageMetadataMappedResource>(link, resource, new { replace = replaceExisting }));
        }