/// <inheritdoc/>
        public UserAccess CreateUserAccess(string username, string password, string tenantName = null, string tenantId = null)
        {
            CloudIdentity identity = null;
            if (tenantId == null)
            {
                identity = new CloudIdentity()
                {
                    Username = username,
                    Password = password
                };

            }
            else
            {
                identity = new CloudIdentityWithProject()
                {
                    ProjectId = (new ProjectId(tenantId ?? tenantName)),
                    ProjectName = tenantName,
                    Username = username,
                    Password = password
                };

            }

            CloudIdentityProvider identityProvider = new CloudIdentityProvider(identity, DefaultPublicEndPointUri);
            UserAccess ua = identityProvider.GetUserAccess(identity);
            this.UA = ua;
            return ua;
        }
Example #2
0
        private void UploadObject(CloudIdentity cloudIdentity, string container, string objectname, string filename)
        {
            var provider = new CloudFilesProvider(cloudIdentity);

            provider.CreateObjectFromFile(container: container, filePath: filename, objectName: objectname, progressUpdated: ProgressCallback);
        }
Example #3
0
 /// <summary>
 /// Gets the public service endpoint to use for Cloud Servers requests for the specified identity and region.
 /// </summary>
 /// <remarks>
 /// This method uses <c>compute</c> for the service type, and <c>cloudServersOpenStack</c> for the preferred service name.
 /// </remarks>
 /// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
 /// <param name="region">The preferred region for the service. If this value is <see langword="null"/>, the user's default region will be used.</param>
 /// <returns>The public URL for the requested Cloud Servers endpoint.</returns>
 /// <exception cref="NotSupportedException">
 /// If the provider does not support the given <paramref name="identity"/> type.
 /// <para>-or-</para>
 /// <para>The specified <paramref name="region"/> is not supported.</para>
 /// </exception>
 /// <exception cref="InvalidOperationException">
 /// If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.
 /// </exception>
 /// <exception cref="net.openstack.Core.Exceptions.NoDefaultRegionSetException">If <paramref name="region"/> is <see langword="null"/> and no default region is available for the identity or provider.</exception>
 /// <exception cref="net.openstack.Core.Exceptions.UserAuthenticationException">If no service catalog is available for the user.</exception>
 /// <exception cref="net.openstack.Core.Exceptions.UserAuthorizationException">If no endpoint is available for the requested service.</exception>
 /// <exception cref="net.openstack.Core.Exceptions.Response.ResponseException">If the REST API request failed.</exception>
 protected string GetServiceEndpoint(CloudIdentity identity, string region = "tyo1")
 {
     // return base.GetPublicServiceEndpoint(identity, "compute", "cloudServersOpenStack", region);
     return(base.GetPublicServiceEndpoint(identity, "account", "Account Service", region ?? "tyo1"));
 }
Example #4
0
        /// <inheritdoc />
        public Notification GetNotification(int notificationCode, string lang = "en", CloudIdentity identity = null)
        {
            CheckIdentity(identity);
            var urlPath = new Uri(string.Format("{0}/notifications/{1}", GetServiceEndpoint(identity), notificationCode.ToString()));

            var response = ExecuteRESTRequest <GetNotificationResponse>(identity, urlPath, HttpMethod.GET);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data.Notification);
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudServersProvider"/> class with
 /// the specified default identity, default region, identity provider, and REST
 /// service implementation.
 /// </summary>
 /// <param name="identity">An instance of a <see cref="CloudIdentity"/> object. <remarks>If not provided, the user will be required to pass a <see cref="net.openstack.Core.Domain.CloudIdentity"/> object to each method individually.</remarks></param>
 /// <param name="defaultRegion">The default region to use for calls that do not explicitly specify a region. If this value is <see langword="null"/>, the default region for the user will be used; otherwise if the service uses region-specific endpoints all calls must specify an explicit region.</param>
 /// <param name="identityProvider">An instance of an <see cref="IIdentityProvider"/> to override the default <see cref="CloudIdentity"/></param>
 /// <param name="restService">An instance of an <see cref="IRestService"/> to override the default <see cref="JsonRestServices"/></param>
 public CloudAccountServiceProvider(CloudIdentity identity, string defaultRegion, IIdentityProvider identityProvider, IRestService restService)
     : base(identity, defaultRegion, identityProvider, restService)
 {
 }
Example #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudServersProvider"/> class with
 /// the specified default identity and identity provider, no default region, and
 /// the default REST service implementation.
 /// </summary>
 /// <param name="identity">The default identity to use for calls that do not explicitly specify an identity. If this value is <see langword="null"/>, no default identity is available so all calls must specify an explicit identity.</param>
 /// <param name="identityProvider">The identity provider to use for authenticating requests to this provider. If this value is <see langword="null"/>, a new instance of <see cref="CloudIdentityProvider"/> is created using <paramref name="identity"/> as the default identity.</param>
 public CloudAccountServiceProvider(CloudIdentity identity, IIdentityProvider identityProvider)
     : this(identity, null, identityProvider, null)
 {
 }
Example #7
0
        /// <inheritdoc/>
        public bool SetGslbSuspend(string domainId, bool enabled, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/gslb_suspend/{1}", GetServiceEndpoint(identity, region), domainId));

            var request = new Dictionary <string, string> {
                { "gslb_suspend", (enabled ? "enable" : "disable") }
            };
            var response = ExecuteRESTRequest <object>(identity, urlPath, HttpMethod.PUT, request);

            if (response == null || response.StatusCode != HttpStatusCode.Accepted)
            {
                return(false);
            }

            return(true);
        }
Example #8
0
        /// <inheritdoc/>
        public DnsRecord GetDnsRecord(string domainId, string recordId, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            if (recordId == null)
            {
                throw new ArgumentNullException("recordId");
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentException("recordId cannot be empty");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}/records/{2}", GetServiceEndpoint(identity, region), domainId, recordId));

            var response = ExecuteRESTRequest <DnsRecord>(identity, urlPath, HttpMethod.GET);

            if (response == null || response.Data == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data);
        }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudDnsProvider"/> class with
 /// the specified default identity and identity provider, no default region, and
 /// the default REST service implementation.
 /// </summary>
 /// <param name="identity">The default identity to use for calls that do not explicitly specify an identity. If this value is <see langword="null"/>, no default identity is available so all calls must specify an explicit identity.</param>
 /// <param name="identityProvider">The identity provider to use for authenticating requests to this provider. If this value is <see langword="null"/>, a new instance of <see cref="CloudIdentityProvider"/> is created using <paramref name="identity"/> as the default identity.</param>
 public CloudDnsProvider(CloudIdentity identity, IIdentityProvider identityProvider)
     : this(identity, null, identityProvider, null)
 {
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudDnsProvider"/> class with
 /// the specified default identity, no default region, and the default identity
 /// provider and REST service implementation.
 /// </summary>
 /// <param name="identity">The default identity to use for calls that do not explicitly specify an identity. If this value is <see langword="null"/>, no default identity is available so all calls must specify an explicit identity.</param>
 public CloudDnsProvider(CloudIdentity identity)
     : this(identity, null, null, null)
 {
 }
Example #11
0
 public ExtendedOpenStackIdentityProvider(Uri urlBase, CloudIdentity identity, JSIStudios.SimpleRESTServices.Client.IRestService restService, net.openstack.Core.Caching.ICache <UserAccess> tokenCache)
     : base(urlBase, identity, restService, tokenCache)
 {
 }
Example #12
0
 public ExtendedOpenStackIdentityProvider(Uri urlBase, CloudIdentity identity)
     : base(urlBase, identity)
 {
 }
        public User GetUserByName(string name, CloudIdentity identity)
        {
            var provider = GetProvider(identity);

            return(provider.GetUserByName(name, identity: identity));
        }
        public IEnumerable <User> ListUsers(CloudIdentity identity)
        {
            var provider = GetProvider(identity);

            return(provider.ListUsers(identity));
        }
Example #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuthRequest"/> class with the
        /// given identity.
        /// </summary>
        /// <param name="identity">The identity of the user to authenticate.</param>
        /// <exception cref="ArgumentNullException">If <paramref name="identity"/> is <see langword="null"/>.</exception>
        /// <exception cref="NotSupportedException">If given <paramref name="identity"/> type is not supported.</exception>
        public AuthRequest(CloudIdentity identity)
        {
            if (identity == null)
                throw new ArgumentNullException("identity");

            var credentials = new AuthDetails();

            credentials.PasswordCredentials = new Credentials(identity.Username, identity.Password, null);

            CloudIdentityWithProject p = identity as CloudIdentityWithProject;
            if (p is CloudIdentityWithProject)
            {
                if (p != null && !string.IsNullOrEmpty(p.ProjectName))
                    credentials.TenantName = p.ProjectName;

                if (p != null && p.ProjectId != null)
                    credentials.TenantId = p.ProjectId.Value;
            }

            Credentials = credentials;
        }
        public IEnumerable <Role> GetRolesByUser(string userId, CloudIdentity identity)
        {
            var provider = GetProvider(identity);

            return(provider.GetRolesByUser(userId, identity: identity));
        }
Example #17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudDnsProvider"/> class with
 /// the specified default identity and REST service implementation, no default region,
 /// and the default identity provider.
 /// </summary>
 /// <param name="identity">The default identity to use for calls that do not explicitly specify an identity. If this value is <see langword="null"/>, no default identity is available so all calls must specify an explicit identity.</param>
 /// <param name="restService">The implementation of <see cref="IRestService"/> to use for executing REST requests. If this value is <see langword="null"/>, the provider will use a new instance of <see cref="JsonRestServices"/>.</param>
 public CloudDnsProvider(CloudIdentity identity, IRestService restService)
     : this(identity, null, null, restService)
 {
 }
Example #18
0
        /// <inheritdoc/>
        public DnsRecord UpdateDnsRecord(string domainId, string recordId, string name = null, string type = null, string data = null, int?priority = null, int?ttl = null, string description = null, string gslbRegion = null, int?gslbWeight = null, int?gslbCheck = null, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            if (recordId == null)
            {
                throw new ArgumentNullException("recordId");
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentException("recordId cannot be empty");
            }
            if (ttl.HasValue && ttl < 3600)
            {
                throw new ArgumentException("ttl must be 3600 and more");
            }
            if (priority.HasValue && (priority < 0 || priority > 65535))
            {
                throw new ArgumentOutOfRangeException("priority must be 0~65535");
            }
            if (gslbWeight.HasValue && (gslbWeight < 0 || gslbWeight > 255))
            {
                throw new ArgumentOutOfRangeException("gslbWeight must be 0~255");
            }
            if (gslbCheck.HasValue && (gslbCheck < 0 || gslbCheck > 65535))
            {
                throw new ArgumentOutOfRangeException("gslbCheck must be 0~65535");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}/records/{2}", GetServiceEndpoint(identity, region), domainId, recordId));

            var request = new CreateDnsRecordRequest(name, type, priority, ttl, data, description, gslbRegion, gslbWeight, gslbCheck);

            var response = ExecuteRESTRequest <DnsRecord>(identity, urlPath, HttpMethod.PUT, request);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(response.Data);
        }
Example #19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudDnsProvider"/> class with
 /// the specified default identity, default region, identity provider, and REST
 /// service implementation.
 /// </summary>
 /// <param name="identity">An instance of a <see cref="CloudIdentity"/> object. <remarks>If not provided, the user will be required to pass a <see cref="net.openstack.Core.Domain.CloudIdentity"/> object to each method individually.</remarks></param>
 /// <param name="defaultRegion">The default region to use for calls that do not explicitly specify a region. If this value is <see langword="null"/>, the default region for the user will be used; otherwise if the service uses region-specific endpoints all calls must specify an explicit region.</param>
 /// <param name="identityProvider">An instance of an <see cref="IIdentityProvider"/> to override the default <see cref="CloudIdentity"/></param>
 /// <param name="restService">An instance of an <see cref="IRestService"/> to override the default <see cref="JsonRestServices"/></param>
 public CloudDnsProvider(CloudIdentity identity, string defaultRegion, IIdentityProvider identityProvider, IRestService restService)
     : this(identity, defaultRegion, identityProvider, restService, false)
 {
 }
Example #20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudServersProvider"/> class with
 /// the specified default identity, no default region, and the default identity
 /// provider and REST service implementation.
 /// </summary>
 /// <param name="identity">The default identity to use for calls that do not explicitly specify an identity. If this value is <see langword="null"/>, no default identity is available so all calls must specify an explicit identity.</param>
 public CloudAccountServiceProvider(CloudIdentity identity)
     : this(identity, null, null, null)
 {
 }
Example #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="identity"></param>
 /// <param name="defaultRegion"></param>
 /// <param name="identityProvider"></param>
 /// <param name="restService"></param>
 /// <param name="isAdminMode"></param>
 public CloudDnsProvider(CloudIdentity identity, string defaultRegion, IIdentityProvider identityProvider, IRestService restService, bool isAdminMode)
     : base(identity, defaultRegion, identityProvider, restService, null, isAdminMode)
 {
 }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CloudServersProvider"/> class with
 /// the specified default identity, no default region, and the specified identity
 /// provider and REST service implementation.
 /// </summary>
 /// <param name="identity">An instance of a <see cref="CloudIdentity"/> object. <remarks>If not provided, the user will be required to pass a <see cref="net.openstack.Core.Domain.CloudIdentity"/> object to each method individually.</remarks></param>
 /// <param name="identityProvider">An instance of an <see cref="IIdentityProvider"/> to override the default <see cref="CloudIdentity"/></param>
 /// <param name="restService">An instance of an <see cref="IRestService"/> to override the default <see cref="JsonRestServices"/></param>
 public CloudAccountServiceProvider(CloudIdentity identity, IIdentityProvider identityProvider, IRestService restService)
     : this(identity, null, identityProvider, restService)
 {
 }
Example #23
0
 /// <summary>
 /// Gets the public service endpoint to use for Cloud Networks requests for the specified identity and region.
 /// </summary>
 /// <remarks>
 /// This method uses <c>compute</c> for the service type, and <c>cloudServersOpenStack</c> for the preferred service name.
 /// </remarks>
 /// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
 /// <param name="region">The preferred region for the service. If this value is <see langword="null"/>, the user's default region will be used.</param>
 /// <returns>The public URL for the requested Cloud Networks endpoint.</returns>
 /// <exception cref="NotSupportedException">
 /// If the provider does not support the given <paramref name="identity"/> type.
 /// <para>-or-</para>
 /// <para>The specified <paramref name="region"/> is not supported.</para>
 /// </exception>
 /// <exception cref="InvalidOperationException">
 /// If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.
 /// </exception>
 /// <exception cref="net.openstack.Core.Exceptions.NoDefaultRegionSetException">If <paramref name="region"/> is <see langword="null"/> and no default region is available for the identity or provider.</exception>
 /// <exception cref="net.openstack.Core.Exceptions.UserAuthenticationException">If no service catalog is available for the user.</exception>
 /// <exception cref="net.openstack.Core.Exceptions.UserAuthorizationException">If no endpoint is available for the requested service.</exception>
 /// <exception cref="net.openstack.Core.Exceptions.Response.ResponseException">If the REST API request failed.</exception>
 protected string GetServiceEndpoint(CloudIdentity identity, string region)
 {
     return(base.GetPublicServiceEndpoint(identity, "dns", "Dns Service", region ?? base.DefaultRegion ?? "tyo1"));
 }
Example #24
0
        /// <inheritdoc />
        public IEnumerable <Notification> ListNotifications(string lang = "en", int offset = 0, int limit = 1000, CloudIdentity identity = null)
        {
            if (limit < 0)
            {
                throw new ArgumentOutOfRangeException("limit");
            }
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset");
            }

            CheckIdentity(identity);
            var urlPath    = new Uri(string.Format("{0}/notifications", GetServiceEndpoint(identity)));
            var parameters = BuildOptionalParameterList(new Dictionary <string, string>
            {
                { "lang", lang },
                { "offset", offset.ToString() },
                { "limit", limit.ToString() }
            });

            var response = ExecuteRESTRequest <ListNotificationsResponse>(identity, urlPath, HttpMethod.GET, queryStringParameter: parameters);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data.Notifications);
        }
Example #25
0
        /// <inheritdoc/>
        public IEnumerable <DnsServer> GetDnsServiceDetails(string domainId, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}/servers", GetServiceEndpoint(identity, region), domainId));

            var defaultSettings = BuildDefaultRequestSettings(new[] { HttpStatusCode.NotFound });
            var response        = ExecuteRESTRequest <GetDnsServiceDetailsResponse>(identity, urlPath, HttpMethod.GET, settings: defaultSettings);

            if (response == null || response.Data == null || response.Data.DnsServers == null)
            {
                return(null);
            }

            return(response.Data.DnsServers);
        }
Example #26
0
        /// <summary>
        /// Execute a Cloud Servers action which does not return a response.
        /// </summary>
        /// <remarks>
        /// This method executes actions using a <see cref="HttpMethod.POST"/> request to the URI
        /// <strong>servers/{serverId}/action</strong>.
        /// </remarks>
        /// <param name="serverId">The server ID. This is obtained from <see cref="ServerBase.Id"/>.</param>
        /// <param name="body">The body of the action.</param>
        /// <param name="region">The region in which to execute this action. If not specified, the user's default region will be used.</param>
        /// <param name="identity">The cloud identity to use for this request. If not specified, the default identity for the current provider instance will be used.</param>
        /// <returns><see langword="true"/> if the <see cref="HttpMethod.POST"/> request is executed successfully; otherwise, <see langword="false"/>.</returns>
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="serverId"/> is <see langword="null"/>.
        /// <para>-or-</para>
        /// <para>If <paramref name="body"/> is <see langword="null"/>.</para>
        /// </exception>
        /// <exception cref="ArgumentException">If <paramref name="serverId"/> is empty.</exception>
        /// <exception cref="NotSupportedException">
        /// If the provider does not support the given <paramref name="identity"/> type.
        /// <para>-or-</para>
        /// <para>The specified <paramref name="region"/> is not supported.</para>
        /// </exception>
        /// <exception cref="InvalidOperationException">
        /// If <paramref name="identity"/> is <see langword="null"/> and no default identity is available for the provider.
        /// <para>-or-</para>
        /// <para>If <paramref name="region"/> is <see langword="null"/> and no default region is available for the provider.</para>
        /// </exception>
        /// <exception cref="net.openstack.Core.Exceptions.Response.ResponseException">If the REST API request failed.</exception>
        protected bool ExecuteServerAction(string serverId, object body, string region = null, CloudIdentity identity = null)
        {
            if (serverId == null)
            {
                throw new ArgumentNullException("serverId");
            }
            if (body == null)
            {
                throw new ArgumentNullException("body");
            }
            if (string.IsNullOrEmpty(serverId))
            {
                throw new ArgumentException("serverId cannot be empty");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/servers/{1}/action", GetServiceEndpoint(identity, region), serverId));

            var response = ExecuteRESTRequest(identity, urlPath, HttpMethod.POST, body);

            if (response == null || !_validServerActionResponseCode.Contains(response.StatusCode))
            {
                return(false);
            }

            return(true);
        }
Example #27
0
        /// <inheritdoc/>
        public Domain CreateDomain(string domainName, string email, int?ttl = 3600, string description = null, int?gslb = 0, string region = null, CloudIdentity identity = null)
        {
            if (domainName == null)
            {
                throw new ArgumentNullException("domainName");
            }
            if (string.IsNullOrEmpty(domainName))
            {
                throw new ArgumentException("domainName cannot be empty");
            }
            if (!domainName.EndsWith("."))
            {
                throw new ArgumentException("domainName must ends with period(.)");
            }
            if (email == null)
            {
                throw new ArgumentNullException("email");
            }
            if (string.IsNullOrEmpty(email))
            {
                throw new ArgumentException("email cannot be empty");
            }
            if (ttl.HasValue && ttl < 3600)
            {
                throw new ArgumentOutOfRangeException("ttl must be 3600 and more");
            }
            if (gslb.HasValue && (gslb != 0 && gslb != 1))
            {
                throw new ArgumentException("gslb must be 0 or 1");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains", GetServiceEndpoint(identity, region)));

            var parameters = new Dictionary <string, object>()
            {
                { "name", domainName },
                { "ttl", ttl },
                { "email", email },
                { "description", string.IsNullOrEmpty(description) ? null : description },
            };

            if (gslb != null)
            {
                parameters.Add("gslb", gslb);
            }

            var response = ExecuteRESTRequest <Domain>(identity, urlPath, HttpMethod.POST, parameters);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            if (response.StatusCode != HttpStatusCode.OK)
            {
                return(null);
            }

            return(response.Data);
        }
 public static void Init(TestContext context)
 {
     _testIdentity = new RackspaceCloudIdentity(Bootstrapper.Settings.TestIdentity);
 }
Example #29
0
        /// <inheritdoc/>
        public Domain UpdateDomain(string domainId, string domainName = null, string email = null, int?ttl = null, string description = null, int?gslb = null, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            if (!string.IsNullOrEmpty(domainName) && !domainName.EndsWith("."))
            {
                throw new ArgumentException("domainName must ends with period(.)");
            }
            if (ttl.HasValue && ttl < 3600)
            {
                throw new ArgumentOutOfRangeException("ttl must be 3600 and more");
            }
            if (gslb.HasValue && (gslb != 0 && gslb != 1))
            {
                throw new ArgumentException("gslb must be 0 or 1");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}", GetServiceEndpoint(identity, region), domainId));

            var request = new UpdateDomainRequest(domainName, email, ttl, description, gslb);

            var response = ExecuteRESTRequest <Domain>(identity, urlPath, HttpMethod.PUT, request);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data);
        }
Example #30
0
        private void DeleteObject(CloudIdentity cloudIdentity, string container, string objectname)
        {
            var provider = new CloudFilesProvider(cloudIdentity);

            provider.DeleteObject(container: container, objectName: objectname, region: fRegion);
        }
Example #31
0
        /// <inheritdoc/>
        public IEnumerable <Domain> SearchDomain(string domainName, string region = null, CloudIdentity identity = null)
        {
            if (!string.IsNullOrEmpty(domainName) && !domainName.EndsWith("."))
            {
                throw new ArgumentException("domainName must ends with period(.)");
            }

            CheckIdentity(identity);

            var urlPath     = new Uri(string.Format("{0}/v1/staff/domains", GetServiceEndpoint(identity, region)));
            var queryParams = new Dictionary <string, string>()
            {
                { "name", domainName },
            };
            var response = ExecuteRESTRequest <ListDomiansResponse>(identity, urlPath, HttpMethod.GET, null, queryParams);

            if (response == null || response.Data == null)
            {
                return(null);
            }

            return(response.Data.Domains);
        }
Example #32
0
        /// <inheritdoc/>
        public bool DeleteDnsRecord(string domainId, string recordId, string region = null, CloudIdentity identity = null)
        {
            if (domainId == null)
            {
                throw new ArgumentNullException("domainId");
            }
            if (string.IsNullOrEmpty(domainId))
            {
                throw new ArgumentException("domainId cannot be empty");
            }
            if (recordId == null)
            {
                throw new ArgumentNullException("recordId");
            }
            if (string.IsNullOrEmpty(recordId))
            {
                throw new ArgumentException("recordId cannot be empty");
            }
            CheckIdentity(identity);

            var urlPath = new Uri(string.Format("{0}/v1/domains/{1}/records/{2}", GetServiceEndpoint(identity, region), domainId, recordId));

            var defaultSettings = BuildDefaultRequestSettings(new[] { HttpStatusCode.NotFound });
            var response        = ExecuteRESTRequest <object>(identity, urlPath, HttpMethod.DELETE, settings: defaultSettings);

            if (response == null || response.StatusCode != HttpStatusCode.OK)
            {
                return(false);
            }

            return(true);
        }
        public OpenStackMember(string username, string password, string tenantName = null, string tenantId = null, string defaultregion = "tyo1", bool bLazyProviderSetting = false)
        {
            if (username == null)
                throw new ArgumentNullException("username");
            if (string.IsNullOrEmpty(username))
                throw new ArgumentException("username cannot be empty");
            if (password == null)
                throw new ArgumentNullException("password");
            if (string.IsNullOrEmpty(password))
                throw new ArgumentException("password cannot be empty");

            this.UserName = username;
            this.TenantId = tenantId;
            this.TenantName = tenantName;

            CloudIdentity identity = null;
            if (tenantName != null || tenantId != null)
            {
                identity = new CloudIdentityWithProject()
                {
                    ProjectId = (new ProjectId(tenantId ?? tenantName)),
                    ProjectName = tenantName,
                    Username = username,
                    Password = password
                };
            }
            else
            {
                identity = new CloudIdentity()
                {
                    Username = username,
                    Password = password
                };
            }

            this.Identity = identity;
            this.DefaultRegion = defaultregion;
            if (!bLazyProviderSetting)
                SetProviders();
        }