Container for the parameters to the DescribeAvailabilityZones operation. Describes one or more of the Availability Zones that are available to you. The results include zones only for the region you're currently using. If there is an event impacting an Availability Zone, you can use this request to view the state and any provided message for that Availability Zone.

For more information, see Regions and Availability Zones in the Amazon Elastic Compute Cloud User Guide.

Inheritance: AmazonEC2Request
        /// <summary>
        /// The DescribeAvailabilityZones operation describes availability zones that are
        /// currently available to the account and their states.
        /// Availability zones are not the same across accounts. The availability zone
        /// us-east-1a for account A is not necessarily the same as us-east-1a for account
        /// B. Zone assignments are mapped independently for each account.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonEC2 service</param>
        /// <param name="request">DescribeAvailabilityZonesRequest request</param>
        public static void InvokeDescribeAvailabilityZones(AmazonEC2 service, DescribeAvailabilityZonesRequest request)
        {
            try 
            {
                DescribeAvailabilityZonesResponse response = service.DescribeAvailabilityZones(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        DescribeAvailabilityZonesResponse");
                if (response.IsSetResponseMetadata())
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId())
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                }
                if (response.IsSetDescribeAvailabilityZonesResult())
                {
                    Console.WriteLine("            DescribeAvailabilityZonesResult");
                    DescribeAvailabilityZonesResult  describeAvailabilityZonesResult = response.DescribeAvailabilityZonesResult;
                    List<AvailabilityZone> availabilityZoneList = describeAvailabilityZonesResult.AvailabilityZone;
                    foreach (AvailabilityZone availabilityZone in availabilityZoneList)
                    {
                        Console.WriteLine("                AvailabilityZone");
                        if (availabilityZone.IsSetZoneName())
                        {
                            Console.WriteLine("                    ZoneName");
                            Console.WriteLine("                        {0}", availabilityZone.ZoneName);
                        }
                        if (availabilityZone.IsSetZoneState())
                        {
                            Console.WriteLine("                    ZoneState");
                            Console.WriteLine("                        {0}", availabilityZone.ZoneState);
                        }
                        if (availabilityZone.IsSetRegionName())
                        {
                            Console.WriteLine("                    RegionName");
                            Console.WriteLine("                        {0}", availabilityZone.RegionName);
                        }
                    }
                }

            } 
            catch (AmazonEC2Exception ex) 
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
                Console.WriteLine("XML: " + ex.XML);
            }
        }
 protected override void ProcessRecord()
 {
     AmazonEC2 client = base.GetClient();
     Amazon.EC2.Model.DescribeAvailabilityZonesRequest request = new Amazon.EC2.Model.DescribeAvailabilityZonesRequest();
     if (string.IsNullOrEmpty(this._ZoneName))
     {
         request.ZoneName.Add(this._ZoneName);
     }
     Amazon.EC2.Model.DescribeAvailabilityZonesResponse response = client.DescribeAvailabilityZones(request);
     base.WriteObject(response.DescribeAvailabilityZonesResult.AvailabilityZone, true);
 }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.EC2.Model.DescribeAvailabilityZonesRequest();

            if (cmdletContext.AllAvailabilityZone != null)
            {
                request.AllAvailabilityZones = cmdletContext.AllAvailabilityZone.Value;
            }
            if (cmdletContext.Filter != null)
            {
                request.Filters = cmdletContext.Filter;
            }
            if (cmdletContext.ZoneId != null)
            {
                request.ZoneIds = cmdletContext.ZoneId;
            }
            if (cmdletContext.ZoneName != null)
            {
                request.ZoneNames = cmdletContext.ZoneName;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
Esempio n. 4
0
        public AWSAvailabilityZone[] GetAvailabilityZones(IAmazonEC2 ec2Client = null)
        {
            var ret = new List<AWSAvailabilityZone>();

            var ec2 = ec2Client ?? GetEC2Client(); // might be passed in by instances calls...
            var request = new DescribeAvailabilityZonesRequest();
            var response = ec2.DescribeAvailabilityZones(request);

            foreach (var zone in response.AvailabilityZones)
            {
                var awsZone = new AWSAvailabilityZone() { Region = zone.RegionName, Name = zone.ZoneName, };
                ret.Add(awsZone);
            }

            return ret.ToArray();
        }
Esempio n. 5
0
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAvailabilityZones operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAvailabilityZones operation on AmazonEC2Client.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndDescribeAvailabilityZones
        ///         operation.</returns>
        public IAsyncResult BeginDescribeAvailabilityZones(DescribeAvailabilityZonesRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new DescribeAvailabilityZonesRequestMarshaller();
            var unmarshaller = DescribeAvailabilityZonesResponseUnmarshaller.Instance;

            return BeginInvoke<DescribeAvailabilityZonesRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Esempio n. 6
0
 IAsyncResult invokeDescribeAvailabilityZones(DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new DescribeAvailabilityZonesRequestMarshaller().Marshall(describeAvailabilityZonesRequest);
     var unmarshaller = DescribeAvailabilityZonesResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Esempio n. 7
0
 /// <summary>
 /// Initiates the asynchronous execution of the DescribeAvailabilityZones operation.
 /// <seealso cref="Amazon.EC2.IAmazonEC2.DescribeAvailabilityZones"/>
 /// </summary>
 /// 
 /// <param name="describeAvailabilityZonesRequest">Container for the necessary parameters to execute the DescribeAvailabilityZones operation on
 ///          AmazonEC2.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking
 ///         EndDescribeAvailabilityZones operation.</returns>
 public IAsyncResult BeginDescribeAvailabilityZones(DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest, AsyncCallback callback, object state)
 {
     return invokeDescribeAvailabilityZones(describeAvailabilityZonesRequest, callback, state, false);
 }
Esempio n. 8
0
 /// <summary>
 /// <para>Describes one or more of the Availability Zones that are available to you. The results include zones only for the region you're
 /// currently using. If there is an event impacting an Availability Zone, you can use this request to view the state and any provided message
 /// for that Availability Zone.</para> <para>For more information, see <a
 /// href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html" >Regions and Availability Zones</a> in the
 /// <i>Amazon Elastic Compute Cloud User Guide</i> .</para>
 /// </summary>
 /// 
 /// <param name="describeAvailabilityZonesRequest">Container for the necessary parameters to execute the DescribeAvailabilityZones service
 ///          method on AmazonEC2.</param>
 /// 
 /// <returns>The response from the DescribeAvailabilityZones service method, as returned by AmazonEC2.</returns>
 /// 
 public DescribeAvailabilityZonesResponse DescribeAvailabilityZones(DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest)
 {
     IAsyncResult asyncResult = invokeDescribeAvailabilityZones(describeAvailabilityZonesRequest, null, null, true);
     return EndDescribeAvailabilityZones(asyncResult);
 }
 private Amazon.EC2.Model.DescribeAvailabilityZonesResponse CallAWSServiceOperation(IAmazonEC2 client, Amazon.EC2.Model.DescribeAvailabilityZonesRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Elastic Compute Cloud (EC2)", "DescribeAvailabilityZones");
     try
     {
         #if DESKTOP
         return(client.DescribeAvailabilityZones(request));
         #elif CORECLR
         return(client.DescribeAvailabilityZonesAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
Esempio n. 10
0
		internal DescribeAvailabilityZonesResponse DescribeAvailabilityZones(DescribeAvailabilityZonesRequest request)
        {
            var task = DescribeAvailabilityZonesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Esempio n. 11
0
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAvailabilityZones operation.
        /// <seealso cref="Amazon.EC2.IAmazonEC2.DescribeAvailabilityZones"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAvailabilityZones operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public async Task<DescribeAvailabilityZonesResponse> DescribeAvailabilityZonesAsync(DescribeAvailabilityZonesRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAvailabilityZonesRequestMarshaller();
            var unmarshaller = DescribeAvailabilityZonesResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, DescribeAvailabilityZonesRequest, DescribeAvailabilityZonesResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Esempio n. 12
0
        /// <summary>
        /// <para> The DescribeAvailabilityZones operation describes availability zones that are currently available to the account and their states.
        /// </para> <para> Availability zones are not the same across accounts. The availability zone <c>us-east-1a</c> for account A is not necessarily
        /// the same as <c>us-east-1a</c> for account B. Zone assignments are mapped independently for each account. </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAvailabilityZones service
        /// method on AmazonEC2.</param>
        /// 
        /// <returns>The response from the DescribeAvailabilityZones service method, as returned by AmazonEC2.</returns>
		public DescribeAvailabilityZonesResponse DescribeAvailabilityZones(DescribeAvailabilityZonesRequest request)
        {
            var task = DescribeAvailabilityZonesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
        /// <summary>
        /// Load availability zones to view model with AWS data based on region selected and EC2 classic/vpc
        /// </summary>
        private void LoadAvailabilityZones(AmazonEC2Client ec2Client)
        {
            try
            {

                DescribeAvailabilityZonesRequest azreq = new DescribeAvailabilityZonesRequest();
                DescribeAvailabilityZonesResponse azresp = ec2Client.DescribeAvailabilityZones(azreq);
                Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                {
                    vm.Zones.Clear();
                }));
                foreach (AvailabilityZone az in azresp.DescribeAvailabilityZonesResult.AvailabilityZone)
                {
                    Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() =>
                    {
                        vm.Zones.Add(az);
                    }));
                }
            }
            catch (Exception ex)
            {
                LogManager.LogEntry(ex.Message);
                LogManager.LogEntry(ex.StackTrace);
                throw new DataLoadingException("Error occurred loading availability zones for region and environment type");
            }
        }
Esempio n. 14
0
        public List<string> descrbibeZones()
        {
            List<string> zones = new List<string>();
            try
            {
                DescribeAvailabilityZonesRequest request = new DescribeAvailabilityZonesRequest();
                DescribeAvailabilityZonesResponse response = _service.DescribeAvailabilityZones(request);

                if (response.IsSetDescribeAvailabilityZonesResult())
                {
                    DescribeAvailabilityZonesResult  describeAvailabilityZonesResult = response.DescribeAvailabilityZonesResult;
                    List<AvailabilityZone> availabilityZoneList = describeAvailabilityZonesResult.AvailabilityZone;
                    foreach (AvailabilityZone availabilityZone in availabilityZoneList)
                    {
                        if (availabilityZone.IsSetZoneName())
                        {
                            zones.Add(availabilityZone.ZoneName);
                        }
                    }
                }
            }
            catch (AmazonEC2Exception ex)
            {
                throw new Exception("Caught Exception: " + ex.XML);
            }
            return zones;
        }
        /// <summary>
        /// Describes one or more of the Availability Zones that are available to you. The results
        /// include zones only for the region you're currently using. If there is an event impacting
        /// an Availability Zone, you can use this request to view the state and any provided
        /// message for that Availability Zone.
        /// 
        ///  
        /// <para>
        /// For more information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html">Regions
        /// and Availability Zones</a> in the <i>Amazon Elastic Compute Cloud User Guide</i>.
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the DescribeAvailabilityZones service method.</param>
        /// 
        /// <returns>The response from the DescribeAvailabilityZones service method, as returned by EC2.</returns>
        public DescribeAvailabilityZonesResponse DescribeAvailabilityZones(DescribeAvailabilityZonesRequest request)
        {
            var marshaller = new DescribeAvailabilityZonesRequestMarshaller();
            var unmarshaller = DescribeAvailabilityZonesResponseUnmarshaller.Instance;

            return Invoke<DescribeAvailabilityZonesRequest,DescribeAvailabilityZonesResponse>(request, marshaller, unmarshaller);
        }
        /// <summary>
        /// Initiates the asynchronous execution of the DescribeAvailabilityZones operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the DescribeAvailabilityZones operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<DescribeAvailabilityZonesResponse> DescribeAvailabilityZonesAsync(DescribeAvailabilityZonesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAvailabilityZonesRequestMarshaller();
            var unmarshaller = DescribeAvailabilityZonesResponseUnmarshaller.Instance;

            return InvokeAsync<DescribeAvailabilityZonesRequest,DescribeAvailabilityZonesResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Esempio n. 17
0
        /// <summary>
        /// <para>Describes one or more of the Availability Zones that are available to you. The results include zones only for the region you're
        /// currently using. If there is an event impacting an Availability Zone, you can use this request to view the state and any provided message
        /// for that Availability Zone.</para> <para>For more information, see <a href="http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html">Regions and Availability Zones</a> in the
        /// <i>Amazon Elastic Compute Cloud User Guide</i> .</para>
        /// </summary>
        /// 
        /// <param name="describeAvailabilityZonesRequest">Container for the necessary parameters to execute the DescribeAvailabilityZones service
        /// method on AmazonEC2.</param>
        /// 
        /// <returns>The response from the DescribeAvailabilityZones service method, as returned by AmazonEC2.</returns>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<DescribeAvailabilityZonesResponse> DescribeAvailabilityZonesAsync(DescribeAvailabilityZonesRequest describeAvailabilityZonesRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new DescribeAvailabilityZonesRequestMarshaller();
            var unmarshaller = DescribeAvailabilityZonesResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, DescribeAvailabilityZonesRequest, DescribeAvailabilityZonesResponse>(describeAvailabilityZonesRequest, marshaller, unmarshaller, signer, cancellationToken);
        }