Exemplo n.º 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));
     }
 }
Exemplo n.º 2
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.");
     }
 }
Exemplo n.º 3
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.");
     }
 }
Exemplo n.º 4
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));
     }
 }
Exemplo n.º 5
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));
            }
        }