Exemplo n.º 1
0
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. configId
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// Info about the async task
 /// </returns>
 public static TaskStatusInfo UpdateMigrationPlan(this IMigrationOperations operations, string configId, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IMigrationOperations)s).UpdateMigrationPlanAsync(configId, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 2
0
 /// <summary>
 /// Hydra spec for start migration plan rest APIThe rest api starts the
 /// estimation of time taken by migration for all/specific volume
 /// container(s) in the given config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='startPlanRequest'>
 /// Required. Start migration plan request model. The object passes the
 /// list of volume container(s) whose migration ETA needs to calculated
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response model for migration job status.
 /// </returns>
 public static MigrationJobStatus StartMigrationPlan(this IMigrationOperations operations, MigrationPlanStartRequest startPlanRequest, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IMigrationOperations)s).StartMigrationPlanAsync(startPlanRequest, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 3
0
 /// <summary>
 /// Hydra spec for import data container rest apiThe rest api initiates
 /// the migration of volume containers for all/specific data
 /// container(s) in the given config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='importDCRequest'>
 /// Required. Import data container request which specifies the list of
 /// data containers to be migrated
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response model for migration job status.
 /// </returns>
 public static MigrationJobStatus MigrationImportDataContainer(this IMigrationOperations operations, string configId, MigrationImportDataContainerRequest importDCRequest, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IMigrationOperations)s).MigrationImportDataContainerAsync(configId, importDCRequest, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 4
0
 /// <summary>
 /// Hydra spec for import legacy appliance config rest api.The rest api
 /// imports the legacy config to the service
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique id for config being imported
 /// </param>
 /// <param name='request'>
 /// Required. Legacy appliance config to be imported
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static AzureOperationResponse ImportLegacyApplianceConfig(this IMigrationOperations operations, string configId, LegacyApplianceConfig request, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IMigrationOperations)s).ImportLegacyApplianceConfigAsync(configId, request, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 5
0
 /// <summary>
 /// Hydra spec for confirm migration rest apiThe rest api confirms the
 /// commit or rollback of the migrated data containers for all data
 /// container in the specified config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='confirmMigrationRequest'>
 /// Required. The confirm migration request specifies the list of
 /// volume containers and rollback/commit operation to be performed
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response model for migration job status.
 /// </returns>
 public static MigrationJobStatus ConfirmMigration(this IMigrationOperations operations, string configId, MigrationConfirmStatusRequest confirmMigrationRequest, CustomRequestHeaders customRequestHeaders)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IMigrationOperations)s).ConfirmMigrationAsync(configId, confirmMigrationRequest, customRequestHeaders);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SFInstallableDblResource" /> class.
 /// </summary>
 /// <param name="userSecret">The user secret.</param>
 /// <param name="paratextOptions">The paratext options.</param>
 /// <param name="restClientFactory">The rest client factory.</param>
 /// <param name="fileSystemService">The file system service.</param>
 /// <param name="jwtTokenHelper">The JWT token helper.</param>
 /// <param name="projectDeleter">The project deleter.</param>
 /// <param name="migrationOperations">The migration operations.</param>
 /// <param name="passwordProvider">The password provider.</param>
 /// <exception cref="ArgumentNullException">restClientFactory</exception>
 private SFInstallableDblResource(UserSecret userSecret, ParatextOptions paratextOptions,
                                  ISFRestClientFactory restClientFactory, IFileSystemService fileSystemService,
                                  IJwtTokenHelper jwtTokenHelper, IProjectDeleter projectDeleter,
                                  IMigrationOperations migrationOperations, IZippedResourcePasswordProvider passwordProvider)
     : base(projectDeleter, migrationOperations, passwordProvider)
 {
     this._userSecret        = userSecret;
     this._paratextOptions   = paratextOptions;
     this._restClientFactory = restClientFactory;
     this._fileSystemService = fileSystemService;
     this._jwtTokenHelper    = jwtTokenHelper;
     if (this._restClientFactory == null)
     {
         throw new ArgumentNullException(nameof(restClientFactory));
     }
     else if (this._fileSystemService == null)
     {
         throw new ArgumentNullException(nameof(fileSystemService));
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the StorSimpleManagementClient class.
 /// </summary>
 /// <param name='httpClient'>
 /// The Http client
 /// </param>
 public StorSimpleManagementClient(HttpClient httpClient)
     : base(httpClient)
 {
     this._backup                             = new BackupOperations(this);
     this._backupPolicy                       = new BackupPolicyOperations(this);
     this._cloneVolume                        = new CloneVolumeOperations(this);
     this._dataContainer                      = new DataContainerOperations(this);
     this._deviceDetails                      = new DeviceDetailsOperations(this);
     this._deviceFailover                     = new DeviceFailoverOperations(this);
     this._deviceJob                          = new DeviceJobOperations(this);
     this._devices                            = new DeviceOperations(this);
     this._devicePublicKey                    = new DevicePublicKeyOperations(this);
     this._iscsiConnection                    = new IscsiConnectionDetailsOperations(this);
     this._migrateLegacyAppliance             = new MigrationOperations(this);
     this._resourceEncryptionKeys             = new ResourceEncryptionKeyOperations(this);
     this._serviceConfig                      = new ServiceConfigurationOperations(this);
     this._virtualDevice                      = new VirtualDeviceOperations(this);
     this._virtualDisk                        = new VirtualDiskOperations(this);
     this._apiVersion                         = "2014-01-01";
     this._longRunningOperationInitialTimeout = -1;
     this._longRunningOperationRetryTimeout   = -1;
     this.HttpClient.Timeout                  = TimeSpan.FromSeconds(300);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Hydra spec for update data container statusThe rest api updates the
 /// status of volume container migration from target device to service
 /// for all volume container in the specified config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// This is the Task Response for all Async Calls
 /// </returns>
 public static Task <TaskResponse> BeginUpdateDataContainerMigrationStatusAsync(this IMigrationOperations operations, string configId, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.BeginUpdateDataContainerMigrationStatusAsync(configId, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 9
0
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. configId
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// Info about the async task
 /// </returns>
 public static Task <TaskStatusInfo> UpdateMigrationPlanAsync(this IMigrationOperations operations, string configId, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.UpdateMigrationPlanAsync(configId, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 10
0
 /// <summary>
 /// Hydra spec for start migration plan rest APIThe rest api starts the
 /// estimation of time taken by migration for all/specific volume
 /// container(s) in the given config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='startPlanRequest'>
 /// Required. Start migration plan request model. The object passes the
 /// list of volume container(s) whose migration ETA needs to calculated
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response model for migration job status.
 /// </returns>
 public static Task <MigrationJobStatus> StartMigrationPlanAsync(this IMigrationOperations operations, MigrationPlanStartRequest startPlanRequest, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.StartMigrationPlanAsync(startPlanRequest, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 11
0
 /// <summary>
 /// Hydra spec for import data container rest apiThe rest api initiates
 /// the migration of volume containers for all/specific data
 /// container(s) in the given config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='importDCRequest'>
 /// Required. Import data container request which specifies the list of
 /// data containers to be migrated
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response model for migration job status.
 /// </returns>
 public static Task <MigrationJobStatus> MigrationImportDataContainerAsync(this IMigrationOperations operations, string configId, MigrationImportDataContainerRequest importDCRequest, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.MigrationImportDataContainerAsync(configId, importDCRequest, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 12
0
 /// <summary>
 /// Hydra spec for import legacy appliance config rest api.The rest api
 /// imports the legacy config to the service
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique id for config being imported
 /// </param>
 /// <param name='request'>
 /// Required. Legacy appliance config to be imported
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// A standard service response including an HTTP status code and
 /// request ID.
 /// </returns>
 public static Task <AzureOperationResponse> ImportLegacyApplianceConfigAsync(this IMigrationOperations operations, string configId, LegacyApplianceConfig request, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.ImportLegacyApplianceConfigAsync(configId, request, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 13
0
 /// <summary>
 /// Hydra spec for get migration planThe rest api get the migration
 /// plan from service for all volume container(s) in the specified
 /// config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response body for get migration plan rest api.
 /// </returns>
 public static Task <MigrationPlanList> GetMigrationPlanAsync(this IMigrationOperations operations, string configId, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.GetMigrationPlanAsync(configId, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 14
0
 /// <summary>
 /// Hydra spec for Get data container migration statusThe rest api
 /// returns the status of volume container migration status from
 /// service for all volume container in the specified config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response body for get data container migration status.
 /// </returns>
 public static Task <MigrationDataContainerStatusList> GetDataContainerMigrationStatusAsync(this IMigrationOperations operations, string configId, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.GetDataContainerMigrationStatusAsync(configId, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 15
0
 /// <summary>
 /// Hydra spec for confirm migration rest apiThe rest api confirms the
 /// commit or rollback of the migrated data containers for all data
 /// container in the specified config
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IMigrationOperations.
 /// </param>
 /// <param name='configId'>
 /// Required. Unique identifier for config specified while importing
 /// the config to service
 /// </param>
 /// <param name='confirmMigrationRequest'>
 /// Required. The confirm migration request specifies the list of
 /// volume containers and rollback/commit operation to be performed
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// The response model for migration job status.
 /// </returns>
 public static Task <MigrationJobStatus> ConfirmMigrationAsync(this IMigrationOperations operations, string configId, MigrationConfirmStatusRequest confirmMigrationRequest, CustomRequestHeaders customRequestHeaders)
 {
     return(operations.ConfirmMigrationAsync(configId, confirmMigrationRequest, customRequestHeaders, CancellationToken.None));
 }
Exemplo n.º 16
0
        /// <summary>
        /// Converts the JSON response to a list of Installable DBL Resources.
        /// </summary>
        /// <param name="baseUri">The base URI.</param>
        /// <param name="response">The response.</param>
        /// <param name="restClientFactory">The rest client factory.</param>
        /// <param name="fileSystemService">The file system service.</param>
        /// <param name="jwtTokenHelper">The JWT token helper.</param>
        /// <param name="createdTimestamp">The created timestamp.</param>
        /// <param name="userSecret">The user secret.</param>
        /// <param name="paratextOptions">The paratext options.</param>
        /// <param name="projectDeleter">The project deleter.</param>
        /// <param name="migrationOperations">The migration operations.</param>
        /// <param name="passwordProvider">The password provider.</param>
        /// <returns>
        /// The Installable Resources.
        /// </returns>
        private static IEnumerable <SFInstallableDblResource> ConvertJsonResponseToInstallableDblResources(
            string baseUri, string response, ISFRestClientFactory restClientFactory,
            IFileSystemService fileSystemService, IJwtTokenHelper jwtTokenHelper, DateTime createdTimestamp,
            UserSecret userSecret, ParatextOptions paratextOptions, IProjectDeleter projectDeleter,
            IMigrationOperations migrationOperations, IZippedResourcePasswordProvider passwordProvider)
        {
            if (!string.IsNullOrWhiteSpace(response))
            {
                JObject jsonResources;
                try
                {
                    jsonResources = JObject.Parse(response);
                }
                catch (JsonReaderException)
                {
                    // Ignore the exception and just return empty result
                    // This is probably caused by partial result from poor connection to DBL
                    yield break;
                }
                foreach (JToken jsonResource in jsonResources["resources"] as JArray ?? new JArray())
                {
                    var name       = (string)jsonResource["name"];
                    var nameCommon = (string)jsonResource["nameCommon"];
                    var fullname   = (string)jsonResource["fullname"];
                    if (string.IsNullOrWhiteSpace(fullname))
                    {
                        fullname = nameCommon;
                    }

                    var        languageName        = (string)jsonResource["languageName"];
                    var        id                  = (string)jsonResource["id"];
                    var        revision            = (string)jsonResource["revision"];
                    var        permissionsChecksum = (string)jsonResource["permissions-checksum"];
                    var        manifestChecksum    = (string)jsonResource["p8z-manifest-checksum"];
                    var        languageIdLdml      = (string)jsonResource["languageLDMLId"];
                    var        languageIdCode      = (string)jsonResource["languageCode"];
                    LanguageId languageId          =
                        migrationOperations.DetermineBestLangIdToUseForResource(languageIdLdml, languageIdCode);
                    if (string.IsNullOrEmpty(languageId.Id))
                    {
                        languageId = LanguageIdHelper.FromCommonLanguageName(languageName);
                    }
                    else
                    {
                        languageId = LanguageId.FromEthnologueCode(languageId.Id);
                    }

                    string url      = BuildDblResourceEntriesUrl(baseUri, id);
                    var    resource = new SFInstallableDblResource(userSecret, paratextOptions, restClientFactory,
                                                                   fileSystemService, jwtTokenHelper, projectDeleter, migrationOperations, passwordProvider)
                    {
                        DisplayName         = name,
                        Name                = name,
                        FullName            = fullname,
                        LanguageID          = languageId,
                        DblSourceUrl        = url,
                        DBLEntryUid         = id,
                        DBLRevision         = int.Parse(revision),
                        PermissionsChecksum = permissionsChecksum,
                        ManifestChecksum    = manifestChecksum,
                        CreatedTimestamp    = createdTimestamp,
                    };

                    resource.LanguageName = MacroLanguageHelper.GetMacroLanguage(resource.LanguageID) ?? languageName;

                    yield return(resource);
                }
            }
        }