GetProtectionPolicy() публичный Метод

Gets a protection policy given the name
public GetProtectionPolicy ( string policyName ) : Microsoft.Azure.Management.RecoveryServices.Backup.Models.ProtectionPolicyResponse
policyName string Name of the policy
Результат Microsoft.Azure.Management.RecoveryServices.Backup.Models.ProtectionPolicyResponse
Пример #1
0
        /// <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;
        }