@@ -91,6 +91,133 @@ let generated x =
9191let rec main () =
9292 List. iter (fun x -> if generated x then gen_binding x) classes;
9393 gen_xenref_converters classes;
94+ List. iter gen_http_action
95+ (List. filter (fun (_ , (_ , _ , sdk , _ , _ , _ )) -> sdk) http_actions)
96+
97+ (* ***************)
98+ (* Http actions *)
99+ (* ***************)
100+
101+ and gen_http_action action =
102+ match action with (name , (meth , uri , _ , args , _ , _ )) ->
103+ let commonVerb = get_http_action_verb name meth in
104+ let verbCategory = get_common_verb_category commonVerb in
105+ let stem = get_http_action_stem name in
106+ let content = sprintf " %s
107+
108+ using System;
109+ using System.Collections;
110+ using System.Collections.Generic;
111+ using System.Management.Automation;
112+ using System.Net;
113+ using System.Text;
114+
115+ using XenAPI;
116+
117+ namespace Citrix.XenServer.Commands
118+ {
119+ [Cmdlet(%s.%s, \" Xen%s\" %s)]
120+ [OutputType(typeof(void))]
121+ public class %sXen%sCommand : XenServerHttpCmdlet
122+ {
123+ #region Cmdlet Parameters
124+ %s%s
125+ #endregion
126+
127+ #region Cmdlet Methods
128+
129+ protected override void ProcessRecord()
130+ {
131+ GetSession();
132+ %s
133+ RunApiCall(() => %s);
134+ }
135+
136+ #endregion
137+ }
138+ }\n " Licence. bsd_two_clause
139+ verbCategory commonVerb stem (gen_should_process_http_decl meth)
140+ commonVerb stem
141+ (gen_progress_tracker meth)
142+ (gen_arg_params args)
143+ (gen_should_process_http meth uri)
144+ (gen_http_action_call action)
145+ in
146+ write_file (sprintf " %s-Xen%s.cs" commonVerb stem) content
147+
148+ and gen_should_process_http_decl meth =
149+ match meth with
150+ | Put -> " , SupportsShouldProcess = true"
151+ | Get -> " , SupportsShouldProcess = false"
152+ | _ -> assert false
153+
154+ and gen_should_process_http meth uri =
155+ match meth with
156+ | Put -> sprintf "
157+ if (!ShouldProcess(\" %s\" ))
158+ return;\n " uri
159+ | _ -> " "
160+
161+ and gen_progress_tracker meth =
162+ match meth with
163+ | Get -> "
164+ [Parameter]
165+ public HTTP.DataCopiedDelegate DataCopiedDelegate { get; set; }\n "
166+ | Put -> "
167+ [Parameter]
168+ public HTTP.UpdateProgressDelegate ProgressDelegate { get; set; }\n "
169+ | _ -> assert false
170+
171+ and gen_arg_params args =
172+ match args with
173+ | [] -> " "
174+ | hd ::tl -> sprintf " %s%s" (gen_arg_param hd) (gen_arg_params tl)
175+
176+ and gen_arg_param = function
177+ | String_query_arg x -> sprintf "
178+ [Parameter%s]
179+ public string %s { get; set; }\n "
180+ (if (String. lowercase x) = " uuid" then
181+ " (ValueFromPipelineByPropertyName = true)"
182+ else " " )
183+ (pascal_case_ x)
184+ | Int64_query_arg x -> sprintf "
185+ [Parameter]
186+ public long %s { get; set; }\n " (pascal_case_ x)
187+ | Bool_query_arg x ->
188+ let y = if x = " host" then " is_host" else x in
189+ sprintf "
190+ [Parameter]
191+ public bool %s { get; set; }\n " (pascal_case_ y)
192+ | Varargs_query_arg -> sprintf "
193+ ///<summary>
194+ /// Alternate names & values
195+ ///</summary>
196+ [Parameter]
197+ public string[] Args { get; set; }\n "
198+
199+ and gen_http_action_call (name , (meth , _ , _ , args , _ , _ )) =
200+ let progressTracker = match meth with
201+ | Get -> " DataCopiedDelegate"
202+ | Put -> " ProgressDelegate"
203+ | _ -> assert false in
204+ sprintf " XenAPI.HTTP_actions.%s(%s,
205+ CancellingDelegate, TimeoutMs, XenHost, Proxy, Path, TaskRef,
206+ session.opaque_ref%s)"
207+ name progressTracker (gen_call_arg_params args)
208+
209+ and gen_call_arg_params args =
210+ match args with
211+ | [] -> " "
212+ | hd ::tl -> sprintf " %s%s" (gen_call_arg_param hd) (gen_call_arg_params tl)
213+
214+ and gen_call_arg_param = function
215+ | String_query_arg x -> sprintf " , %s" (pascal_case_ x)
216+ | Int64_query_arg x -> sprintf " , %s" (pascal_case_ x)
217+ | Bool_query_arg x ->
218+ let y = if x = " host" then " is_host" else x in
219+ sprintf " , %s" (pascal_case_ y)
220+ | Varargs_query_arg -> sprintf " , Args"
94221
95222
96223(* **********************************)
@@ -223,7 +350,7 @@ using XenAPI;
223350
224351namespace Citrix.XenServer.Commands
225352{
226- [Cmdlet(VerbsCommon.Get, \" Xen%s\" , DefaultParameterSetName = \" Ref\" )]
353+ [Cmdlet(VerbsCommon.Get, \" Xen%s\" , DefaultParameterSetName = \" Ref\" , SupportsShouldProcess = false )]
227354 [OutputType(typeof(%s[]))]
228355 public class GetXen%sCommand : XenServerCmdlet
229356 {\n "
@@ -341,7 +468,7 @@ using XenAPI;
341468
342469namespace Citrix.XenServer.Commands
343470{
344- [Cmdlet(VerbsCommon.New, \" Xen%s\" , SupportsShouldProcess= true)]
471+ [Cmdlet(VerbsCommon.New, \" Xen%s\" , SupportsShouldProcess = true)]
345472 [OutputType(typeof(%s))]%s
346473 [OutputType(typeof(void))]
347474 public class NewXen%sCommand : XenServerCmdlet
@@ -562,7 +689,7 @@ using XenAPI;
562689
563690namespace Citrix.XenServer.Commands
564691{
565- [Cmdlet(VerbsCommon.Remove, \" Xen%s\" , SupportsShouldProcess= true)]
692+ [Cmdlet(VerbsCommon.Remove, \" Xen%s\" , SupportsShouldProcess = true)]
566693 [OutputType(typeof(%s))]%s
567694 [OutputType(typeof(void))]
568695 public class RemoveXen%s : XenServerCmdlet
@@ -639,7 +766,7 @@ using XenAPI;
639766
640767namespace Citrix.XenServer.Commands
641768{
642- [Cmdlet(VerbsCommon.Remove, \" Xen%sProperty\" , SupportsShouldProcess= true)]
769+ [Cmdlet(VerbsCommon.Remove, \" Xen%sProperty\" , SupportsShouldProcess = true)]
643770 [OutputType(typeof(%s))]%s
644771 public class RemoveXen%sProperty : XenServerCmdlet
645772 {
@@ -709,7 +836,7 @@ using XenAPI;
709836
710837namespace Citrix.XenServer.Commands
711838{
712- [Cmdlet(VerbsCommon.Set, \" Xen%s\" , SupportsShouldProcess= true)]
839+ [Cmdlet(VerbsCommon.Set, \" Xen%s\" , SupportsShouldProcess = true)]
713840 [OutputType(typeof(%s))]%s
714841 [OutputType(typeof(void))]
715842 public class SetXen%s : XenServerCmdlet
@@ -780,7 +907,7 @@ using XenAPI;
780907
781908namespace Citrix.XenServer.Commands
782909{
783- [Cmdlet(VerbsCommon.Add, \" Xen%s\" , SupportsShouldProcess= true)]
910+ [Cmdlet(VerbsCommon.Add, \" Xen%s\" , SupportsShouldProcess = true)]
784911 [OutputType(typeof(%s))]%s
785912 [OutputType(typeof(void))]
786913 public class AddXen%s : XenServerCmdlet
@@ -850,7 +977,7 @@ using XenAPI;
850977
851978namespace Citrix.XenServer.Commands
852979{
853- [Cmdlet(VerbsLifecycle.Invoke, \" Xen%s\" , SupportsShouldProcess= true)]
980+ [Cmdlet(VerbsLifecycle.Invoke, \" Xen%s\" , SupportsShouldProcess = true)]
854981 public class InvokeXen%s : XenServerCmdlet
855982 {
856983 #region Cmdlet Parameters
@@ -924,7 +1051,7 @@ using XenAPI;
9241051
9251052namespace Citrix.XenServer.Commands
9261053{
927- [Cmdlet(VerbsCommon.Get, \" Xen%sProperty\" , SupportsShouldProcess= false)]
1054+ [Cmdlet(VerbsCommon.Get, \" Xen%sProperty\" , SupportsShouldProcess = false)]
9281055 public class GetXen%sProperty : XenServerCmdlet
9291056 {
9301057 #region Cmdlet Parameters
0 commit comments