/// <summary>
 /// Initializes the provider with the data recieved from the cmdlet layer
 /// </summary>
 /// <param name="providerData">Data from the cmdlet layer intended for the provider</param>
 /// <param name="serviceClientAdapter">Service client adapter for communicating with the backend service</param>
 public void Initialize(
     Dictionary<System.Enum, object> providerData,
     ServiceClientAdapter serviceClientAdapter)
 {
     this.ProviderData = providerData;
     this.ServiceClientAdapter = serviceClientAdapter;
 }
        /// <summary>
        /// Initializes the service clients and the logging utility
        /// </summary>
        protected void InitializeAzureBackupCmdlet()
        {
            var cloudServicesClient = AzureSession.ClientFactory.CreateClient<CloudServiceManagementClient>(DefaultContext, AzureEnvironment.Endpoint.ResourceManager);
            ServiceClientAdapter = new ServiceClientAdapter(cloudServicesClient.Credentials, cloudServicesClient.BaseUri);

            WriteDebug("InsideRestore. going to create ResourceManager Client");
            RmClient = AzureSession.ClientFactory.CreateClient<ResourcesNS.ResourceManagementClient>(DefaultContext, AzureEnvironment.Endpoint.ResourceManager);
            WriteDebug("Client Created successfully");

            Logger.Instance = new Logger(WriteWarning, WriteDebug, WriteVerbose, ThrowTerminatingError);
        }
        /// <summary>
        /// Fetches policies by name
        /// </summary>
        /// <param name="policyName">Name of the policy to be fetched</param>
        /// <param name="serviceClientAdapter">Service client adapter with which to make calls</param>
        /// <returns></returns>
        public static ProtectionPolicyResponse GetProtectionPolicyByName(string policyName,
                                                 ServiceClientAdapter serviceClientAdapter)
        {
            ProtectionPolicyResponse response = null;

            try
            {                
                response = serviceClientAdapter.GetProtectionPolicy(policyName);
                Logger.Instance.WriteDebug("Successfully fetched policy from service: " + policyName);
            }
            catch (AggregateException exception)
            {
                // if http response is NotFound - then ignore and return NULL response
                if (exception.InnerException != null && exception.InnerException is CloudException)
                {
                    var cloudEx = exception.InnerException as CloudException;
                    if (cloudEx.Response != null)
                    {
                        if (cloudEx.Response.StatusCode != HttpStatusCode.NotFound)
                        {
                            Logger.Instance.WriteDebug("CloudException Response statusCode: " +
                                                        cloudEx.Response.StatusCode);
                            throw;
                        }
                    }
                    else
                    {
                        throw;
                    }
                }
                else
                {
                    throw;
                }
            }

            return response;
        }
 public PsBackupProviderManager(Dictionary<System.Enum, object> providerDataIn, ServiceClientAdapter serviceClientAdapterIn)
 {
     providerData = providerDataIn;
     serviceClientAdapter = serviceClientAdapterIn;
 }