/*******************************************************************************
* 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.QuickSight;
using Amazon.QuickSight.Model;
namespace Amazon.PowerShell.Cmdlets.QS
{
///
/// Creates a refresh schedule for a dataset. You can create up to 5 different schedules
/// for a single dataset.
///
[Cmdlet("New", "QSRefreshSchedule", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.Medium)]
[OutputType("Amazon.QuickSight.Model.CreateRefreshScheduleResponse")]
[AWSCmdlet("Calls the Amazon QuickSight CreateRefreshSchedule API operation.", Operation = new[] {"CreateRefreshSchedule"}, SelectReturnType = typeof(Amazon.QuickSight.Model.CreateRefreshScheduleResponse))]
[AWSCmdletOutput("Amazon.QuickSight.Model.CreateRefreshScheduleResponse",
"This cmdlet returns an Amazon.QuickSight.Model.CreateRefreshScheduleResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack."
)]
public partial class NewQSRefreshScheduleCmdlet : AmazonQuickSightClientCmdlet, IExecutor
{
#region Parameter Schedule_Arn
///
///
/// The Amazon Resource Name (ARN) for the refresh schedule.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.String Schedule_Arn { get; set; }
#endregion
#region Parameter AwsAccountId
///
///
/// The Amazon Web Services account ID.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String AwsAccountId { get; set; }
#endregion
#region Parameter DataSetId
///
///
/// The ID of the dataset.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowEmptyString]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
public System.String DataSetId { get; set; }
#endregion
#region Parameter RefreshOnDay_DayOfMonth
///
///
/// The day of the month that you want to schedule refresh on.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Schedule_ScheduleFrequency_RefreshOnDay_DayOfMonth")]
public System.String RefreshOnDay_DayOfMonth { get; set; }
#endregion
#region Parameter RefreshOnDay_DayOfWeek
///
///
/// The day of the week that you want to schedule a refresh on.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Schedule_ScheduleFrequency_RefreshOnDay_DayOfWeek")]
[AWSConstantClassSource("Amazon.QuickSight.DayOfWeek")]
public Amazon.QuickSight.DayOfWeek RefreshOnDay_DayOfWeek { get; set; }
#endregion
#region Parameter ScheduleFrequency_Interval
///
///
/// The interval between scheduled refreshes. Valid values are as follows:MINUTE15
: The dataset refreshes every 15 minutes. This value is only
/// supported for incremental refreshes. This interval can only be used for one schedule
/// per dataset.MINUTE30
:The dataset refreshes every 30 minutes. This value is only
/// supported for incremental refreshes. This interval can only be used for one schedule
/// per dataset.HOURLY
: The dataset refreshes every hour. This interval can only be
/// used for one schedule per dataset.DAILY
: The dataset refreshes every day.WEEKLY
: The dataset refreshes every week.MONTHLY
: The dataset refreshes every month.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[Alias("Schedule_ScheduleFrequency_Interval")]
[AWSConstantClassSource("Amazon.QuickSight.RefreshInterval")]
public Amazon.QuickSight.RefreshInterval ScheduleFrequency_Interval { get; set; }
#endregion
#region Parameter Schedule_RefreshType
///
///
/// The type of refresh that a datset undergoes. Valid values are as follows:FULL_REFRESH
: A complete refresh of a dataset.INCREMENTAL_REFRESH
: A partial refresh of some rows of a dataset, based
/// on the time window specified.
For more information on full and incremental refreshes, see Refreshing
/// SPICE data in the Amazon QuickSight User Guide.
///
///
#if !MODULAR
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
#else
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true, Mandatory = true)]
[System.Management.Automation.AllowNull]
#endif
[Amazon.PowerShell.Common.AWSRequiredParameter]
[AWSConstantClassSource("Amazon.QuickSight.IngestionType")]
public Amazon.QuickSight.IngestionType Schedule_RefreshType { get; set; }
#endregion
#region Parameter Schedule_ScheduleId
///
///
/// An identifier for the refresh schedule.
///
///
#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]
public System.String Schedule_ScheduleId { get; set; }
#endregion
#region Parameter Schedule_StartAfterDateTime
///
///
/// Time after which the refresh schedule can be started, expressed in YYYY-MM-DDTHH:MM:SS
/// format.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public System.DateTime? Schedule_StartAfterDateTime { get; set; }
#endregion
#region Parameter ScheduleFrequency_TimeOfTheDay
///
///
/// The time of day that you want the datset to refresh. This value is expressed in HH:MM
/// format. This field is not required for schedules that refresh hourly.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Schedule_ScheduleFrequency_TimeOfTheDay")]
public System.String ScheduleFrequency_TimeOfTheDay { get; set; }
#endregion
#region Parameter ScheduleFrequency_Timezone
///
///
/// The timezone that you want the refresh schedule to use. The timezone ID must match
/// a corresponding ID found on java.util.time.getAvailableIDs()
.
///
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
[Alias("Schedule_ScheduleFrequency_Timezone")]
public System.String ScheduleFrequency_Timezone { 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.QuickSight.Model.CreateRefreshScheduleResponse).
/// Specifying the name of a property of type Amazon.QuickSight.Model.CreateRefreshScheduleResponse 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 Schedule_ScheduleId parameter.
/// The -PassThru parameter is deprecated, use -Select '^Schedule_ScheduleId' instead. This parameter will be removed in a future version.
///
[System.Obsolete("The -PassThru parameter is deprecated, use -Select '^Schedule_ScheduleId' instead. This parameter will be removed in a future version.")]
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter PassThru { get; set; }
#endregion
#region Parameter Force
///
/// This parameter overrides confirmation prompts to force
/// the cmdlet to continue its operation. This parameter should always
/// be used with caution.
///
[System.Management.Automation.Parameter(ValueFromPipelineByPropertyName = true)]
public SwitchParameter Force { get; set; }
#endregion
protected override void ProcessRecord()
{
this._AWSSignerType = "v4";
base.ProcessRecord();
var resourceIdentifiersText = FormatParameterValuesForConfirmationMsg(nameof(this.Schedule_ScheduleId), MyInvocation.BoundParameters);
if (!ConfirmShouldProceed(this.Force.IsPresent, resourceIdentifiersText, "New-QSRefreshSchedule (CreateRefreshSchedule)"))
{
return;
}
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.Schedule_ScheduleId;
}
#pragma warning restore CS0618, CS0612 //A class member was marked with the Obsolete attribute
context.AwsAccountId = this.AwsAccountId;
#if MODULAR
if (this.AwsAccountId == null && ParameterWasBound(nameof(this.AwsAccountId)))
{
WriteWarning("You are passing $null as a value for parameter AwsAccountId 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.DataSetId = this.DataSetId;
#if MODULAR
if (this.DataSetId == null && ParameterWasBound(nameof(this.DataSetId)))
{
WriteWarning("You are passing $null as a value for parameter DataSetId 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.Schedule_Arn = this.Schedule_Arn;
context.Schedule_RefreshType = this.Schedule_RefreshType;
#if MODULAR
if (this.Schedule_RefreshType == null && ParameterWasBound(nameof(this.Schedule_RefreshType)))
{
WriteWarning("You are passing $null as a value for parameter Schedule_RefreshType 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.ScheduleFrequency_Interval = this.ScheduleFrequency_Interval;
#if MODULAR
if (this.ScheduleFrequency_Interval == null && ParameterWasBound(nameof(this.ScheduleFrequency_Interval)))
{
WriteWarning("You are passing $null as a value for parameter ScheduleFrequency_Interval 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.RefreshOnDay_DayOfMonth = this.RefreshOnDay_DayOfMonth;
context.RefreshOnDay_DayOfWeek = this.RefreshOnDay_DayOfWeek;
context.ScheduleFrequency_TimeOfTheDay = this.ScheduleFrequency_TimeOfTheDay;
context.ScheduleFrequency_Timezone = this.ScheduleFrequency_Timezone;
context.Schedule_ScheduleId = this.Schedule_ScheduleId;
#if MODULAR
if (this.Schedule_ScheduleId == null && ParameterWasBound(nameof(this.Schedule_ScheduleId)))
{
WriteWarning("You are passing $null as a value for parameter Schedule_ScheduleId 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.Schedule_StartAfterDateTime = this.Schedule_StartAfterDateTime;
// 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.QuickSight.Model.CreateRefreshScheduleRequest();
if (cmdletContext.AwsAccountId != null)
{
request.AwsAccountId = cmdletContext.AwsAccountId;
}
if (cmdletContext.DataSetId != null)
{
request.DataSetId = cmdletContext.DataSetId;
}
// populate Schedule
var requestScheduleIsNull = true;
request.Schedule = new Amazon.QuickSight.Model.RefreshSchedule();
System.String requestSchedule_schedule_Arn = null;
if (cmdletContext.Schedule_Arn != null)
{
requestSchedule_schedule_Arn = cmdletContext.Schedule_Arn;
}
if (requestSchedule_schedule_Arn != null)
{
request.Schedule.Arn = requestSchedule_schedule_Arn;
requestScheduleIsNull = false;
}
Amazon.QuickSight.IngestionType requestSchedule_schedule_RefreshType = null;
if (cmdletContext.Schedule_RefreshType != null)
{
requestSchedule_schedule_RefreshType = cmdletContext.Schedule_RefreshType;
}
if (requestSchedule_schedule_RefreshType != null)
{
request.Schedule.RefreshType = requestSchedule_schedule_RefreshType;
requestScheduleIsNull = false;
}
System.String requestSchedule_schedule_ScheduleId = null;
if (cmdletContext.Schedule_ScheduleId != null)
{
requestSchedule_schedule_ScheduleId = cmdletContext.Schedule_ScheduleId;
}
if (requestSchedule_schedule_ScheduleId != null)
{
request.Schedule.ScheduleId = requestSchedule_schedule_ScheduleId;
requestScheduleIsNull = false;
}
System.DateTime? requestSchedule_schedule_StartAfterDateTime = null;
if (cmdletContext.Schedule_StartAfterDateTime != null)
{
requestSchedule_schedule_StartAfterDateTime = cmdletContext.Schedule_StartAfterDateTime.Value;
}
if (requestSchedule_schedule_StartAfterDateTime != null)
{
request.Schedule.StartAfterDateTime = requestSchedule_schedule_StartAfterDateTime.Value;
requestScheduleIsNull = false;
}
Amazon.QuickSight.Model.RefreshFrequency requestSchedule_schedule_ScheduleFrequency = null;
// populate ScheduleFrequency
var requestSchedule_schedule_ScheduleFrequencyIsNull = true;
requestSchedule_schedule_ScheduleFrequency = new Amazon.QuickSight.Model.RefreshFrequency();
Amazon.QuickSight.RefreshInterval requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Interval = null;
if (cmdletContext.ScheduleFrequency_Interval != null)
{
requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Interval = cmdletContext.ScheduleFrequency_Interval;
}
if (requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Interval != null)
{
requestSchedule_schedule_ScheduleFrequency.Interval = requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Interval;
requestSchedule_schedule_ScheduleFrequencyIsNull = false;
}
System.String requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_TimeOfTheDay = null;
if (cmdletContext.ScheduleFrequency_TimeOfTheDay != null)
{
requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_TimeOfTheDay = cmdletContext.ScheduleFrequency_TimeOfTheDay;
}
if (requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_TimeOfTheDay != null)
{
requestSchedule_schedule_ScheduleFrequency.TimeOfTheDay = requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_TimeOfTheDay;
requestSchedule_schedule_ScheduleFrequencyIsNull = false;
}
System.String requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Timezone = null;
if (cmdletContext.ScheduleFrequency_Timezone != null)
{
requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Timezone = cmdletContext.ScheduleFrequency_Timezone;
}
if (requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Timezone != null)
{
requestSchedule_schedule_ScheduleFrequency.Timezone = requestSchedule_schedule_ScheduleFrequency_scheduleFrequency_Timezone;
requestSchedule_schedule_ScheduleFrequencyIsNull = false;
}
Amazon.QuickSight.Model.ScheduleRefreshOnEntity requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay = null;
// populate RefreshOnDay
var requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDayIsNull = true;
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay = new Amazon.QuickSight.Model.ScheduleRefreshOnEntity();
System.String requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfMonth = null;
if (cmdletContext.RefreshOnDay_DayOfMonth != null)
{
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfMonth = cmdletContext.RefreshOnDay_DayOfMonth;
}
if (requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfMonth != null)
{
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay.DayOfMonth = requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfMonth;
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDayIsNull = false;
}
Amazon.QuickSight.DayOfWeek requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfWeek = null;
if (cmdletContext.RefreshOnDay_DayOfWeek != null)
{
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfWeek = cmdletContext.RefreshOnDay_DayOfWeek;
}
if (requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfWeek != null)
{
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay.DayOfWeek = requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay_refreshOnDay_DayOfWeek;
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDayIsNull = false;
}
// determine if requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay should be set to null
if (requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDayIsNull)
{
requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay = null;
}
if (requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay != null)
{
requestSchedule_schedule_ScheduleFrequency.RefreshOnDay = requestSchedule_schedule_ScheduleFrequency_schedule_ScheduleFrequency_RefreshOnDay;
requestSchedule_schedule_ScheduleFrequencyIsNull = false;
}
// determine if requestSchedule_schedule_ScheduleFrequency should be set to null
if (requestSchedule_schedule_ScheduleFrequencyIsNull)
{
requestSchedule_schedule_ScheduleFrequency = null;
}
if (requestSchedule_schedule_ScheduleFrequency != null)
{
request.Schedule.ScheduleFrequency = requestSchedule_schedule_ScheduleFrequency;
requestScheduleIsNull = false;
}
// determine if request.Schedule should be set to null
if (requestScheduleIsNull)
{
request.Schedule = null;
}
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.QuickSight.Model.CreateRefreshScheduleResponse CallAWSServiceOperation(IAmazonQuickSight client, Amazon.QuickSight.Model.CreateRefreshScheduleRequest request)
{
Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon QuickSight", "CreateRefreshSchedule");
try
{
#if DESKTOP
return client.CreateRefreshSchedule(request);
#elif CORECLR
return client.CreateRefreshScheduleAsync(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 AwsAccountId { get; set; }
public System.String DataSetId { get; set; }
public System.String Schedule_Arn { get; set; }
public Amazon.QuickSight.IngestionType Schedule_RefreshType { get; set; }
public Amazon.QuickSight.RefreshInterval ScheduleFrequency_Interval { get; set; }
public System.String RefreshOnDay_DayOfMonth { get; set; }
public Amazon.QuickSight.DayOfWeek RefreshOnDay_DayOfWeek { get; set; }
public System.String ScheduleFrequency_TimeOfTheDay { get; set; }
public System.String ScheduleFrequency_Timezone { get; set; }
public System.String Schedule_ScheduleId { get; set; }
public System.DateTime? Schedule_StartAfterDateTime { get; set; }
public System.Func Select { get; set; } =
(response, cmdlet) => response;
}
}
}