/*******************************************************************************
* Copyright 2012-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use
* this file except in compliance with the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file.
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
* *****************************************************************************
*
* AWS Tools for Windows (TM) PowerShell (TM)
*
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using Amazon.PowerShell.Common;
using Amazon.Runtime;
using Amazon.Route53;
using Amazon.Route53.Model;
namespace Amazon.PowerShell.Cmdlets.R53
{
///
/// Lists the resource record sets in a specified hosted zone.
///
///
/// ListResourceRecordSets
returns up to 300 resource record sets at a time
/// in ASCII order, beginning at a position specified by the name
and type
/// elements.
/// Sort orderListResourceRecordSets
sorts results first by DNS name with the labels
/// reversed, for example:
/// com.example.www.
/// Note the trailing dot, which can change the sort order when the record name contains
/// characters that appear before .
(decimal 46) in the ASCII table. These
/// characters include the following: ! " # $ % & ' ( ) * + , -
/// When multiple records have the same DNS name, ListResourceRecordSets
/// sorts results by the record type.
/// Specifying where to start listing records
/// You can use the name and type elements to specify the resource record set that the
/// list begins with:
/// - If you do not specify Name or Type
-
/// The results begin with the first resource record set that the hosted zone contains.
///
- If you specify Name but not Type
-
/// The results begin with the first resource record set in the list whose name is greater
/// than or equal to
Name
.
/// - If you specify Type but not Name
-
/// Amazon Route 53 returns the
InvalidInput
error.
/// - If you specify both Name and Type
-
/// The results begin with the first resource record set in the list whose name is greater
/// than or equal to
Name
, and whose type is greater than or equal to Type
.
///
Resource record sets that are PENDING
/// This action returns the most current version of the records. This includes records
/// that are PENDING
, and that are not yet available on all Route 53 DNS
/// servers.
/// Changing resource record sets
/// To ensure that you get an accurate listing of the resource record sets for a hosted
/// zone at a point in time, do not submit a ChangeResourceRecordSets
request
/// while you're paging through the results of a ListResourceRecordSets
request.
/// If you do, some pages may display results without the latest changes while other pages
/// display results with the latest changes.
/// Displaying the next page of results
/// If a ListResourceRecordSets
command returns more than one page of results,
/// the value of IsTruncated
is true
. To display the next page
/// of results, get the values of NextRecordName
, NextRecordType
,
/// and NextRecordIdentifier
(if any) from the response. Then submit another
/// ListResourceRecordSets
request, and specify those values for StartRecordName
,
/// StartRecordType
, and StartRecordIdentifier
.
///
///
[Cmdlet("Get", "R53ResourceRecordSet")]
[OutputType("Amazon.Route53.Model.ListResourceRecordSetsResponse")]
[AWSCmdlet("Calls the Amazon Route 53 ListResourceRecordSets API operation.", Operation = new[] {"ListResourceRecordSets"}, SelectReturnType = typeof(Amazon.Route53.Model.ListResourceRecordSetsResponse))]
[AWSCmdletOutput("Amazon.Route53.Model.ListResourceRecordSetsResponse",
"This cmdlet returns an Amazon.Route53.Model.ListResourceRecordSetsResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class GetR53ResourceRecordSetCmdlet : AmazonRoute53ClientCmdlet, IExecutor
{
#region Parameter HostedZoneId
///
///
/// The ID of the hosted zone that contains the resource record sets that you want to
/// list.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
#else
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("Id")]
public System.String HostedZoneId { get; set; }
#endregion
#region Parameter StartRecordIdentifier
///
///
/// Resource record sets that have a routing policy other than simple: If results
/// were truncated for a given DNS name and type, specify the value of NextRecordIdentifier
/// from the previous response to get the next resource record set that has the current
/// DNS name and type.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String StartRecordIdentifier { get; set; }
#endregion
#region Parameter StartRecordName
///
///
/// The first name in the lexicographic ordering of resource record sets that you want
/// to list. If the specified record name doesn't exist, the results begin with the first
/// resource record set that has a name greater than the value of name
.
///
///
[System.Management.Automation.Parameter(Position = 1, ValueFromPipelineByPropertyName = true)]
public System.String StartRecordName { get; set; }
#endregion
#region Parameter StartRecordType
///
///
/// The type of resource record set to begin the record listing from.Valid values for basic resource record sets: A
| AAAA
|
/// CAA
| CNAME
| MX
| NAPTR
| NS
/// | PTR
| SOA
| SPF
| SRV
| TXT
Values for weighted, latency, geolocation, and failover resource record sets: A
/// | AAAA
| CAA
| CNAME
| MX
| NAPTR
/// | PTR
| SPF
| SRV
| TXT
Values for alias resource record sets: - API Gateway custom regional API or edge-optimized API: A
- CloudFront distribution: A or AAAA
- Elastic Beanstalk environment that has a regionalized subdomain: A
- Elastic Load Balancing load balancer: A | AAAA
- S3 bucket: A
- VPC interface VPC endpoint: A
- Another resource record set in this hosted zone: The type of the resource
/// record set that the alias references.
Constraint: Specifying type
without specifying name
returns
/// an InvalidInput
error.
///
///
[System.Management.Automation.Parameter(Position = 2, ValueFromPipelineByPropertyName = true)]
[AWSConstantClassSource("Amazon.Route53.RRType")]
public Amazon.Route53.RRType StartRecordType { get; set; }
#endregion
#region Parameter MaxItem
///
///
/// (Optional) The maximum number of resource records sets to include in the response
/// body for this request. If the response includes more than maxitems
resource
/// record sets, the value of the IsTruncated
element in the response is
/// true
, and the values of the NextRecordName
and NextRecordType
/// elements in the response identify the first resource record set in the next group
/// of maxitems
resource record sets.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("MaxItems")]
public System.String MaxItem { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is '*'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.Route53.Model.ListResourceRecordSetsResponse).
/// Specifying the name of a property of type Amazon.Route53.Model.ListResourceRecordSetsResponse will result in that property being returned.
/// Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public string Select { get; set; } = "*";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the HostedZoneId parameter.
/// The -PassThru parameter is deprecated, use -Select '^HostedZoneId' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^HostedZoneId' instead. This parameter will be removed in a future version.")]
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter PassThru { get; set; }
#endregion
protected override void ProcessRecord()
{
this._AWSSignerType = "v4";
base.ProcessRecord();
var context = new CmdletContext();
// allow for manipulation of parameters prior to loading into context
PreExecutionContextLoad(context);
#pragma warning disable CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (ParameterWasBound(nameof(this.Select)))
{
context.Select = CreateSelectDelegate(Select) ??
throw new System.ArgumentException("Invalid value for -Select parameter.", nameof(this.Select));
if (this.PassThru.IsPresent)
{
throw new System.ArgumentException("-PassThru cannot be used when -Select is specified.", nameof(this.Select));
}
}
else if (this.PassThru.IsPresent)
{
context.Select = (response, cmdlet) => this.HostedZoneId;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.HostedZoneId = this.HostedZoneId;
#if MODULAR
if (this.HostedZoneId == null && ParameterWasBound(nameof(this.HostedZoneId)))
{
WriteWarning("You are passing $null as a value for parameter HostedZoneId which is marked as required. In case you believe this parameter was incorrectly marked as required, report this by opening an issue at https://github.com/aws/aws-tools-for-powershell/issues.");
}
#endif
context.StartRecordName = this.StartRecordName;
context.StartRecordType = this.StartRecordType;
context.StartRecordIdentifier = this.StartRecordIdentifier;
context.MaxItem = this.MaxItem;
// allow further manipulation of loaded context prior to processing
PostExecutionContextLoad(context);
var output = Execute(context) as CmdletOutput;
ProcessOutput(output);
}
#region IExecutor Members
public object Execute(ExecutorContext context)
{
var cmdletContext = context as CmdletContext;
// create request
var request = new Amazon.Route53.Model.ListResourceRecordSetsRequest();
if (cmdletContext.HostedZoneId != null)
{
request.HostedZoneId = cmdletContext.HostedZoneId;
}
if (cmdletContext.StartRecordName != null)
{
request.StartRecordName = cmdletContext.StartRecordName;
}
if (cmdletContext.StartRecordType != null)
{
request.StartRecordType = cmdletContext.StartRecordType;
}
if (cmdletContext.StartRecordIdentifier != null)
{
request.StartRecordIdentifier = cmdletContext.StartRecordIdentifier;
}
if (cmdletContext.MaxItem != null)
{
request.MaxItems = cmdletContext.MaxItem;
}
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;
}
public ExecutorContext CreateContext()
{
return new CmdletContext();
}
#endregion
#region AWS Service Operation Call
private Amazon.Route53.Model.ListResourceRecordSetsResponse CallAWSServiceOperation(IAmazonRoute53 client, Amazon.Route53.Model.ListResourceRecordSetsRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Route 53", "ListResourceRecordSets");
try
{
#if DESKTOP
return client.ListResourceRecordSets(request);
#elif CORECLR
return client.ListResourceRecordSetsAsync(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;
}
}
#endregion
internal partial class CmdletContext : ExecutorContext
{
public System.String HostedZoneId { get; set; }
public System.String StartRecordName { get; set; }
public Amazon.Route53.RRType StartRecordType { get; set; }
public System.String StartRecordIdentifier { get; set; }
public System.String MaxItem { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response;
}
}
}