Skip to content

Commit

Permalink
Spot Fleet tagging capability allows customers to automatically tag i…
Browse files Browse the repository at this point in the history
…nstances launched by Spot Fleet. You can use this feature to label or distinguish instances created by distinct Spot Fleets. Tagging your EC2 instances also enables you to see instance cost allocation by tag in your AWS bill.
  • Loading branch information
sstevenkang committed Jul 24, 2017
1 parent 16d0f89 commit 6e0e442
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 9 deletions.
46 changes: 40 additions & 6 deletions generator/ServiceModels/ec2/ec2-2016-11-15.normal.json
Original file line number Diff line number Diff line change
Expand Up @@ -4554,7 +4554,8 @@
"shape":"Boolean",
"documentation":"<p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>"
}
}
},
"documentation":"<p>Contains the parameters for CreateNetworkInterfacePermission.</p>"
},
"CreateNetworkInterfacePermissionResult":{
"type":"structure",
Expand All @@ -4564,7 +4565,8 @@
"documentation":"<p>Information about the permission for the network interface.</p>",
"locationName":"interfacePermission"
}
}
},
"documentation":"<p>Contains the output of CreateNetworkInterfacePermission.</p>"
},
"CreateNetworkInterfaceRequest":{
"type":"structure",
Expand Down Expand Up @@ -5513,7 +5515,8 @@
"shape":"Boolean",
"documentation":"<p>Checks whether you have the required permissions for the action, without actually making the request, and provides an error response. If you have the required permissions, the error response is <code>DryRunOperation</code>. Otherwise, it is <code>UnauthorizedOperation</code>.</p>"
}
}
},
"documentation":"<p>Contains the parameters for DeleteNetworkInterfacePermission.</p>"
},
"DeleteNetworkInterfacePermissionResult":{
"type":"structure",
Expand All @@ -5523,7 +5526,8 @@
"documentation":"<p>Returns <code>true</code> if the request succeeds, otherwise returns an error.</p>",
"locationName":"return"
}
}
},
"documentation":"<p>Contains the output for DeleteNetworkInterfacePermission.</p>"
},
"DeleteNetworkInterfaceRequest":{
"type":"structure",
Expand Down Expand Up @@ -6996,7 +7000,8 @@
"shape":"Integer",
"documentation":"<p>The maximum number of results to return in a single call. To retrieve the remaining results, make another call with the returned <code>NextToken</code> value. If this parameter is not specified, up to 50 results are returned by default.</p>"
}
}
},
"documentation":"<p>Contains the parameters for DescribeNetworkInterfacePermissions.</p>"
},
"DescribeNetworkInterfacePermissionsResult":{
"type":"structure",
Expand All @@ -7011,7 +7016,8 @@
"documentation":"<p>The token to use to retrieve the next page of results.</p>",
"locationName":"nextToken"
}
}
},
"documentation":"<p>Contains the output for DescribeNetworkInterfacePermissions.</p>"
},
"DescribeNetworkInterfacesRequest":{
"type":"structure",
Expand Down Expand Up @@ -17407,6 +17413,11 @@
"shape":"Double",
"documentation":"<p>The number of units provided by the specified instance type. These are the same units that you chose to set the target capacity in terms (instances or a performance characteristic such as vCPUs, memory, or I/O).</p> <p>If the target capacity divided by this value is not a whole number, we round the number of instances to the next whole number. If this value is not specified, the default is 1.</p>",
"locationName":"weightedCapacity"
},
"TagSpecifications":{
"shape":"SpotFleetTagSpecificationList",
"documentation":"<p>The tags to apply during creation.</p>",
"locationName":"tagSpecificationSet"
}
},
"documentation":"<p>Describes the launch specification for one or more Spot instances.</p>"
Expand Down Expand Up @@ -17543,6 +17554,29 @@
"locationName":"item"
}
},
"SpotFleetTagSpecification":{
"type":"structure",
"members":{
"ResourceType":{
"shape":"ResourceType",
"documentation":"<p>The type of resource. Currently, the only resource type that is supported is <code>instance</code>.</p>",
"locationName":"resourceType"
},
"Tags":{
"shape":"TagList",
"documentation":"<p>The tags.</p>",
"locationName":"tag"
}
},
"documentation":"<p>The tags for a Spot fleet resource.</p>"
},
"SpotFleetTagSpecificationList":{
"type":"list",
"member":{
"shape":"SpotFleetTagSpecification",
"locationName":"item"
}
},
"SpotInstanceRequest":{
"type":"structure",
"members":{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace Amazon.EC2.Model
{
/// <summary>
/// This is the response object from the CreateNetworkInterfacePermission operation.
/// Contains the output of CreateNetworkInterfacePermission.
/// </summary>
public partial class CreateNetworkInterfacePermissionResponse : AmazonWebServiceResponse
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace Amazon.EC2.Model
{
/// <summary>
/// This is the response object from the DeleteNetworkInterfacePermission operation.
/// Contains the output for DeleteNetworkInterfacePermission.
/// </summary>
public partial class DeleteNetworkInterfacePermissionResponse : AmazonWebServiceResponse
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace Amazon.EC2.Model
{
/// <summary>
/// This is the response object from the DescribeNetworkInterfacePermissions operation.
/// Contains the output for DescribeNetworkInterfacePermissions.
/// </summary>
public partial class DescribeNetworkInterfacePermissionsResponse : AmazonWebServiceResponse
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,34 @@ public IRequest Marshall(RequestSpotFleetRequest publicRequest)
{
request.Parameters.Add("SpotFleetRequestConfig" + "." + "LaunchSpecifications" + "." + publicRequestSpotFleetRequestConfiglistValueIndex + "." + "SubnetId", StringUtils.FromString(publicRequestSpotFleetRequestConfiglistValue.SubnetId));
}
if(publicRequestSpotFleetRequestConfiglistValue.IsSetTagSpecifications())
{
int publicRequestSpotFleetRequestConfiglistValuelistValueIndex = 1;
foreach(var publicRequestSpotFleetRequestConfiglistValuelistValue in publicRequestSpotFleetRequestConfiglistValue.TagSpecifications)
{
if(publicRequestSpotFleetRequestConfiglistValuelistValue.IsSetResourceType())
{
request.Parameters.Add("SpotFleetRequestConfig" + "." + "LaunchSpecifications" + "." + publicRequestSpotFleetRequestConfiglistValueIndex + "." + "TagSpecificationSet" + "." + publicRequestSpotFleetRequestConfiglistValuelistValueIndex + "." + "ResourceType", StringUtils.FromString(publicRequestSpotFleetRequestConfiglistValuelistValue.ResourceType));
}
if(publicRequestSpotFleetRequestConfiglistValuelistValue.IsSetTags())
{
int publicRequestSpotFleetRequestConfiglistValuelistValuelistValueIndex = 1;
foreach(var publicRequestSpotFleetRequestConfiglistValuelistValuelistValue in publicRequestSpotFleetRequestConfiglistValuelistValue.Tags)
{
if(publicRequestSpotFleetRequestConfiglistValuelistValuelistValue.IsSetKey())
{
request.Parameters.Add("SpotFleetRequestConfig" + "." + "LaunchSpecifications" + "." + publicRequestSpotFleetRequestConfiglistValueIndex + "." + "TagSpecificationSet" + "." + publicRequestSpotFleetRequestConfiglistValuelistValueIndex + "." + "Tag" + "." + publicRequestSpotFleetRequestConfiglistValuelistValuelistValueIndex + "." + "Key", StringUtils.FromString(publicRequestSpotFleetRequestConfiglistValuelistValuelistValue.Key));
}
if(publicRequestSpotFleetRequestConfiglistValuelistValuelistValue.IsSetValue())
{
request.Parameters.Add("SpotFleetRequestConfig" + "." + "LaunchSpecifications" + "." + publicRequestSpotFleetRequestConfiglistValueIndex + "." + "TagSpecificationSet" + "." + publicRequestSpotFleetRequestConfiglistValuelistValueIndex + "." + "Tag" + "." + publicRequestSpotFleetRequestConfiglistValuelistValuelistValueIndex + "." + "Value", StringUtils.FromString(publicRequestSpotFleetRequestConfiglistValuelistValuelistValue.Value));
}
publicRequestSpotFleetRequestConfiglistValuelistValuelistValueIndex++;
}
}
publicRequestSpotFleetRequestConfiglistValuelistValueIndex++;
}
}
if(publicRequestSpotFleetRequestConfiglistValue.IsSetUserData())
{
request.Parameters.Add("SpotFleetRequestConfig" + "." + "LaunchSpecifications" + "." + publicRequestSpotFleetRequestConfiglistValueIndex + "." + "UserData", StringUtils.FromString(publicRequestSpotFleetRequestConfiglistValue.UserData));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ public SpotFleetLaunchSpecification Unmarshall(XmlUnmarshallerContext context)
unmarshalledObject.SubnetId = unmarshaller.Unmarshall(context);
continue;
}
if (context.TestExpression("tagSpecificationSet/item", targetDepth))
{
var unmarshaller = SpotFleetTagSpecificationUnmarshaller.Instance;
var item = unmarshaller.Unmarshall(context);
unmarshalledObject.TagSpecifications.Add(item);
continue;
}
if (context.TestExpression("userData", targetDepth))
{
var unmarshaller = StringUnmarshaller.Instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright 2010-2014 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.
*/

/*
* Do not modify this file. This file is generated from the ec2-2016-11-15.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Serialization;

using Amazon.EC2.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
namespace Amazon.EC2.Model.Internal.MarshallTransformations
{
/// <summary>
/// Response Unmarshaller for SpotFleetTagSpecification Object
/// </summary>
public class SpotFleetTagSpecificationUnmarshaller : IUnmarshaller<SpotFleetTagSpecification, XmlUnmarshallerContext>, IUnmarshaller<SpotFleetTagSpecification, JsonUnmarshallerContext>
{
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public SpotFleetTagSpecification Unmarshall(XmlUnmarshallerContext context)
{
SpotFleetTagSpecification unmarshalledObject = new SpotFleetTagSpecification();
int originalDepth = context.CurrentDepth;
int targetDepth = originalDepth + 1;

if (context.IsStartOfDocument)
targetDepth += 2;

while (context.ReadAtDepth(originalDepth))
{
if (context.IsStartElement || context.IsAttribute)
{
if (context.TestExpression("resourceType", targetDepth))
{
var unmarshaller = StringUnmarshaller.Instance;
unmarshalledObject.ResourceType = unmarshaller.Unmarshall(context);
continue;
}
if (context.TestExpression("tag/item", targetDepth))
{
var unmarshaller = TagUnmarshaller.Instance;
var item = unmarshaller.Unmarshall(context);
unmarshalledObject.Tags.Add(item);
continue;
}
}
else if (context.IsEndElement && context.CurrentDepth < originalDepth)
{
return unmarshalledObject;
}
}

return unmarshalledObject;
}

/// <summary>
/// Unmarshaller error response to exception.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public SpotFleetTagSpecification Unmarshall(JsonUnmarshallerContext context)
{
return null;
}


private static SpotFleetTagSpecificationUnmarshaller _instance = new SpotFleetTagSpecificationUnmarshaller();

/// <summary>
/// Gets the singleton.
/// </summary>
public static SpotFleetTagSpecificationUnmarshaller Instance
{
get
{
return _instance;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public partial class SpotFleetLaunchSpecification
private List<GroupIdentifier> _securityGroups = new List<GroupIdentifier>();
private string _spotPrice;
private string _subnetId;
private List<SpotFleetTagSpecification> _tagSpecifications = new List<SpotFleetTagSpecification>();
private string _userData;
private double? _weightedCapacity;

Expand Down Expand Up @@ -333,6 +334,24 @@ internal bool IsSetSubnetId()
return this._subnetId != null;
}

/// <summary>
/// Gets and sets the property TagSpecifications.
/// <para>
/// The tags to apply during creation.
/// </para>
/// </summary>
public List<SpotFleetTagSpecification> TagSpecifications
{
get { return this._tagSpecifications; }
set { this._tagSpecifications = value; }
}

// Check to see if TagSpecifications property is set
internal bool IsSetTagSpecifications()
{
return this._tagSpecifications != null && this._tagSpecifications.Count > 0;
}

/// <summary>
/// Gets and sets the property UserData.
/// <para>
Expand Down
75 changes: 75 additions & 0 deletions sdk/src/Services/EC2/Generated/Model/SpotFleetTagSpecification.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
* Copyright 2010-2014 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.
*/

/*
* Do not modify this file. This file is generated from the ec2-2016-11-15.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;

using Amazon.Runtime;
using Amazon.Runtime.Internal;

namespace Amazon.EC2.Model
{
/// <summary>
/// The tags for a Spot fleet resource.
/// </summary>
public partial class SpotFleetTagSpecification
{
private ResourceType _resourceType;
private List<Tag> _tags = new List<Tag>();

/// <summary>
/// Gets and sets the property ResourceType.
/// <para>
/// The type of resource. Currently, the only resource type that is supported is <code>instance</code>.
/// </para>
/// </summary>
public ResourceType ResourceType
{
get { return this._resourceType; }
set { this._resourceType = value; }
}

// Check to see if ResourceType property is set
internal bool IsSetResourceType()
{
return this._resourceType != null;
}

/// <summary>
/// Gets and sets the property Tags.
/// <para>
/// The tags.
/// </para>
/// </summary>
public List<Tag> Tags
{
get { return this._tags; }
set { this._tags = value; }
}

// Check to see if Tags property is set
internal bool IsSetTags()
{
return this._tags != null && this._tags.Count > 0;
}

}
}

0 comments on commit 6e0e442

Please sign in to comment.