Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dazinator opened this issue Mar 26, 2024 · 0 comments
Open

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

dazinator opened this issue Mar 26, 2024 · 0 comments

Comments

@dazinator
Copy link

dazinator commented Mar 26, 2024

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant