Skip to content

ServiceCreationMode is missing replicated-job and global-job #674

Open

Description

This api that lets you list swarm services

   var serviceListParams = new ServicesListParameters()
        {
            Filters = new ServiceFilter()
            {
                Mode = new []
                {
                    ServiceCreationMode.Replicated
                }

the Mode filter requires an ServiceCreationMode enum, but that enum is missing a couple of items

  • replicated-job
  • global-job
   public class ServicesListParameters
    {
        [QueryStringParameter("filters", false, typeof(MapQueryStringConverter))]
        public ServiceFilter Filters { get; set; }
    }
    public class ServiceFilter : Dictionary<string, string[]>
    {
        public string[] Id
        {
            get => this["id"];
            set => this["id"] = value;
        }
        public string[] Label
        {
            get => this["label"];
            set => this["label"] = value;
        }
        public ServiceCreationMode[] Mode
        {
            get => this["mode"]?.ToList().Select(m => (ServiceCreationMode)Enum.Parse(typeof(ServiceCreationMode), m)).ToArray();
            set => this["mode"] = value?.Select(m => m.ToString()).ToArray();
        }
        public string[] Name
        {
            get => this["name"];
            set => this["name"] = value;
        }
    }

    public enum ServiceCreationMode
    {
        Replicated,
        Global
    }
}

Not too bad as it looks like I should be able to workaround it by directly accessing the dictionary, but then if I set "mode" = "replicated-job" in the dictionary, the "Mode" property get accessor will throw an exception with an invalid cast..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions