/// <summary>
 /// Initializes a new instance of the WebhookCreateOrUpdateParameters
 /// class with required arguments.
 /// </summary>
 public WebhookCreateOrUpdateParameters(string name, WebhookCreateOrUpdateProperties properties)
     : this()
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Name = name;
     this.Properties = properties;
 }
 /// <summary>
 /// Initializes a new instance of the WebhookCreateOrUpdateParameters
 /// class with required arguments.
 /// </summary>
 public WebhookCreateOrUpdateParameters(string name, WebhookCreateOrUpdateProperties properties)
     : this()
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (properties == null)
     {
         throw new ArgumentNullException("properties");
     }
     this.Name       = name;
     this.Properties = properties;
 }
        public Model.Webhook CreateWebhook(
            string resourceGroupName,
            string automationAccountName,
            string name,
            string runbookName,
            bool isEnabled,
            DateTimeOffset expiryTime,
            Hashtable runbookParameters)
        {
            Requires.Argument("ResourceGroupName", resourceGroupName).NotNull();
            Requires.Argument("AutomationAccountName", automationAccountName).NotNull();
            using (var request = new RequestSettings(this.automationManagementClient))
            {
                var rbAssociationProperty = new RunbookAssociationProperty { Name = runbookName };
                var createOrUpdateProperties = new WebhookCreateOrUpdateProperties
                                                   {
                                                       IsEnabled = isEnabled,
                                                       ExpiryTime = expiryTime,
                                                       Runbook = rbAssociationProperty,
                                                       Uri =
                                                           this.automationManagementClient
                                                           .Webhooks.GenerateUri(
                                                               resourceGroupName,
                                                               automationAccountName).Uri
                                                   };
                if (runbookParameters != null)
                {
                    createOrUpdateProperties.Parameters =
                        runbookParameters.Cast<DictionaryEntry>()
                            .ToDictionary(kvp => (string)kvp.Key, kvp => (string)kvp.Value);
                }

                var webhookCreateOrUpdateParameters = new WebhookCreateOrUpdateParameters(
                    name,
                    createOrUpdateProperties);

                var webhook =
                    this.automationManagementClient.Webhooks.CreateOrUpdate(
                        resourceGroupName,
                        automationAccountName,
                        webhookCreateOrUpdateParameters).Webhook;

                return new Model.Webhook(
                    resourceGroupName,
                    automationAccountName,
                    webhook,
                    webhookCreateOrUpdateParameters.Properties.Uri);
            }
        }