Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Call Operation with Dynamic Options

    Scheduled Pinned Locked Moved Support
    buildmaster
    4 Posts 2 Posters 0 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jharbison
      last edited by

      Is it possible to somehow call an operation with optional parameters without specifying the optional parameter names explicitly? Ideally I would like to be able to call an operation and pass in a map that contains the parameters. This would allow me to do something like the following where in reality %configuration is read in from an application variable that the user has access to change.

      set %configuration = %{To: somebody, Subject: something important, Text: some text};
      call Send-Email(%configuration);
      

      Instead I have to know all optional parameters that might be set ahead of time resulting in something like

      set set %configuration = %{To: somebody, Subject: something important, Text: some text};
      call Send-Email(
      To: $MapItem(%configuration, To),
      Subject: $MapItem(%configuration, Subject),
      Text: $MapItem(%configuration, Text)
      );
      

      This is fine for simple operations but when dealing with something like IIS::Ensure-AppPool that has over 40 parameters it quickly gets out of hand when different users need to specify a different subset of parameters. Currently all users need to specify all parameters with defaults even if they specifically only care about a couple.

      Product: BuildMaster
      Version: 5.6.8

      1 Reply Last reply Reply Quote 0
      • ? This user is from outside of this forum
        Guest
        last edited by

        Josh, this is an interesting use case, we haven't quite considered it. After discussing it a bit on our team, here's our idea:

        Invoke-Operation
        (
          Name: Send-Email,
          Arguments: %(To: somebody, Subject: something important, Text: some text)
        );
        
        Invoke-Operation ( Name: $OpName, Arguments: %OpArgs );
        

        Basically, it's an operation that invokes another operation. It's relatively easy to implement, and is something we would do in a maintence release.

        We definitely welcome your feedback.

        1 Reply Last reply Reply Quote 0
        • ? This user is from outside of this forum
          Guest
          last edited by

          An operation like that would be perfect. I had tried something along the same lines by constructing a string with the same structure as an operation call and using $Eval before noticing in the documentation that $Eval is only for variables and functions. This operation would fill that void.

          1 Reply Last reply Reply Quote 0
          • ? This user is from outside of this forum
            Guest
            last edited by

            This has been added as BM-3004, and is currently scheduled for 5.6.10.

            1 Reply Last reply Reply Quote 0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post
            Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation