public Model.SourceControl CreateSourceControl(
            string resourceGroupName,
            string automationAccountName,
            string name,
            string description,
            SecureString accessToken,
            string repoUrl,
            string sourceType,
            string branch,
            string folderPath,
            bool publishRunbook,
            bool autoSync)
        {
            Requires.Argument("resourceGroupName", resourceGroupName).NotNullOrEmpty();
            Requires.Argument("automationAccountName", automationAccountName).NotNullOrEmpty();
            Requires.Argument("name", name).NotNullOrEmpty();
            Requires.Argument("accessToken", accessToken).NotNullOrEmpty();
            Requires.Argument("repoUrl", repoUrl).NotNullOrEmpty();
            Requires.Argument("sourceType", sourceType).NotNullOrEmpty();
            Requires.Argument("folderPath", folderPath).NotNullOrEmpty();

            if (String.Equals(sourceType, Constants.SupportedSourceType.GitHub.ToString()) ||
                String.Equals(sourceType, Constants.SupportedSourceType.VsoGit.ToString()))
            {
                Requires.Argument("branch", branch).NotNullOrEmpty();
            }

            var decryptedAccessToken = Utils.GetStringFromSecureString(accessToken);

            var createParams = new SourceControlCreateOrUpdateParameters(
                repoUrl,
                branch,
                folderPath,
                autoSync,
                publishRunbook,
                sourceType,
                GetAccessTokenProperties(decryptedAccessToken),
                description);

            var sdkSourceControl = this.automationManagementClient.SourceControl.CreateOrUpdate(
                resourceGroupName,
                automationAccountName,
                name,
                createParams);

            Model.SourceControl result = null;

            if (sdkSourceControl != null)
            {
                result = new Model.SourceControl(sdkSourceControl, automationAccountName, resourceGroupName);
            }

            return(result);
        }
 /// <summary>
 /// Create a source control.
 /// <see href="http://aka.ms/azureautomationsdk/sourcecontroloperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='sourceControlName'>
 /// The source control name.
 /// </param>
 /// <param name='parameters'>
 /// The parameters supplied to the create or update source control operation.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <SourceControl> CreateOrUpdateAsync(this ISourceControlOperations operations, string resourceGroupName, string automationAccountName, string sourceControlName, SourceControlCreateOrUpdateParameters parameters, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateOrUpdateWithHttpMessagesAsync(resourceGroupName, automationAccountName, sourceControlName, parameters, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Create a source control.
 /// <see href="http://aka.ms/azureautomationsdk/sourcecontroloperations" />
 /// </summary>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Name of an Azure Resource group.
 /// </param>
 /// <param name='automationAccountName'>
 /// The name of the automation account.
 /// </param>
 /// <param name='sourceControlName'>
 /// The source control name.
 /// </param>
 /// <param name='parameters'>
 /// The parameters supplied to the create or update source control operation.
 /// </param>
 public static SourceControl CreateOrUpdate(this ISourceControlOperations operations, string resourceGroupName, string automationAccountName, string sourceControlName, SourceControlCreateOrUpdateParameters parameters)
 {
     return(operations.CreateOrUpdateAsync(resourceGroupName, automationAccountName, sourceControlName, parameters).GetAwaiter().GetResult());
 }