public void TestConstructorWithUnknowRegionThrowException() { // ARRANGE const string applicationKey = "applicationKey"; const string applicationSecret = "applicationSecret"; const string region = "bad-region"; // ACT var ovhApi = new OvhApi(applicationKey, applicationSecret, region); }
public void TestConstructorWithInvalidRegionThrowException() { // ARRANGE const string applicationKey = "applicationKey"; const string applicationSecret = "applicationSecret"; const string region = null; // ACT var ovhApi = new OvhApi(applicationKey, applicationSecret, region); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="serviceName">The internal name of your CDN offer</param> /// </summary> public async Task UpdateCdnDedicatedServiceinfos(OvhApi.Models.Services.Service requestBody,string serviceName) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNullNorEmpty("serviceName",serviceName); await RawCall(HttpMethod.Put,String.Format("/cdn/dedicated/{0}/serviceInfos",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Return quota history /// <param name="period">To be written</param> /// <param name="serviceName">The internal name of your CDN offer</param> /// </summary> public async Task<OvhApi.Models.Cdnanycast.StatsDataType[]> GetCdnDedicatedQuotas(OvhApi.Models.Cdnanycast.StatsPeriodEnum period,string serviceName) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("period",period); Ensure.NotNullNorEmpty("serviceName",serviceName); var queryString = new QueryString(); queryString.Add("period",period); return await RawCall<OvhApi.Models.Cdnanycast.StatsDataType[]>(HttpMethod.Get,String.Format("/cdn/dedicated/{0}/quota{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),queryString)); }
public void TestRequestConsumerKeyWithInvalidKeyReturnStringEmpty() { // ARRANGE const string applicationKey = "applicationKey"; const string applicationSecret = "applicationSecret"; var ovhApi = new OvhApi(applicationKey, applicationSecret); // ACT string requestConsumerKey = ovhApi.RequestConsumerKey(); // ASSERT Assert.AreEqual(requestConsumerKey, string.Empty, "requestConsumerKey is not empty"); }
public void TestConstructorWithValidArguments() { // ARRANGE const string applicationKey = "applicationKey"; const string applicationSecret = "applicationSecret"; // ACT var ovhApi = new OvhApi(applicationKey, applicationSecret); // ASSERT Assert.IsNotNull(ovhApi, "instance is null"); Assert.IsNotNull(ovhApi.ApplicationKey, "application key is null"); Assert.IsNotNull(ovhApi.ApplicationSecret, "application secret is null"); Assert.IsNotNull(ovhApi.EndPointName, "end point name is null"); Assert.AreEqual(applicationKey, ovhApi.ApplicationKey, "application key is not the same has been set"); Assert.AreEqual(applicationSecret, ovhApi.ApplicationSecret, "application secret is not the same has been set"); }
/// <summary> /// Add a cache rule to a domain /// <param name="cacheType">Type of cache rule to add to the domain</param> /// <param name="ttl">ttl for cache rule to add to the domain</param> /// <param name="fileMatch">File match for cache rule to add to the domain</param> /// <param name="fileType">File type for cache rule to add to the domain</param> /// <param name="serviceName">The internal name of your CDN offer</param> /// <param name="domain">Domain of this object</param> /// </summary> public OvhApi.Models.Cdnanycast.CacheRule CreateCdnDedicatedDomainsCacherules(OvhApi.Models.Cdnanycast.CacheRuleCacheTypeEnum cacheType,long ttl,string fileMatch,OvhApi.Models.Cdnanycast.CacheRuleFileTypeEnum fileType,string serviceName,string domain) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("cacheType",cacheType); Ensure.IdIsValid("ttl",ttl); Ensure.NotNullNorEmpty("fileMatch",fileMatch); Ensure.NotNull("fileType",fileType); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("domain",domain); var requestBody = new Dictionary<string, object>(); requestBody.Add("cacheType",cacheType); requestBody.Add("ttl",ttl); requestBody.Add("fileMatch",fileMatch); requestBody.Add("fileType",fileType); return RawCall<OvhApi.Models.Cdnanycast.CacheRule>(HttpMethod.Post,String.Format("/cdn/dedicated/{0}/domains/{1}/cacheRules",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(domain.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Ip under mitigation /// <param name="auto">Filter the value of auto property (=)</param> /// <param name="state">Filter the value of state property (=)</param> /// <param name="ip">To be written</param> /// </summary> public async Task<System.Net.IPAddress[]> GetIpMitigations(OVHApi.IPAddressBlock ip,OvhApi.Models.Ip.MitigationStateEnum? state = null,bool? auto = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("ip",ip); var queryString = new QueryString(); queryString.Add("auto",auto); queryString.Add("state",state); return await RawCall<System.Net.IPAddress[]>(HttpMethod.Get,String.Format("/ip/{0}/mitigation{1}",System.Uri.EscapeDataString(ip.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Add mailing list /// <param name="joinRestriction">Join restriction policy</param> /// <param name="departRestriction">Depart restriction policy</param> /// <param name="hiddenFromGAL">If true mailing list is hiddend in Global Address List</param> /// <param name="mailingListAddress">The mailing list address</param> /// <param name="senderAuthentification">If true sender has to authenticate</param> /// <param name="maxSendSize">Maximum send email size in MB</param> /// <param name="maxReceiveSize">Maximum receive email size in MB</param> /// <param name="displayName">Name displayed in Global Access List</param> /// <param name="organizationName">The internal name of your exchange organization</param> /// <param name="exchangeService">The internal name of your exchange service</param> /// </summary> public async Task<OvhApi.Models.Email.Exchange.Task> CreateEmailExchangeServiceMailinglist(OvhApi.Models.Email.Exchange.MailingListJoinRestrictionEnum joinRestriction,OvhApi.Models.Email.Exchange.MailingListDepartRestrictionEnum departRestriction,string mailingListAddress,string organizationName,string exchangeService,string displayName = null,long? maxReceiveSize = null,long? maxSendSize = null,bool? senderAuthentification = null,bool? hiddenFromGAL = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("joinRestriction",joinRestriction); Ensure.NotNull("departRestriction",departRestriction); Ensure.NotNullNorEmpty("mailingListAddress",mailingListAddress); Ensure.NotNullNorEmpty("organizationName",organizationName); Ensure.NotNullNorEmpty("exchangeService",exchangeService); var requestBody = new Dictionary<string, object>(); requestBody.Add("joinRestriction",joinRestriction); requestBody.Add("departRestriction",departRestriction); requestBody.Add("hiddenFromGAL",hiddenFromGAL); requestBody.Add("mailingListAddress",mailingListAddress); requestBody.Add("senderAuthentification",senderAuthentification); requestBody.Add("maxSendSize",maxSendSize); requestBody.Add("maxReceiveSize",maxReceiveSize); requestBody.Add("displayName",displayName); return await RawCall<OvhApi.Models.Email.Exchange.Task>(HttpMethod.Post,String.Format("/email/exchange/{0}/service/{1}/mailingList",System.Uri.EscapeDataString(organizationName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(exchangeService.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Your OVH IPs /// <param name="ip">Filter the value of ip property (contains or equals)</param> /// <param name="routedTo_serviceName">Filter the value of routedTo.serviceName property (like)</param> /// <param name="type">Filter the value of type property (=)</param> /// <param name="description">Filter the value of description property (like)</param> /// </summary> public async Task<OVHApi.IPAddressBlock[]> GetIps(string description = null,OvhApi.Models.Ip.IpTypeEnum? type = null,string routedTo_serviceName = null,OVHApi.IPAddressBlock ip = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); var queryString = new QueryString(); queryString.Add("ip",ip); queryString.Add("routedTo.serviceName",routedTo_serviceName); queryString.Add("type",type); queryString.Add("description",description); return await RawCall<OVHApi.IPAddressBlock[]>(HttpMethod.Get,String.Format("/ip{0}",queryString)); }
/// <summary> /// Create new profile for one of your ip /// <param name="ipMitigationProfile">To be written</param> /// <param name="autoMitigationTimeOut">Delay to wait before remove ip from auto mitigation after an attack</param> /// <param name="ip">To be written</param> /// </summary> public async Task<OvhApi.Models.Ip.MitigationProfile> CreateIpMitigationprofiles(System.Net.IPAddress ipMitigationProfile,OvhApi.Models.Ip.MitigationProfileAutoMitigationTimeOutEnum autoMitigationTimeOut,OVHApi.IPAddressBlock ip) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("ipMitigationProfile",ipMitigationProfile); Ensure.NotNull("autoMitigationTimeOut",autoMitigationTimeOut); Ensure.NotNull("ip",ip); var requestBody = new Dictionary<string, object>(); requestBody.Add("ipMitigationProfile",ipMitigationProfile); requestBody.Add("autoMitigationTimeOut",autoMitigationTimeOut); return await RawCall<OvhApi.Models.Ip.MitigationProfile>(HttpMethod.Post,String.Format("/ip/{0}/mitigationProfiles",System.Uri.EscapeDataString(ip.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="serviceName">The internal name of your hosting</param> /// <param name="id">Cron's id</param> /// </summary> public async Task UpdateHostingWebCron(OvhApi.Models.Hosting.Web.Cron requestBody,string serviceName,long id) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.IdIsValid("id",id); await RawCall(HttpMethod.Put,String.Format("/hosting/web/{0}/cron/{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(id.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Link a domain to this hosting /// <param name="cdn">Is linked to the hosting cdn</param> /// <param name="domain">Domain to link</param> /// <param name="path">Domain's path, relative to your home directory</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> CreateHostingWebAttacheddomain(string domain,string path,string serviceName,OvhApi.Models.Hosting.Web.AttachedDomain.CdnEnum? cdn = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("domain",domain); Ensure.NotNullNorEmpty("path",path); Ensure.NotNullNorEmpty("serviceName",serviceName); var requestBody = new Dictionary<string, object>(); requestBody.Add("cdn",cdn); requestBody.Add("domain",domain); requestBody.Add("path",path); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Post,String.Format("/hosting/web/{0}/attachedDomain",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Crons on your hosting /// <param name="email">Filter the value of email property (like)</param> /// <param name="language">Filter the value of language property (=)</param> /// <param name="description">Filter the value of description property (like)</param> /// <param name="command">Filter the value of command property (like)</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<long[]> GetHostingWebCronIds(string serviceName,string command = null,string description = null,OvhApi.Models.Hosting.Web.Cron.LanguageEnum? language = null,string email = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("serviceName",serviceName); var queryString = new QueryString(); queryString.Add("email",email); queryString.Add("language",language); queryString.Add("description",description); queryString.Add("command",command); return await RawCall<long[]>(HttpMethod.Get,String.Format("/hosting/web/{0}/cron{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Request the dump from your database /// <param name="date">The date you want to dump</param> /// <param name="serviceName">The internal name of your hosting</param> /// <param name="name">Database name</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> CreateHostingWebDatabaseDump(OvhApi.Models.Hosting.Web.Database.DumpDateEnum date,string serviceName,string name) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("date",date); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("name",name); var requestBody = new Dictionary<string, object>(); requestBody.Add("date",date); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Post,String.Format("/hosting/web/{0}/database/{1}/dump",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(name.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Databases linked to your hosting /// <param name="mode">Filter the value of mode property (=)</param> /// <param name="user">Filter the value of user property (like)</param> /// <param name="name">Filter the value of name property (like)</param> /// <param name="type">Filter the value of type property (=)</param> /// <param name="server">Filter the value of server property (like)</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<string[]> GetHostingWebDatabaseNames(string serviceName,string server = null,OvhApi.Models.Hosting.Web.Database.DatabaseTypeEnum? type = null,string name = null,string user = null,OvhApi.Models.Hosting.Web.Database.ModeEnum? mode = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("serviceName",serviceName); var queryString = new QueryString(); queryString.Add("mode",mode); queryString.Add("user",user); queryString.Add("name",name); queryString.Add("type",type); queryString.Add("server",server); return await RawCall<string[]>(HttpMethod.Get,String.Format("/hosting/web/{0}/database{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Get statistics about request on CDN, bandwidth value in Bytes /// <param name="period">To be written</param> /// <param name="value">To be written</param> /// <param name="type">To be written</param> /// <param name="serviceName">The internal name of your CDN Website offer</param> /// <param name="domain">To be written</param> /// </summary> public async Task<OvhApi.Models.Cdn.Website.StatsDataType[]> GetCdnWebsiteZoneDomainsStatistics(OvhApi.Models.Cdn.Website.StatsPeriodEnum period,OvhApi.Models.Cdn.Website.StatsValueEnum value,OvhApi.Models.Cdn.Website.StatsTypeEnum type,string serviceName,string domain) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("period",period); Ensure.NotNull("value",value); Ensure.NotNull("type",type); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("domain",domain); var queryString = new QueryString(); queryString.Add("period",period); queryString.Add("value",value); queryString.Add("type",type); return await RawCall<OvhApi.Models.Cdn.Website.StatsDataType[]>(HttpMethod.Get,String.Format("/cdn/website/{0}/zone/domains/{1}/statistics{2}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(domain.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Get active licenses for specific period of time /// <param name="license">License type</param> /// <param name="toDate">Get active licenses until date</param> /// <param name="fromDate">Get active licenses since date </param> /// <param name="organizationName">The internal name of your exchange organization</param> /// <param name="exchangeService">The internal name of your exchange service</param> /// </summary> public async Task<OvhApi.Models.Email.Exchange.DailyLicense[]> GetEmailExchangeServiceLicenses(string organizationName,string exchangeService,DateTime? fromDate = null,DateTime? toDate = null,OvhApi.Models.Email.Exchange.OvhLicenceEnum? license = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("organizationName",organizationName); Ensure.NotNullNorEmpty("exchangeService",exchangeService); var queryString = new QueryString(); queryString.Add("license",license); queryString.Add("toDate",toDate); queryString.Add("fromDate",fromDate); return await RawCall<OvhApi.Models.Email.Exchange.DailyLicense[]>(HttpMethod.Get,String.Format("/email/exchange/{0}/service/{1}/license{2}",System.Uri.EscapeDataString(organizationName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(exchangeService.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Install new database /// <param name="quota">Quota assign to your database. Only for extraSql</param> /// <param name="password">Database password</param> /// <param name="version">Version you want for your database following the type</param> /// <param name="capabilitie">Type of your database</param> /// <param name="user">Database user name. Must begin with your hosting login and must be in lower case</param> /// <param name="type">Type you want for your database</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> CreateHostingWebDatabase(OvhApi.Models.Hosting.Web.Database.DatabaseCapabilitiesTypeEnum capabilitie,string user,OvhApi.Models.Hosting.Web.Database.DatabaseTypeEnum type,string serviceName,OvhApi.Models.Hosting.Web.Database.VersionEnum? version = null,string password = null,OvhApi.Models.Hosting.Web.Database.ExtraSqlQuotaEnum? quota = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("capabilitie",capabilitie); Ensure.NotNullNorEmpty("user",user); Ensure.NotNull("type",type); Ensure.NotNullNorEmpty("serviceName",serviceName); var requestBody = new Dictionary<string, object>(); requestBody.Add("quota",quota); requestBody.Add("password",password); requestBody.Add("version",version); requestBody.Add("capabilitie",capabilitie); requestBody.Add("user",user); requestBody.Add("type",type); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Post,String.Format("/hosting/web/{0}/database",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// create new resource account in exchange server /// <param name="resourceEmailAddress">resource address</param> /// <param name="allowConflict">resource can be scheduled by more than one person during the same time period</param> /// <param name="type">field of your reservation</param> /// <param name="capacity">number of the same equipment or capacity of a room</param> /// <param name="displayName">resource account display name</param> /// <param name="organizationName">The internal name of your exchange organization</param> /// <param name="exchangeService">The internal name of your exchange service</param> /// </summary> public async Task<OvhApi.Models.Email.Exchange.Task> CreateEmailExchangeServiceResourceaccount(string resourceEmailAddress,OvhApi.Models.Email.Exchange.ResourceTypeEnum type,long capacity,string organizationName,string exchangeService,string displayName = null,bool? allowConflict = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("resourceEmailAddress",resourceEmailAddress); Ensure.NotNull("type",type); Ensure.IdIsValid("capacity",capacity); Ensure.NotNullNorEmpty("organizationName",organizationName); Ensure.NotNullNorEmpty("exchangeService",exchangeService); var requestBody = new Dictionary<string, object>(); requestBody.Add("resourceEmailAddress",resourceEmailAddress); requestBody.Add("allowConflict",allowConflict); requestBody.Add("type",type); requestBody.Add("capacity",capacity); requestBody.Add("displayName",displayName); return await RawCall<OvhApi.Models.Email.Exchange.Task>(HttpMethod.Post,String.Format("/email/exchange/{0}/service/{1}/resourceAccount",System.Uri.EscapeDataString(organizationName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(exchangeService.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Get statistics about this database /// <param name="period">To be written</param> /// <param name="type">To be written</param> /// <param name="serviceName">The internal name of your hosting</param> /// <param name="name">Database name</param> /// </summary> public async Task<OvhApi.Models.ComplexType.ChartSerie<OvhApi.Models.ComplexType.ChartTimestampValue>[]> GetHostingWebDatabaseStatistics(OvhApi.Models.Hosting.Web.StatisticsPeriodEnum period,OvhApi.Models.Hosting.Web.Database.StatisticsTypeEnum type,string serviceName,string name) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("period",period); Ensure.NotNull("type",type); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("name",name); var queryString = new QueryString(); queryString.Add("period",period); queryString.Add("type",type); return await RawCall<OvhApi.Models.ComplexType.ChartSerie<OvhApi.Models.ComplexType.ChartTimestampValue>[]>(HttpMethod.Get,String.Format("/hosting/web/{0}/database/{1}/statistics{2}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(name.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="organizationName">The internal name of your exchange organization</param> /// <param name="exchangeService">The internal name of your exchange service</param> /// <param name="resourceEmailAddress">resource as email</param> /// </summary> public async Task UpdateEmailExchangeServiceResourceaccount(OvhApi.Models.Email.Exchange.ResourceAccount requestBody,string organizationName,string exchangeService,string resourceEmailAddress) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNullNorEmpty("organizationName",organizationName); Ensure.NotNullNorEmpty("exchangeService",exchangeService); Ensure.NotNullNorEmpty("resourceEmailAddress",resourceEmailAddress); await RawCall(HttpMethod.Put,String.Format("/email/exchange/{0}/service/{1}/resourceAccount/{2}",System.Uri.EscapeDataString(organizationName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(exchangeService.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(resourceEmailAddress.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Create new cron /// <param name="frequency">Frequency ( crontab format ) define for the script ( minutes are ignored )</param> /// <param name="email">Email use to receive error log ( stderr )</param> /// <param name="language">Cron language</param> /// <param name="description">Description field for you</param> /// <param name="command">Command to execute</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<string> CreateHostingWebCron(string frequency,OvhApi.Models.Hosting.Web.Cron.LanguageEnum language,string command,string serviceName,string description = null,string email = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("frequency",frequency); Ensure.NotNull("language",language); Ensure.NotNullNorEmpty("command",command); Ensure.NotNullNorEmpty("serviceName",serviceName); var requestBody = new Dictionary<string, object>(); requestBody.Add("frequency",frequency); requestBody.Add("email",email); requestBody.Add("language",language); requestBody.Add("description",description); requestBody.Add("command",command); return await RawCall<string>(HttpMethod.Post,String.Format("/hosting/web/{0}/cron",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// List available database version following a type /// <param name="type">Type of the database</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Database.VersionEnum[]> GetHostingWebDatabaseavailableversions(OvhApi.Models.Hosting.Web.Database.DatabaseTypeEnum type,string serviceName) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("type",type); Ensure.NotNullNorEmpty("serviceName",serviceName); var queryString = new QueryString(); queryString.Add("type",type); return await RawCall<OvhApi.Models.Hosting.Web.Database.VersionEnum[]>(HttpMethod.Get,String.Format("/hosting/web/{0}/databaseAvailableVersion{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="serviceName">The internal name of your hosting</param> /// <param name="domain">Domain linked (fqdn)</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> UpdateHostingWebAttacheddomain(OvhApi.Models.Hosting.Web.AttachedDomain requestBody,string serviceName,string domain) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("domain",domain); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Put,String.Format("/hosting/web/{0}/attachedDomain/{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(domain.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Create new ftp/ssh user /// <param name="password">Password</param> /// <param name="iisRemoteRights">User IIS rights</param> /// <param name="home">Home directory</param> /// <param name="webDavRights">User WebDav rights</param> /// <param name="login">Login use for your new user</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> CreateHostingWebUser(string password,string home,string login,string serviceName,OvhApi.Models.Hosting.Web.User.WebDavRightsEnum? webDavRights = null,OvhApi.Models.Hosting.Web.User.IisRightsEnum? iisRemoteRights = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("password",password); Ensure.NotNullNorEmpty("home",home); Ensure.NotNullNorEmpty("login",login); Ensure.NotNullNorEmpty("serviceName",serviceName); var requestBody = new Dictionary<string, object>(); requestBody.Add("password",password); requestBody.Add("iisRemoteRights",iisRemoteRights); requestBody.Add("home",home); requestBody.Add("webDavRights",webDavRights); requestBody.Add("login",login); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Post,String.Format("/hosting/web/{0}/user",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Get offer capabilities /// <param name="offer">Describe offer capabilities</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Capabilities> GetHostingWebOffercapabilities(OvhApi.Models.Hosting.Web.OfferCapabilitiesEnum offer) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("offer",offer); var queryString = new QueryString(); queryString.Add("offer",offer); return await RawCall<OvhApi.Models.Hosting.Web.Capabilities>(HttpMethod.Get,String.Format("/hosting/web/offerCapabilities{0}",queryString)); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="serviceName">The internal name of your hosting</param> /// <param name="login">Login used to connect on FTP</param> /// </summary> public async Task UpdateHostingWebUser(OvhApi.Models.Hosting.Web.User requestBody,string serviceName,string login) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("login",login); await RawCall(HttpMethod.Put,String.Format("/hosting/web/{0}/user/{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(login.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="serviceName">The internal name of your CDN offer</param> /// <param name="domain">Domain of this object</param> /// </summary> public async Task UpdateCdnDedicatedDomains(OvhApi.Models.Cdnanycast.Domain requestBody,string serviceName,string domain) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNullNorEmpty("serviceName",serviceName); Ensure.NotNullNorEmpty("domain",domain); await RawCall(HttpMethod.Put,String.Format("/cdn/dedicated/{0}/domains/{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(domain.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Restore this snapshot ALL CURRENT DATA WILL BE REPLACED BY YOUR SNAPSHOT /// <param name="backup">The backup you want to restore</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> CreateHostingWebRestoresnapshot(OvhApi.Models.Hosting.Web.Backup.TypeEnum backup,string serviceName) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("backup",backup); Ensure.NotNullNorEmpty("serviceName",serviceName); var requestBody = new Dictionary<string, object>(); requestBody.Add("backup",backup); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Post,String.Format("/hosting/web/{0}/restoreSnapshot",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// IP tasks /// <param name="function">Filter the value of function property (=)</param> /// <param name="status">Filter the value of status property (=)</param> /// <param name="ip">To be written</param> /// </summary> public async Task<long[]> GetIpTaskIds(OVHApi.IPAddressBlock ip,OvhApi.Models.Ip.TaskStatusEnum? status = null,OvhApi.Models.Ip.TaskFunctionEnum? function = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("ip",ip); var queryString = new QueryString(); queryString.Add("function",function); queryString.Add("status",status); return await RawCall<long[]>(HttpMethod.Get,String.Format("/ip/{0}/task{1}",System.Uri.EscapeDataString(ip.ToString()).Replace("%2B", "+"),queryString)); }
/// <summary> /// Install a new module /// <param name="domain">On which domain the module has to be available (it can be a multidomain or a subdomain) - if not set, the module will be available on your serviceName domain</param> /// <param name="language">The language to set to your module</param> /// <param name="adminName">The login for the admin account (may be a standard string or your email)</param> /// <param name="adminPassword">The password for the admin account (at least 8 characters)</param> /// <param name="dependencies">The dependencies that we have to configure on your module. A dependency can be a standard database (like MySQL or PostgreSQL) or a key-value store (like Redis or Memcached) for example</param> /// <param name="path">Where to install the module, relative to your home directory</param> /// <param name="moduleId">ID of the module you want to install</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<OvhApi.Models.Hosting.Web.Task> CreateHostingWebModule(string domain,OvhApi.Models.Hosting.Web.Module.LanguageEnum language,string adminName,string adminPassword,OvhApi.Models.Hosting.Web.Module.DependencyType[] dependencies,string path,long moduleId,string serviceName) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("domain",domain); Ensure.NotNull("language",language); Ensure.NotNullNorEmpty("adminName",adminName); Ensure.NotNullNorEmpty("adminPassword",adminPassword); Ensure.NotNull("dependencies",dependencies); Ensure.NotNullNorEmpty("path",path); Ensure.IdIsValid("moduleId",moduleId); Ensure.NotNullNorEmpty("serviceName",serviceName); var requestBody = new Dictionary<string, object>(); requestBody.Add("domain",domain); requestBody.Add("language",language); requestBody.Add("adminName",adminName); requestBody.Add("adminPassword",adminPassword); requestBody.Add("dependencies",dependencies); requestBody.Add("path",path); requestBody.Add("moduleId",moduleId); return await RawCall<OvhApi.Models.Hosting.Web.Task>(HttpMethod.Post,String.Format("/hosting/web/{0}/module",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Alter this object properties /// <param name="requestBody">New object properties</param> /// <param name="ip">To be written</param> /// <param name="ipOnMitigation">To be written</param> /// </summary> public async Task UpdateIpMitigation(OvhApi.Models.Ip.MitigationIp requestBody,OVHApi.IPAddressBlock ip,System.Net.IPAddress ipOnMitigation) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNull("requestBody",requestBody); Ensure.NotNull("ip",ip); Ensure.NotNull("ipOnMitigation",ipOnMitigation); await RawCall(HttpMethod.Put,String.Format("/ip/{0}/mitigation/{1}",System.Uri.EscapeDataString(ip.ToString()).Replace("%2B", "+"),System.Uri.EscapeDataString(ipOnMitigation.ToString()).Replace("%2B", "+")),requestBody); }
/// <summary> /// Tasks attached to your hosting /// <param name="function">Filter the value of function property (like)</param> /// <param name="status">Filter the value of status property (=)</param> /// <param name="serviceName">The internal name of your hosting</param> /// </summary> public async Task<long[]> GetHostingWebTaskIds(string serviceName,OvhApi.Models.Hosting.Web.Task.StatusEnum? status = null,string function = null) { if(ConsumerKey == null) throw new OvhException("This request must be authenticated"); Ensure.NotNullNorEmpty("serviceName",serviceName); var queryString = new QueryString(); queryString.Add("function",function); queryString.Add("status",status); return await RawCall<long[]>(HttpMethod.Get,String.Format("/hosting/web/{0}/tasks{1}",System.Uri.EscapeDataString(serviceName.ToString()).Replace("%2B", "+"),queryString)); }