VariableSetResource

Namespace: Octopus.Client
We found 10 examples in language CSharp for this search. You will see 37 fragments of code.

        public static void ImportVariables(OctopusRepository octopusRepository, ProjectResource createdProject,
            VariableSetResource variables)
        {
            variables.OwnerId = createdProject.Id;
            variables.Links["Self"] = string.Format("/api/variables/{0}", createdProject.VariableSetId);
            variables.Version = 0;
            octopusRepository.VariableSets.Modify(variables);
        }

        public static void UpdateVariablesVersion(string projectSlug, OctopusRepository octopusRepository,
            ProjectResource project, VariableSetResource varaibleResources)
        {
            var variables = octopusRepository.VariableSets.Get(project.VariableSetId);
            varaibleResources.Version = variables.Version;
        }

        internal static List<ProjectGroupResource> ProjectGroups(string serverVersion)
        {
            var json = File.ReadAllText("TestData\\Responses\\" + serverVersion + "\\ProjectGroups.json");
            return JsonConvert.DeserializeObject<List<ProjectGroupResource>>(json);
        }

        internal static ResourceCollection<ProjectResource> Projects(string serverVersion, ProjectGroupResource projectGroupResource)
        {
            var json = File.ReadAllText("TestData\\Responses\\" + serverVersion + "\\" + projectGroupResource.Id + ".json");
            return JsonConvert.DeserializeObject<ResourceCollection<ProjectResource>>(json);
        }

        internal static ProjectResource Project(string serverVersion, string projectId)
        {
            var json = File.ReadAllText("TestData\\Responses\\" + serverVersion + "\\" + projectId + ".json");
            return JsonConvert.DeserializeObject<ProjectResource>(json);
        }

        internal static ProgressionResource Progresssion(string serverVersion, ProjectResource projectResource)
        {
            var json = File.ReadAllText("TestData\\Responses\\" + serverVersion + "\\" + projectResource.Id + "-Progression.json");
            return JsonConvert.DeserializeObject<ProgressionResource>(json);
        }

        internal static VariableSetResource VariableSet(string serverVersion, ProjectResource projectResource)
        {
            var json = File.ReadAllText("TestData\\Responses\\" + serverVersion + "\\" + projectResource.Id + "-VariableSet.json");
            return JsonConvert.DeserializeObject<VariableSetResource>(json);
        }

        public static async Task<IEnumerable<Variable>> ToModel(this VariableSetResource resource, DeploymentProcessResource deploymentProcessResource, IOctopusAsyncRepository repository)
        {
            return await Task.WhenAll(resource.Variables.Select(v => v.ToModel(deploymentProcessResource, repository)));
        }

        public static async Task<VariableSetResource> UpdateWith(this VariableSetResource resource, IVariableSet model, IOctopusAsyncRepository repository, DeploymentProcessResource deploymentProcess, ProjectResource project)
        {
            resource.Variables = (await Task.WhenAll(model.Variables.Select(v => new VariableResource().UpdateWith(v, repository, deploymentProcess, project)))).ToList();
            return resource;
        }

        VariableSetResource GetVariablePreview(string project, string channel, string tenant, string runbook, string action, string environment, string machine, string role);

        public string[] GetVariableNames(string project, string[] environments)
        {
            return Client.Get<string[]>(Repository.Link("VariableNames"), new { project, projectEnvironmentsFilter = environments ?? new string[0] });
        }

        public VariableSetResource GetVariablePreview(string project, string channel, string tenant, string runbook, string action, string environment, string machine, string role)
        {
            return Client.Get<VariableSetResource>(Repository.Link("VariablePreview"), new { project, channel, tenant, runbook, action, environment, machine, role });
        }

        public override List<VariableSetResource> Get(params string[] ids)
        {
            throw new NotSupportedException("VariableSet does not support this operation");
        }

        Task<VariableSetResource> GetVariablePreview(string project, string channel, string tenant, string runbook, string action, string environment, string machine, string role);

        public async Task<string[]> GetVariableNames(string project, string[] environments)
        {
            return await Client.Get<string[]>(await Repository.Link("VariableNames").ConfigureAwait(false), new { project, projectEnvironmentsFilter = environments ?? new string[0] }).ConfigureAwait(false);
        }

        public async Task<VariableSetResource> GetVariablePreview(string project, string channel, string tenant, string runbook, string action, string environment, string machine, string role)
        {
            return await Client.Get<VariableSetResource>(await Repository.Link("VariablePreview").ConfigureAwait(false), new { project, channel, tenant, runbook, action, environment, machine, role }).ConfigureAwait(false);
        }

        public override Task<List<VariableSetResource>> Get(params string[] ids)
        {
            throw new NotSupportedException("VariableSet does not support this operation");
        }


        public VariableSetResource AddOrUpdateVariableValue(string name, string value)
        {
            var existing = Variables.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) &&
                (x.Scope == null || x.Scope.Equals(new ScopeSpecification())));

            if (existing == null)
            {
                var template = new VariableResource
                {
                    Name = name,
                    Value = value,
                };

                Variables.Add(template);
            }
            else
            {
                existing.Name = name;
                existing.Value = value;
            }

            return this;
        }

        public VariableSetResource AddOrUpdateVariableValue(string name, string value, string description)
        {
            var existing = Variables.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) &&
                                                         (x.Scope == null || x.Scope.Equals(new ScopeSpecification())));

            if (existing == null)
            {
                var template = new VariableResource
                {
                    Name = name,
                    Value = value,
                    Description = description
                };

                Variables.Add(template);
            }
            else
            {
                existing.Name = name;
                existing.Value = value;
                existing.Description = description;
            }

            return this;
        }

        public VariableSetResource AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope)
        {
            var existing = Variables.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) && x.Scope.Equals(scope));
            if (existing == null)
            {
                var template = new VariableResource
                {
                    Name = name,
                    Value = value,
                    Scope = scope,
                };

                Variables.Add(template);
            }
            else
            {
                existing.Name = name;
                existing.Value = value;
                existing.Scope = scope;
            }

            return this;
        }

        public VariableSetResource AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope, bool isSensitive)
        {
            var existing = Variables.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) && x.Scope.Equals(scope));
            if (existing == null)
            {
                var template = new VariableResource
                {
                    Name = name,
                    Value = value,
                    Scope = scope,
                    IsSensitive = isSensitive
                };

                Variables.Add(template);
            }
            else
            {
                existing.Name = name;
                existing.Value = value;
                existing.Scope = scope;
                existing.IsSensitive = isSensitive;
            }

            return this;
        }

        public VariableSetResource AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope, bool isSensitive, string description)
        {
            var existing = Variables.FirstOrDefault(x => string.Equals(x.Name, name, StringComparison.OrdinalIgnoreCase) && x.Scope.Equals(scope));
            if (existing == null)
            {
                var template = new VariableResource
                {
                    Name = name,
                    Value = value,
                    Scope = scope,
                    IsSensitive = isSensitive,
                    Description = description
                };

                Variables.Add(template);
            }
            else
            {
                existing.Name = name;
                existing.Value = value;
                existing.Scope = scope;
                existing.IsSensitive = isSensitive;
                existing.Description = description;
            }

            return this;
        }

        public static async Task<LibraryVariableSet> ToModel(this LibraryVariableSetResource resource, IOctopusAsyncRepository repository)
        {
            var variableSetResource = await repository.VariableSets.Get(resource.VariableSetId);
            return new LibraryVariableSet(
                new ElementIdentifier(resource.Name), 
                resource.Description, 
                (LibraryVariableSet.VariableSetContentType) resource.ContentType,
                await Task.WhenAll(variableSetResource.Variables.Select(v => v.ToModel(null, repository))));
        }

        public static LibraryVariableSetResource UpdateWith(this LibraryVariableSetResource resource, LibraryVariableSet model)
        {
            resource.Name = model.Identifier.Name;
            resource.ContentType = (VariableSetContentType) model.ContentType;
            resource.Description = model.Description;
            return resource;
        }

using System.Collections.Generic;
using Octopus.Client.Model;

namespace Octopus.Cli.Model
{
    public class ProjectExport
    {
        public ProjectResource Project { get; set; }
        public ReferenceDataItem ProjectGroup { get; set; }
        public VariableSetResource VariableSet { get; set; }
        public List<ReferenceDataItem> NuGetFeeds { get; set; }
        public List<ReferenceDataItem> ActionTemplates { get; set; }
        public DeploymentProcessResource DeploymentProcess { get; set; }
        public List<ReferenceDataItem> LibraryVariableSets { get; set; }
        public ReferenceDataItem Lifecycle { get; set; }
        public List<ChannelResource> Channels { get; set; } 
        public List<ReferenceDataItem> ChannelLifecycles { get; set; }
        public List<ReferenceDataItem> WorkerPools { get; set; }
    }
}


        public VariableSetEditor Load(string id)
        {
            Instance = repository.Get(id);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope, bool isSensitive)
        {
            Instance.AddOrUpdateVariableValue(name, value, scope, isSensitive);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope, bool isSensitive, string description)
        {
            Instance.AddOrUpdateVariableValue(name, value, scope, isSensitive, description);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope)
        {
            Instance.AddOrUpdateVariableValue(name, value, scope);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value)
        {
            Instance.AddOrUpdateVariableValue(name, value);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, string description)
        {
            Instance.AddOrUpdateVariableValue(name, value, description);
            return this;
        }


        public async Task<VariableSetEditor> Load(string id)
        {
            Instance = await repository.Get(id).ConfigureAwait(false);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope, bool isSensitive)
        {
            Instance.AddOrUpdateVariableValue(name, value, scope, isSensitive);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope, bool isSensitive, string description)
        {
            Instance.AddOrUpdateVariableValue(name, value, scope, isSensitive, description);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, ScopeSpecification scope)
        {
            Instance.AddOrUpdateVariableValue(name, value, scope);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value)
        {
            Instance.AddOrUpdateVariableValue(name, value);
            return this;
        }

        public VariableSetEditor AddOrUpdateVariableValue(string name, string value, string description)
        {
            Instance.AddOrUpdateVariableValue(name, value, description);
            return this;
        }

Octopus.Client.Model.VariableSetResource : IResource, IAuditedResource, IHaveSpaceResource

Constructors :

public VariableSetResource()

Methods :

public String get_OwnerId()
public Void set_OwnerId(String value = )
public Int32 get_Version()
public Void set_Version(Int32 value = )
public IList<VariableResource> get_Variables()
public Void set_Variables(IList<VariableResource> value = )
public VariableScopeValues get_ScopeValues()
public Void set_ScopeValues(VariableScopeValues value = )
public VariableSetResource AddOrUpdateVariableValue(String name = , String value = )
public VariableSetResource AddOrUpdateVariableValue(String name = , String value = , String description = )
public VariableSetResource AddOrUpdateVariableValue(String name = , String value = , ScopeSpecification scope = )
public VariableSetResource AddOrUpdateVariableValue(String name = , String value = , ScopeSpecification scope = , Boolean isSensitive = )
public VariableSetResource AddOrUpdateVariableValue(String name = , String value = , ScopeSpecification scope = , Boolean isSensitive = , String description = )
public String get_SpaceId()
public Void set_SpaceId(String value = )
public String get_Id()
public Void set_Id(String value = )
public Nullable<DateTimeOffset> get_LastModifiedOn()
public Void set_LastModifiedOn(Nullable<DateTimeOffset> value = )
public String get_LastModifiedBy()
public Void set_LastModifiedBy(String value = )
public LinkCollection get_Links()
public Void set_Links(LinkCollection value = )
public Boolean HasLink(String name = )
public String Link(String name = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()

Other methods