Beispiel #1
0
 public async Task <string> UpdateIbxObject <T>(string url, string data)
 {
     if (InfobloxSDKExtensionMethods.IsInfobloxType <T>())
     {
         if (!String.IsNullOrEmpty(data))
         {
             if (!String.IsNullOrEmpty(url))
             {
                 return(await this.PutAsync(url, data));
             }
             else
             {
                 throw new ArgumentNullException("url", "The url parameter cannot be null or empty.");
             }
         }
         else
         {
             throw new ArgumentNullException("data", "The updated data cannot be null or empty.");
         }
     }
     else
     {
         throw new ArgumentException(String.Format("The type must be a valid infoblox object type, {0} was provided.", typeof(T).Name));
     }
 }
Beispiel #2
0
 public async Task <string> UpdateIbxObject(Type type, string reference, IEnumerable <KeyValuePair <string, string> > args)
 {
     if (type.IsInfobloxType())
     {
         if (args != null)
         {
             if (!String.IsNullOrEmpty(reference))
             {
                 return(await this.PutAsync(reference, InfobloxSDKExtensionMethods.PrepareArgsForSend(type, args)));
             }
             else
             {
                 throw new ArgumentNullException("reference", "The reference data cannot be null or empty.");
             }
         }
         else
         {
             throw new ArgumentNullException("ibxObject", "The updated object cannot be null.");
         }
     }
     else
     {
         throw new ArgumentException(String.Format("The type must be a valid infoblox object type, {0} was provided.", type.Name));
     }
 }
Beispiel #3
0
 public async Task <IEnumerable <T> > SearchIbxObject <T>(SearchType searchType, string searchField, string value, IEnumerable <string> fieldsToReturn)
 {
     if (InfobloxSDKExtensionMethods.IsInfobloxType <T>())
     {
         return(await this.SearchAsync <T>(CommandHelpers.BuildGetSearchRequest <T>(searchType, searchField, value, fieldsToReturn)));
     }
     else
     {
         throw new ArgumentException($"The type must be a valid infoblox object type, { typeof(T).FullName} was provided.");
     }
 }
Beispiel #4
0
 public async Task <string> NewIbxObject(Type type, IEnumerable <KeyValuePair <string, string> > args)
 {
     if (type.IsInfobloxType())
     {
         if (args.Any())
         {
             return(await this.PostAsync(type.GetNameAttribute(), InfobloxSDKExtensionMethods.PrepareArgsForSend(type, args)));
         }
         else
         {
             throw new ArgumentNullException("args", "The length of arguments must be greater than 0.");
         }
     }
     else
     {
         throw new ArgumentException($"The type must be a valid infoblox object type, {type.FullName} was provided.");
     }
 }
Beispiel #5
0
 public async Task <string> NewIbxObject(dynamic ibxObject)
 {
     if (ibxObject != null)
     {
         if (InfobloxSDKExtensionMethods.IsInfobloxType(ibxObject.GetType()))
         {
             return(await this.PostAsync(InfobloxSDKExtensionMethods.GetNameAttribute(ibxObject), InfobloxSDKExtensionMethods.PrepareObjectForSend(ibxObject, true)));
         }
         else
         {
             throw new ArgumentException($"The type must be a valid infoblox object type, {ibxObject.GetType().FullName} was provided.");
         }
     }
     else
     {
         throw new ArgumentNullException("ibxObject", "The ibxObject parameter cannot be null.");
     }
 }
Beispiel #6
0
 public async Task <T> GetIbxObject <T>(string reference, IEnumerable <string> fieldsToReturn)
 {
     if (InfobloxSDKExtensionMethods.IsInfobloxType <T>())
     {
         if (!String.IsNullOrEmpty(reference))
         {
             return(await this.GetAsync <T>(CommandHelpers.BuildGetRequest <T>(reference, fieldsToReturn)));
         }
         else
         {
             throw new ArgumentNullException("reference", "Reference data cannot be null or empty.");
         }
     }
     else
     {
         throw new ArgumentException(String.Format("The type must be a valid infoblox object type, {0} was provided.", typeof(T).Name));
     }
 }
Beispiel #7
0
        public async Task <string> UpdateIbxObject <T>(T ibxObject, bool RemoveEmpty = true) where T : RefObject
        {
            if (InfobloxSDKExtensionMethods.IsInfobloxType <T>())
            {
                if (ibxObject != null)
                {
                    PropertyInfo prop = ibxObject.GetType().GetTypeInfo().GetProperty("_ref");

                    if (prop != null)
                    {
                        string reference = prop.GetValue(ibxObject) as string;

                        if (!String.IsNullOrEmpty(reference))
                        {
                            string Json = InfobloxSDKExtensionMethods.PrepareObjectForSend(ibxObject, RemoveEmpty);

                            return(await this.PutAsync(reference, Json));
                        }
                        else
                        {
                            throw new ArgumentNullException("ibxObject._ref", "The _ref property cannot be null or empty.");
                        }
                    }
                    else
                    {
                        throw new ArgumentException("The updated object must contain a valid _ref property data cannot be null.");
                    }
                }
                else
                {
                    throw new ArgumentNullException("ibxObject", "The updated object cannot be null.");
                }
            }
            else
            {
                throw new ArgumentException(String.Format("The type must be a valid infoblox object type, {0} was provided.", typeof(T).Name));
            }
        }
Beispiel #8
0
 public static string GetNameAttributeUrlEncoded(dynamic obj)
 {
     return(WebUtility.UrlEncode(InfobloxSDKExtensionMethods.GetNameAttribute(obj)));
 }