/// <summary>
        /// Returns the entire list response from the CloudStack API, detecting paging in use and issuing multiple
        /// requests where necessary
        /// </summary>
        /// <typeparam name="TResponse">Type of item response expected</typeparam>
        /// <param name="proxy">Proxy to operate on</param>
        /// <param name="request">Request Details</param>
        public static ListResponse <TResponse> RequestAllPages <TResponse>(this ICloudStackAPIProxy proxy, APIListRequest request) where TResponse : new()
        {
            int page = 1;
            ListResponse <TResponse> response = proxy.Request <ListResponse <TResponse> >(request);

            while (response.Results.Count < response.Count)
            {
                page++;

                request.Page = page;
                if (!request.PageSize.HasValue)
                {
                    request.PageSize = response.Results.Count;
                }

                ListResponse <TResponse> pageResponse = proxy.Request <ListResponse <TResponse> >(request);
                foreach (TResponse item in pageResponse.Results)
                {
                    response.Results.Add(item);
                }
                response.Count = pageResponse.Count;        // In case it changed while we pulled results
            }

            return(response);
        }
Example #2
0
        /// <summary>
        /// Copies test values from the application's properties.
        /// </summary>
        private void Setup()
        {
            _apiKey     = Properties.Settings.Default.User;
            _secretKey  = Properties.Settings.Default.Password;
            _serviceUri = new Uri(Properties.Settings.Default.URL);

            _proxy  = new CloudStackAPIProxy(_serviceUri.ToString(), _apiKey, _secretKey);
            _client = new CloudStackAPIClient(_proxy);

            _templateId        = Properties.Settings.Default.TemplateId;
            _networkId         = Properties.Settings.Default.SubnetId;
            _serviceOfferingId = Properties.Settings.Default.ServiceOfferingId;

            this._deployStopped = Properties.Settings.Default.DeployStopped;
            _zoneId             = Properties.Settings.Default.ZoneId;
        }
Example #3
0
        /// <summary>
        /// Copies test values from the application's properties.
        /// </summary>
        private void Setup()
        {
            _apiKey = Properties.Settings.Default.User;
            _secretKey = Properties.Settings.Default.Password;
            _serviceUri = new Uri(Properties.Settings.Default.URL);

            _proxy = new CloudStackAPIProxy(_serviceUri.ToString(), _apiKey, _secretKey);
            _client = new CloudStackAPIClient(_proxy);

            _templateId = Properties.Settings.Default.TemplateId;
            _networkId = Properties.Settings.Default.SubnetId;
            _serviceOfferingId = Properties.Settings.Default.ServiceOfferingId;

            this._deployStopped = Properties.Settings.Default.DeployStopped;
            _zoneId = Properties.Settings.Default.ZoneId;
        }
Example #4
0
 public void _Setup()
 {
     _sut = new CloudStackAPIProxy("http://localhost:8080/client/api", "foo", "foo");
 }
        /// <summary>
        /// Returns the entire list response from the CloudStack API, detecting paging in use and issuing multiple
        /// requests where necessary
        /// </summary>
        /// <typeparam name="TResponse">Type of item response expected</typeparam>
        /// <param name="proxy">Proxy to operate on</param>
        /// <param name="request">Request Details</param>
        public static async Task <ListResponse <TResponse> > RequestAllPagesAsync <TResponse>(this ICloudStackAPIProxy proxy, APIListRequest request) where TResponse : new()
        {
            int page = 0;
            ListResponse <TResponse> response = await proxy.RequestAsync <ListResponse <TResponse> >(request);

            while (response.Results.Count < response.Count)
            {
                page++;

                request.Page = page;
                ListResponse <TResponse> pageReponse = await proxy.RequestAsync <ListResponse <TResponse> >(request);

                foreach (TResponse item in pageReponse.Results)
                {
                    response.Results.Add(item);
                }
            }

            return(response);
        }
Example #6
0
 public CloudStackAPIClient(ICloudStackAPIProxy proxy)
 {
     Proxy = proxy;
 }
 public CloudStackAPIClient(ICloudStackAPIProxy proxy)
 {
     _proxy = proxy;
 }
 public void _Setup()
 {
     _sut = new CloudStackAPIProxy("http://localhost:8080/client/api", "foo", "foo");
 }