/*******************************************************************************
* 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.IoTWireless;
using Amazon.IoTWireless.Model;
namespace Amazon.PowerShell.Cmdlets.IOTW
{
///
/// Get estimated position information as a payload in GeoJSON format. The payload measurement
/// data is resolved using solvers that are provided by third-party vendors.
///
[Cmdlet("Get", "IOTWPositionEstimate")]
[OutputType("System.IO.MemoryStream")]
[AWSCmdlet("Calls the AWS IoT Wireless GetPositionEstimate API operation.", Operation = new[] {"GetPositionEstimate"}, SelectReturnType = typeof(Amazon.IoTWireless.Model.GetPositionEstimateResponse))]
[AWSCmdletOutput("System.IO.MemoryStream or Amazon.IoTWireless.Model.GetPositionEstimateResponse",
"This cmdlet returns a System.IO.MemoryStream object.",
"The service call response (type Amazon.IoTWireless.Model.GetPositionEstimateResponse) can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class GetIOTWPositionEstimateCmdlet : AmazonIoTWirelessClientCmdlet, IExecutor
{
#region Parameter Gnss_AssistAltitude
///
///
/// Optional assistance altitude, which is the altitude of the device at capture time,
/// specified in meters above the WGS84 reference ellipsoid.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Single? Gnss_AssistAltitude { get; set; }
#endregion
#region Parameter Gnss_AssistPosition
///
///
/// Optional assistance position information, specified using latitude and longitude values
/// in degrees. The coordinates are inside the WGS84 reference frame.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Single[] Gnss_AssistPosition { get; set; }
#endregion
#region Parameter Gnss_CaptureTime
///
///
/// Optional parameter that gives an estimate of the time when the GNSS scan information
/// is taken, in seconds GPS time (GPST). If capture time is not specified, the local
/// server time is used.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Single? Gnss_CaptureTime { get; set; }
#endregion
#region Parameter Gnss_CaptureTimeAccuracy
///
///
/// Optional value that gives the capture time estimate accuracy, in seconds. If capture
/// time accuracy is not specified, default value of 300 is used.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Single? Gnss_CaptureTimeAccuracy { get; set; }
#endregion
#region Parameter CellTowers_Cdma
///
///
/// CDMA object information.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.IoTWireless.Model.CdmaObj[] CellTowers_Cdma { get; set; }
#endregion
#region Parameter CellTowers_Gsm
///
///
/// GSM object information.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.IoTWireless.Model.GsmObj[] CellTowers_Gsm { get; set; }
#endregion
#region Parameter Ip_IpAddress
///
///
/// IP address information.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Ip_IpAddress { get; set; }
#endregion
#region Parameter CellTowers_Lte
///
///
/// LTE object information.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.IoTWireless.Model.LteObj[] CellTowers_Lte { get; set; }
#endregion
#region Parameter Gnss_Payload
///
///
/// Payload that contains the GNSS scan result, or NAV message, in hexadecimal notation.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Gnss_Payload { get; set; }
#endregion
#region Parameter CellTowers_Tdscdma
///
///
/// TD-SCDMA object information.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.IoTWireless.Model.TdscdmaObj[] CellTowers_Tdscdma { get; set; }
#endregion
#region Parameter Timestamp
///
///
/// Optional information that specifies the time when the position information will be
/// resolved. It uses the Unix timestamp format. If not specified, the time at which the
/// request was received will be used.
///
///
[System.Management.Automation.Parameter(Position = 0, ValueFromPipelineByPropertyName = true, ValueFromPipeline = true)]
public System.DateTime? Timestamp { get; set; }
#endregion
#region Parameter Gnss_Use2DSolver
///
///
/// Optional parameter that forces 2D solve, which modifies the positioning algorithm
/// to a 2D solution problem. When this parameter is specified, the assistance altitude
/// should have an accuracy of at least 10 meters.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.Boolean? Gnss_Use2DSolver { get; set; }
#endregion
#region Parameter CellTowers_Wcdma
///
///
/// WCDMA object information.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public Amazon.IoTWireless.Model.WcdmaObj[] CellTowers_Wcdma { get; set; }
#endregion
#region Parameter WiFiAccessPoint
///
///
/// Retrieves an estimated device position by resolving WLAN measurement data. The position
/// is resolved using HERE's Wi-Fi based solver.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("WiFiAccessPoints")]
public Amazon.IoTWireless.Model.WiFiAccessPoint[] WiFiAccessPoint { get; set; }
#endregion
#region Parameter Select
///
/// Use the -Select parameter to control the cmdlet output. The default value is 'GeoJsonPayload'.
/// Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.IoTWireless.Model.GetPositionEstimateResponse).
/// Specifying the name of a property of type Amazon.IoTWireless.Model.GetPositionEstimateResponse 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; } = "GeoJsonPayload";
#endregion
#region Parameter PassThru
///
/// Changes the cmdlet behavior to return the value passed to the Timestamp parameter.
/// The -PassThru parameter is deprecated, use -Select '^Timestamp' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^Timestamp' 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.Timestamp;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
if (this.CellTowers_Cdma != null)
{
context.CellTowers_Cdma = new List(this.CellTowers_Cdma);
}
if (this.CellTowers_Gsm != null)
{
context.CellTowers_Gsm = new List(this.CellTowers_Gsm);
}
if (this.CellTowers_Lte != null)
{
context.CellTowers_Lte = new List(this.CellTowers_Lte);
}
if (this.CellTowers_Tdscdma != null)
{
context.CellTowers_Tdscdma = new List(this.CellTowers_Tdscdma);
}
if (this.CellTowers_Wcdma != null)
{
context.CellTowers_Wcdma = new List(this.CellTowers_Wcdma);
}
context.Gnss_AssistAltitude = this.Gnss_AssistAltitude;
if (this.Gnss_AssistPosition != null)
{
context.Gnss_AssistPosition = new List(this.Gnss_AssistPosition);
}
context.Gnss_CaptureTime = this.Gnss_CaptureTime;
context.Gnss_CaptureTimeAccuracy = this.Gnss_CaptureTimeAccuracy;
context.Gnss_Payload = this.Gnss_Payload;
context.Gnss_Use2DSolver = this.Gnss_Use2DSolver;
context.Ip_IpAddress = this.Ip_IpAddress;
context.Timestamp = this.Timestamp;
if (this.WiFiAccessPoint != null)
{
context.WiFiAccessPoint = new List(this.WiFiAccessPoint);
}
// 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.IoTWireless.Model.GetPositionEstimateRequest();
// populate CellTowers
var requestCellTowersIsNull = true;
request.CellTowers = new Amazon.IoTWireless.Model.CellTowers();
List requestCellTowers_cellTowers_Cdma = null;
if (cmdletContext.CellTowers_Cdma != null)
{
requestCellTowers_cellTowers_Cdma = cmdletContext.CellTowers_Cdma;
}
if (requestCellTowers_cellTowers_Cdma != null)
{
request.CellTowers.Cdma = requestCellTowers_cellTowers_Cdma;
requestCellTowersIsNull = false;
}
List requestCellTowers_cellTowers_Gsm = null;
if (cmdletContext.CellTowers_Gsm != null)
{
requestCellTowers_cellTowers_Gsm = cmdletContext.CellTowers_Gsm;
}
if (requestCellTowers_cellTowers_Gsm != null)
{
request.CellTowers.Gsm = requestCellTowers_cellTowers_Gsm;
requestCellTowersIsNull = false;
}
List requestCellTowers_cellTowers_Lte = null;
if (cmdletContext.CellTowers_Lte != null)
{
requestCellTowers_cellTowers_Lte = cmdletContext.CellTowers_Lte;
}
if (requestCellTowers_cellTowers_Lte != null)
{
request.CellTowers.Lte = requestCellTowers_cellTowers_Lte;
requestCellTowersIsNull = false;
}
List requestCellTowers_cellTowers_Tdscdma = null;
if (cmdletContext.CellTowers_Tdscdma != null)
{
requestCellTowers_cellTowers_Tdscdma = cmdletContext.CellTowers_Tdscdma;
}
if (requestCellTowers_cellTowers_Tdscdma != null)
{
request.CellTowers.Tdscdma = requestCellTowers_cellTowers_Tdscdma;
requestCellTowersIsNull = false;
}
List requestCellTowers_cellTowers_Wcdma = null;
if (cmdletContext.CellTowers_Wcdma != null)
{
requestCellTowers_cellTowers_Wcdma = cmdletContext.CellTowers_Wcdma;
}
if (requestCellTowers_cellTowers_Wcdma != null)
{
request.CellTowers.Wcdma = requestCellTowers_cellTowers_Wcdma;
requestCellTowersIsNull = false;
}
// determine if request.CellTowers should be set to null
if (requestCellTowersIsNull)
{
request.CellTowers = null;
}
// populate Gnss
var requestGnssIsNull = true;
request.Gnss = new Amazon.IoTWireless.Model.Gnss();
System.Single? requestGnss_gnss_AssistAltitude = null;
if (cmdletContext.Gnss_AssistAltitude != null)
{
requestGnss_gnss_AssistAltitude = cmdletContext.Gnss_AssistAltitude.Value;
}
if (requestGnss_gnss_AssistAltitude != null)
{
request.Gnss.AssistAltitude = requestGnss_gnss_AssistAltitude.Value;
requestGnssIsNull = false;
}
List requestGnss_gnss_AssistPosition = null;
if (cmdletContext.Gnss_AssistPosition != null)
{
requestGnss_gnss_AssistPosition = cmdletContext.Gnss_AssistPosition;
}
if (requestGnss_gnss_AssistPosition != null)
{
request.Gnss.AssistPosition = requestGnss_gnss_AssistPosition;
requestGnssIsNull = false;
}
System.Single? requestGnss_gnss_CaptureTime = null;
if (cmdletContext.Gnss_CaptureTime != null)
{
requestGnss_gnss_CaptureTime = cmdletContext.Gnss_CaptureTime.Value;
}
if (requestGnss_gnss_CaptureTime != null)
{
request.Gnss.CaptureTime = requestGnss_gnss_CaptureTime.Value;
requestGnssIsNull = false;
}
System.Single? requestGnss_gnss_CaptureTimeAccuracy = null;
if (cmdletContext.Gnss_CaptureTimeAccuracy != null)
{
requestGnss_gnss_CaptureTimeAccuracy = cmdletContext.Gnss_CaptureTimeAccuracy.Value;
}
if (requestGnss_gnss_CaptureTimeAccuracy != null)
{
request.Gnss.CaptureTimeAccuracy = requestGnss_gnss_CaptureTimeAccuracy.Value;
requestGnssIsNull = false;
}
System.String requestGnss_gnss_Payload = null;
if (cmdletContext.Gnss_Payload != null)
{
requestGnss_gnss_Payload = cmdletContext.Gnss_Payload;
}
if (requestGnss_gnss_Payload != null)
{
request.Gnss.Payload = requestGnss_gnss_Payload;
requestGnssIsNull = false;
}
System.Boolean? requestGnss_gnss_Use2DSolver = null;
if (cmdletContext.Gnss_Use2DSolver != null)
{
requestGnss_gnss_Use2DSolver = cmdletContext.Gnss_Use2DSolver.Value;
}
if (requestGnss_gnss_Use2DSolver != null)
{
request.Gnss.Use2DSolver = requestGnss_gnss_Use2DSolver.Value;
requestGnssIsNull = false;
}
// determine if request.Gnss should be set to null
if (requestGnssIsNull)
{
request.Gnss = null;
}
// populate Ip
var requestIpIsNull = true;
request.Ip = new Amazon.IoTWireless.Model.Ip();
System.String requestIp_ip_IpAddress = null;
if (cmdletContext.Ip_IpAddress != null)
{
requestIp_ip_IpAddress = cmdletContext.Ip_IpAddress;
}
if (requestIp_ip_IpAddress != null)
{
request.Ip.IpAddress = requestIp_ip_IpAddress;
requestIpIsNull = false;
}
// determine if request.Ip should be set to null
if (requestIpIsNull)
{
request.Ip = null;
}
if (cmdletContext.Timestamp != null)
{
request.Timestamp = cmdletContext.Timestamp.Value;
}
if (cmdletContext.WiFiAccessPoint != null)
{
request.WiFiAccessPoints = cmdletContext.WiFiAccessPoint;
}
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.IoTWireless.Model.GetPositionEstimateResponse CallAWSServiceOperation(IAmazonIoTWireless client, Amazon.IoTWireless.Model.GetPositionEstimateRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "AWS IoT Wireless", "GetPositionEstimate");
try
{
#if DESKTOP
return client.GetPositionEstimate(request);
#elif CORECLR
return client.GetPositionEstimateAsync(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 List CellTowers_Cdma { get; set; }
public List CellTowers_Gsm { get; set; }
public List CellTowers_Lte { get; set; }
public List CellTowers_Tdscdma { get; set; }
public List CellTowers_Wcdma { get; set; }
public System.Single? Gnss_AssistAltitude { get; set; }
public List Gnss_AssistPosition { get; set; }
public System.Single? Gnss_CaptureTime { get; set; }
public System.Single? Gnss_CaptureTimeAccuracy { get; set; }
public System.String Gnss_Payload { get; set; }
public System.Boolean? Gnss_Use2DSolver { get; set; }
public System.String Ip_IpAddress { get; set; }
public System.DateTime? Timestamp { get; set; }
public List WiFiAccessPoint { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response.GeoJsonPayload;
}
}
}