Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Module"/> class.
        /// </summary>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <param name="automationAccountName">
        /// The account name.
        /// </param>
        /// <param name="webhook">
        /// The Webhook.
        /// </param>
        /// <param name="webhookUri">
        /// The Webhook URI
        /// </param>
        public Webhook(
            string resourceGroupName,
            string automationAccountName,
            Azure.Management.Automation.Models.Webhook webhook,
            string webhookUri = "")
        {
            Requires.Argument("resourceGroupName", resourceGroupName).NotNull();
            Requires.Argument("automationAccountName", automationAccountName).NotNull();
            Requires.Argument("webhook", webhook).NotNull();

            this.ResourceGroupName     = resourceGroupName;
            this.AutomationAccountName = automationAccountName;
            this.Name = webhook.Name;

            if (webhook.Properties == null)
            {
                return;
            }

            this.CreationTime = webhook.Properties.CreationTime.ToLocalTime();
            this.Description  = webhook.Properties.Description;
            this.ExpiryTime   = webhook.Properties.ExpiryTime.ToLocalTime();
            this.IsEnabled    = webhook.Properties.IsEnabled;
            if (webhook.Properties.LastInvokedTime.HasValue)
            {
                this.LastInvokedTime = webhook.Properties.LastInvokedTime.Value.ToLocalTime();
            }

            this.LastModifiedTime = webhook.Properties.LastModifiedTime.ToLocalTime();
            this.Parameters       = new Hashtable(webhook.Properties.Parameters.ToDictionary(kvp => kvp.Key, kvp => kvp.Value));
            this.RunbookName      = webhook.Properties.Runbook.Name;
            this.WebhookURI       = webhookUri;
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Module"/> class.
        /// </summary>
        /// <param name="resourceGroupName">
        /// The resource group name.
        /// </param>
        /// <param name="automationAccountName">
        /// The account name.
        /// </param>
        /// <param name="webhook">
        /// The Webhook.
        /// </param>
        /// <param name="webhookUri">
        /// The Webhook URI
        /// </param>
        public Webhook(
            string resourceGroupName,
            string automationAccountName,
            Azure.Management.Automation.Models.Webhook webhook,
            string webhookUri = "")
        {
            Requires.Argument("resourceGroupName", resourceGroupName).NotNull();
            Requires.Argument("automationAccountName", automationAccountName).NotNull();
            Requires.Argument("webhook", webhook).NotNull();

            this.ResourceGroupName     = resourceGroupName;
            this.AutomationAccountName = automationAccountName;
            this.Name = webhook.Name;

            if (webhook == null)
            {
                return;
            }

            this.CreationTime = webhook.CreationTime.ToLocalTime();
            this.Description  = webhook.Description;
            this.ExpiryTime   = webhook.ExpiryTime.ToLocalTime();
            this.IsEnabled    = webhook.IsEnabled;
            if (webhook.LastInvokedTime.HasValue)
            {
                this.LastInvokedTime = webhook.LastInvokedTime.Value.ToLocalTime();
            }

            this.LastModifiedTime = webhook.LastModifiedTime.ToLocalTime();
            this.Parameters       = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            if (webhook.Parameters != null)
            {
                foreach (var kvp in webhook.Parameters)
                {
                    this.Parameters.Add(kvp.Key, (object)PowerShellJsonConverter.Deserialize(kvp.Value));
                }
            }

            this.RunbookName  = webhook.Runbook.Name;
            this.WebhookURI   = webhookUri;
            this.HybridWorker = webhook.RunOn;
        }