/// <summary>
 /// Initializes a new instance of the
 /// RunbookCreateOrUpdateDraftProperties class.
 /// </summary>
 /// <param name="runbookType">Gets or sets the type of the runbook.
 /// Possible values include: 'Script', 'Graph', 'PowerShellWorkflow',
 /// 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell'</param>
 /// <param name="draft">Gets or sets the draft runbook
 /// properties.</param>
 /// <param name="logVerbose">Gets or sets verbose log option.</param>
 /// <param name="logProgress">Gets or sets progress log option.</param>
 /// <param name="description">Gets or sets the description of the
 /// runbook.</param>
 /// <param name="logActivityTrace">Gets or sets the activity-level
 /// tracing options of the runbook.</param>
 public RunbookCreateOrUpdateDraftProperties(string runbookType, RunbookDraft draft, bool?logVerbose = default(bool?), bool?logProgress = default(bool?), string description = default(string), int?logActivityTrace = default(int?))
 {
     LogVerbose       = logVerbose;
     LogProgress      = logProgress;
     RunbookType      = runbookType;
     Draft            = draft;
     Description      = description;
     LogActivityTrace = logActivityTrace;
     CustomInit();
 }
 //Runbook exists both on disk and in the cloud. But are they in sync?
 public AutomationRunbook(FileInfo localFile, Runbook cloudRunbook, RunbookDraft cloudRunbookDraft)
     : base(cloudRunbook.Name, localFile.LastWriteTime, cloudRunbook.Properties.LastModifiedTime.LocalDateTime)
 {
     this.AuthoringState = cloudRunbook.Properties.State;
     this.localFileInfo = localFile;
     this.Description = cloudRunbook.Properties.Description;
     this.Parameters = cloudRunbook.Properties.Parameters;
     if (cloudRunbookDraft != null)
     {
         this.LastModifiedCloud = cloudRunbookDraft.LastModifiedTime.LocalDateTime;
         UpdateSyncStatus();
     }
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the RunbookCreateOrUpdateParameters
 /// class.
 /// </summary>
 /// <param name="runbookType">Gets or sets the type of the runbook.
 /// Possible values include: 'Script', 'Graph', 'PowerShellWorkflow',
 /// 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell'</param>
 /// <param name="logVerbose">Gets or sets verbose log option.</param>
 /// <param name="logProgress">Gets or sets progress log option.</param>
 /// <param name="draft">Gets or sets the draft runbook
 /// properties.</param>
 /// <param name="publishContentLink">Gets or sets the published runbook
 /// content link.</param>
 /// <param name="description">Gets or sets the description of the
 /// runbook.</param>
 /// <param name="logActivityTrace">Gets or sets the activity-level
 /// tracing options of the runbook.</param>
 /// <param name="name">Gets or sets the name of the resource.</param>
 /// <param name="location">Gets or sets the location of the
 /// resource.</param>
 /// <param name="tags">Gets or sets the tags attached to the
 /// resource.</param>
 public RunbookCreateOrUpdateParameters(string runbookType, bool?logVerbose = default(bool?), bool?logProgress = default(bool?), RunbookDraft draft = default(RunbookDraft), ContentLink publishContentLink = default(ContentLink), string description = default(string), int?logActivityTrace = default(int?), string name = default(string), string location = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>))
 {
     LogVerbose         = logVerbose;
     LogProgress        = logProgress;
     RunbookType        = runbookType;
     Draft              = draft;
     PublishContentLink = publishContentLink;
     Description        = description;
     LogActivityTrace   = logActivityTrace;
     Name     = name;
     Location = location;
     Tags     = tags;
     CustomInit();
 }
Beispiel #4
0
 /// <summary>
 /// Initializes a new instance of the
 /// RunbookCreateOrUpdateDraftProperties class with required arguments.
 /// </summary>
 public RunbookCreateOrUpdateDraftProperties(string runbookType, RunbookDraft draft)
     : this()
 {
     if (runbookType == null)
     {
         throw new ArgumentNullException("runbookType");
     }
     if (draft == null)
     {
         throw new ArgumentNullException("draft");
     }
     this.RunbookType = runbookType;
     this.Draft       = draft;
 }
Beispiel #5
0
 /// <summary>
 /// Initializes a new instance of the Runbook class.
 /// </summary>
 /// <param name="id">Fully qualified resource Id for the
 /// resource</param>
 /// <param name="name">The name of the resource</param>
 /// <param name="type">The type of the resource.</param>
 /// <param name="tags">Resource tags.</param>
 /// <param name="location">The Azure Region where the resource
 /// lives</param>
 /// <param name="runbookType">Gets or sets the type of the runbook.
 /// Possible values include: 'Script', 'Graph', 'PowerShellWorkflow',
 /// 'PowerShell', 'GraphPowerShellWorkflow', 'GraphPowerShell'</param>
 /// <param name="publishContentLink">Gets or sets the published runbook
 /// content link.</param>
 /// <param name="state">Gets or sets the state of the runbook. Possible
 /// values include: 'New', 'Edit', 'Published'</param>
 /// <param name="logVerbose">Gets or sets verbose log option.</param>
 /// <param name="logProgress">Gets or sets progress log option.</param>
 /// <param name="logActivityTrace">Gets or sets the option to log
 /// activity trace of the runbook.</param>
 /// <param name="jobCount">Gets or sets the job count of the
 /// runbook.</param>
 /// <param name="parameters">Gets or sets the runbook
 /// parameters.</param>
 /// <param name="outputTypes">Gets or sets the runbook output
 /// types.</param>
 /// <param name="draft">Gets or sets the draft runbook
 /// properties.</param>
 /// <param name="provisioningState">Gets or sets the provisioning state
 /// of the runbook. Possible values include: 'Succeeded'</param>
 /// <param name="lastModifiedBy">Gets or sets the last modified
 /// by.</param>
 /// <param name="creationTime">Gets or sets the creation time.</param>
 /// <param name="lastModifiedTime">Gets or sets the last modified
 /// time.</param>
 /// <param name="description">Gets or sets the description.</param>
 /// <param name="etag">Gets or sets the etag of the resource.</param>
 public Runbook(string id = default(string), string name = default(string), string type = default(string), IDictionary <string, string> tags = default(IDictionary <string, string>), string location = default(string), string runbookType = default(string), ContentLink publishContentLink = default(ContentLink), string state = default(string), bool?logVerbose = default(bool?), bool?logProgress = default(bool?), int?logActivityTrace = default(int?), int?jobCount = default(int?), IDictionary <string, RunbookParameter> parameters = default(IDictionary <string, RunbookParameter>), IList <string> outputTypes = default(IList <string>), RunbookDraft draft = default(RunbookDraft), RunbookProvisioningState?provisioningState = default(RunbookProvisioningState?), string lastModifiedBy = default(string), System.DateTimeOffset creationTime = default(System.DateTimeOffset), System.DateTimeOffset lastModifiedTime = default(System.DateTimeOffset), string description = default(string), string etag = default(string))
     : base(id, name, type, tags, location)
 {
     RunbookType        = runbookType;
     PublishContentLink = publishContentLink;
     State             = state;
     LogVerbose        = logVerbose;
     LogProgress       = logProgress;
     LogActivityTrace  = logActivityTrace;
     JobCount          = jobCount;
     Parameters        = parameters;
     OutputTypes       = outputTypes;
     Draft             = draft;
     ProvisioningState = provisioningState;
     LastModifiedBy    = lastModifiedBy;
     CreationTime      = creationTime;
     LastModifiedTime  = lastModifiedTime;
     Description       = description;
     Etag = etag;
     CustomInit();
 }
 /// <summary>
 /// Initializes a new instance of the
 /// RunbookCreateOrUpdateDraftProperties class with required arguments.
 /// </summary>
 public RunbookCreateOrUpdateDraftProperties(string runbookType, RunbookDraft draft)
     : this()
 {
     if (runbookType == null)
     {
         throw new ArgumentNullException("runbookType");
     }
     if (draft == null)
     {
         throw new ArgumentNullException("draft");
     }
     this.RunbookType = runbookType;
     this.Draft = draft;
 }
Beispiel #7
0
        public async Task<OperationResult> SaveRunbookAsync(RunbookModelProxy runbook, string runbookContent)
        {
            var runbookCreated = false;
            var response = default(RunbookCreateOrUpdateResponse);

            //if (runbook.RunbookID == Guid.Empty)
            //{
                //runbookNeedsCreation = true;

            // This is a new runbook!
            var draft = new RunbookDraft();
            draft.InEdit = true;
            draft.CreationTime = DateTimeOffset.Now;
            draft.LastModifiedTime = DateTimeOffset.Now;
                
            var details = new RunbookCreateOrUpdateDraftParameters();
            details.Name = runbook.RunbookName;
            details.Location = _connectionData.AzureRMLocation;
            details.Tags.Add(AutoStudioTagName, runbook.Tags != null ? runbook.Tags : string.Empty);

            details.Properties = new RunbookCreateOrUpdateDraftProperties();
            details.Properties.RunbookType = "Script";
            details.Properties.Description = "Runbook created with Automation Studio.";
            details.Properties.Draft = draft;

            response = await _client.Runbooks.CreateOrUpdateWithDraftAsync(_connectionData.AzureRMGroupName, _connectionData.AzureAutomationAccount, details);

            if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
                runbookCreated = false;
            else
                runbookCreated = true;

            // Need to set the draft runbook ID to notify the system that this runbook is in draft mode
            runbook.DraftRunbookVersionID = Guid.NewGuid();
            //}

            if (!runbookCreated /*&& runbookNeedsCreation*/)
            {
                return new OperationResult
                {
                    ErrorCode = response.StatusCode.ToString(),
                    ErrorMessage = "Unable to save the runbook",
                    HttpStatusCode = response.StatusCode,
                    Status = OperationStatus.Failed
                };
            }

            // Now we need to commit the draft
            var status = await SaveRunbookContentAsync(runbook, runbookContent, RunbookType.Draft);

            // Make sure that we add the runbook to our Env Explorer
            if (runbook.RunbookID == Guid.Empty)
            {
                Context.Start();
            }

            return new OperationResult
            {
                HttpStatusCode = System.Net.HttpStatusCode.OK,
                Status = status,
                RequestUrl = string.Empty
            };
        }