public void Deserialize()
        {
            var xml = @"<StopInstancesResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
  <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId>
  <instancesSet>
    <item>
      <instanceId>i-1234567890abcdef0</instanceId>
      <currentState>
          <code>64</code>
          <name>stopping</name>
      </currentState>
      <previousState>
          <code>16</code>
          <name>running</name>
      </previousState>
    </item>
  </instancesSet>
</StopInstancesResponse>";

            var response = Ec2Serializer <StopInstancesResponse> .Deserialize(xml);

            Assert.Equal("i-1234567890abcdef0", response.Instances[0].InstanceId);

            Assert.Equal(64, response.Instances[0].CurrentState.Code);
            Assert.Equal("stopping", response.Instances[0].CurrentState.Name);

            Assert.Equal(16, response.Instances[0].PreviousState.Code);
            Assert.Equal("running", response.Instances[0].PreviousState.Name);
        }
Ejemplo n.º 2
0
        public void X()
        {
            var text =
                @"<DescribeImagesResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
  <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
  <imagesSet>
    <item>
      <imageId>ami-1a2b3c4d</imageId>
      <imageLocation>amazon/getting-started</imageLocation>
      <imageState>available</imageState>
      <imageOwnerId>123456789012</imageOwnerId>
      <isPublic>true</isPublic>
      <architecture>i386</architecture>
      <imageType>machine</imageType>
      <kernelId>aki-1a2b3c4d</kernelId>
      <ramdiskId>ari-1a2b3c4d</ramdiskId>
      <imageOwnerAlias>amazon</imageOwnerAlias>
      <imageOwnerId>123456789012</imageOwnerId>
      <name>getting-started</name>
      <description>Image Description</description>
      <rootDeviceType>ebs</rootDeviceType>
      <rootDeviceName>/dev/sda</rootDeviceName>
      <blockDeviceMapping>
        <item>
          <deviceName>/dev/sda1</deviceName>
          <ebs>
            <snapshotId>snap-1234567890abcdef0</snapshotId>
            <volumeSize>15</volumeSize>
            <deleteOnTermination>false</deleteOnTermination>
            <volumeType>standard</volumeType>
          </ebs>
        </item>
      </blockDeviceMapping>
      <virtualizationType>paravirtual</virtualizationType>
      <tagSet/>
      <hypervisor>xen</hypervisor>
    </item>
  </imagesSet>
</DescribeImagesResponse>";

            var response = Ec2Serializer <DescribeImagesResponse> .Deserialize(text);

            Assert.Single(response.Images);

            var image = response.Images[0];

            Assert.Equal(123456789012, image.ImageOwnerId);
            Assert.Equal("ami-1a2b3c4d", image.ImageId);
            Assert.Equal("i386", image.Architecture);
            Assert.Equal("aki-1a2b3c4d", image.KernelId);
            Assert.Equal("Image Description", image.Description);
            Assert.Equal("paravirtual", image.VirtualizationType);
            Assert.Equal("xen", image.Hypervisor);
            Assert.True(image.IsPublic);
        }
Ejemplo n.º 3
0
        public void Deserialize()
        {
            var text =
                @"<DescribeSubnetsResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
  <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
  <subnetSet>
    <item>
      <subnetId>subnet-9d4a7b6c</subnetId>
      <state>available</state>
      <vpcId>vpc-1a2b3c4d</vpcId>
      <cidrBlock>10.0.1.0/24</cidrBlock>
      <ipv6CidrBlockAssociationSet>
        <item>
          <ipv6CidrBlock>2001:db8:1234:1a00::/64</ipv6CidrBlock>
          <associationId>subnet-cidr-assoc-abababab</associationId>
          <ipv6CidrBlockState>
             <state>ASSOCIATED</state>
          </ipv6CidrBlockState>
         </item>
     </ipv6CidrBlockAssociationSet>
      <availableIpAddressCount>251</availableIpAddressCount>
      <availabilityZone>us-east-1a</availabilityZone>
      <defaultForAz>false</defaultForAz>
      <mapPublicIpOnLaunch>false</mapPublicIpOnLaunch>
      <tagSet/>
      <assignIpv6AddressOnCreation>false</assignIpv6AddressOnCreation>
    </item>
    <item>
      <subnetId>subnet-6e7f829e</subnetId>
      <state>available</state>
      <vpcId>vpc-1a2b3c4d></vpcId>
      <cidrBlock>10.0.0.0/24</cidrBlock>
      <ipv6CidrBlockAssociationSet/> 
      <availableIpAddressCount>251</availableIpAddressCount>
      <availabilityZone>us-east-1a</availabilityZone>
      <defaultForAz>false</defaultForAz>
      <mapPublicIpOnLaunch>false</mapPublicIpOnLaunch>
      <assignIpv6AddressOnCreation>false</assignIpv6AddressOnCreation>
    </item>
  </subnetSet>
</DescribeSubnetsResponse>";

            var response = Ec2Serializer <DescribeSubnetsResponse> .Deserialize(text);

            Assert.Equal(2, response.Subnets.Length);

            var subnet = response.Subnets[0];

            Assert.Equal("subnet-9d4a7b6c", subnet.SubnetId);
            Assert.Equal("vpc-1a2b3c4d", subnet.VpcId);
        }
Ejemplo n.º 4
0
        public void X()
        {
            var text =
                @"<DescribeVolumesResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
   <requestId>59dbff89-35bd-4eac-99ed-be587EXAMPLE</requestId> 
   <volumeSet>
      <item>
         <volumeId>vol-1234567890abcdef0</volumeId>
         <size>80</size>
         <snapshotId/>
         <availabilityZone>us-east-1a</availabilityZone>
         <status>in-use</status>
         <createTime>2016-01-05T03:15:30Z</createTime>
         <attachmentSet>
            <item>
               <volumeId>vol-1234567890abcdef0</volumeId>
               <instanceId>i-1234567890abcdef0</instanceId>
               <device>/dev/sdh</device>
               <status>attached</status>
               <attachTime>2016-01-05T03:15:30Z</attachTime>
               <deleteOnTermination>false</deleteOnTermination>
            </item>
         </attachmentSet>
         <volumeType>standard</volumeType>
         <encrypted>true</encrypted>
      </item>
   </volumeSet>
</DescribeVolumesResponse>";

            var response = Ec2Serializer <DescribeVolumesResponse> .Deserialize(text);

            Assert.Single(response.Volumes);

            var volume = response.Volumes[0];
            var date   = DateTime.Parse("2016-01-05T03:15:30Z", null, DateTimeStyles.AdjustToUniversal);

            Assert.Equal(date, volume.CreateTime);
            Assert.Equal("vol-1234567890abcdef0", volume.VolumeId);
            Assert.Equal("us-east-1a", volume.AvailabilityZone);
            Assert.Equal("in-use", volume.Status);
            Assert.Equal(80, volume.Size);
            Assert.Equal("standard", volume.VolumeType);

            var a1 = volume.Attachments[0];

            Assert.Equal("i-1234567890abcdef0", a1.InstanceId);
            Assert.Equal(date, a1.AttachTime);

            Assert.Single(volume.Attachments);
        }
Ejemplo n.º 5
0
        public void Deserialize()
        {
            var text =

                @"<DescribeVpcsResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
  <requestId>7a62c49f-347e-4fc4-9331-6e8eEXAMPLE</requestId>
  <vpcSet>
    <item>
      <vpcId>vpc-1a2b3c4d</vpcId>
      <state>available</state>
      <cidrBlock>10.0.0.0/23</cidrBlock>
      <ipv6CidrBlockAssociationSet>
        <item>
          <ipv6CidrBlock>2001:db8:1234:1a00::/56</ipv6CidrBlock>
          <associationId>vpc-cidr-assoc-abababab</associationId>
          <ipv6CidrBlockState>
             <state>ASSOCIATED</state>
          </ipv6CidrBlockState>
        </item>
      </ipv6CidrBlockAssociationSet>    
      <dhcpOptionsId>dopt-7a8b9c2d</dhcpOptionsId> 
      <instanceTenancy>default</instanceTenancy>
      <isDefault>false</isDefault>
      <tagSet/>
    </item>
  </vpcSet>
</DescribeVpcsResponse>";

            var response = Ec2Serializer <DescribeVpcsResponse> .Deserialize(text);

            Assert.Single(response.Vpcs);

            var vpc = response.Vpcs[0];

            Assert.Equal("vpc-1a2b3c4d", vpc.VpcId);
            Assert.Equal("available", vpc.State);
            Assert.Equal("10.0.0.0/23", vpc.CidrBlock);
            Assert.Equal("default", vpc.InstanceTenancy);
            Assert.Equal("dopt-7a8b9c2d", vpc.DhcpOptionsId);
            Assert.False(vpc.IsDefault);

            Assert.Equal("2001:db8:1234:1a00::/56", vpc.Ipv6CidrBlockAssociations[0].Ipv6CidrBlock);
        }
Ejemplo n.º 6
0
        public void CanParse()
        {
            var text =
                @"<DescribeSecurityGroupsResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
    <requestId>1d62eae0-acdd-481d-88c9-example</requestId>
    <securityGroupInfo>
        <item>
            <ownerId>123456789012</ownerId>
            <groupId>sg-9bf6ceff</groupId>
            <groupName>SSHAccess</groupName>
            <groupDescription>Security group for SSH access</groupDescription>
            <vpcId>vpc-31896b55</vpcId>
            <ipPermissions>
                <item>
                    <ipProtocol>tcp</ipProtocol>
                    <fromPort>22</fromPort>
                    <toPort>22</toPort>
                    <groups/>
                    <ipRanges>
                        <item>
                            <cidrIp>0.0.0.0/0</cidrIp>
                        </item>
                    </ipRanges>
                    <ipv6Ranges>
                        <item>
                            <cidrIpv6>::/0</cidrIpv6>
                        </item>
                    </ipv6Ranges>
                    <prefixListIds/>
                </item>
            </ipPermissions>
            <ipPermissionsEgress>
                <item>
                    <ipProtocol>-1</ipProtocol>
                    <groups/>
                    <ipRanges>
                        <item>
                            <cidrIp>0.0.0.0/0</cidrIp>
                        </item>
                    </ipRanges>
                    <ipv6Ranges>
                        <item>
                            <cidrIpv6>::/0</cidrIpv6>
                        </item>
                    </ipv6Ranges>
                    <prefixListIds/>
                </item>
            </ipPermissionsEgress>
        </item>
    </securityGroupInfo>
</DescribeSecurityGroupsResponse>";

            var response = Ec2Serializer <DescribeSecurityGroupsResponse> .Deserialize(text);


            Assert.Single(response.SecurityGroups);

            var group = response.SecurityGroups[0];

            Assert.Equal(123456789012L, group.OwnerId);
            Assert.Equal("sg-9bf6ceff", group.GroupId);
            Assert.Equal("SSHAccess", group.GroupName);
            Assert.Equal("Security group for SSH access", group.GroupDescription);

            Assert.Single(group.IpPermissions);
            Assert.Single(group.IpPermissionsEgress);
        }
        public void X()
        {
            var text =
                @"<DescribeNetworkInterfacesResponse xmlns=""http://ec2.amazonaws.com/doc/2016-11-15/"">
    <requestId>fc45294c-006b-457b-bab9-012f5b3b0e40</requestId>
    <networkInterfaceSet>
       <item>
         <networkInterfaceId>eni-0f62d866</networkInterfaceId>
         <subnetId>subnet-c53c87ac</subnetId>
         <vpcId>vpc-cc3c87a5</vpcId>
         <availabilityZone>api-southeast-1b</availabilityZone>
         <description/>
         <ownerId>053230519467</ownerId>
         <requesterManaged>false</requesterManaged>
         <status>in-use</status>
         <macAddress>02:81:60:cb:27:37</macAddress>
         <privateIpAddress>10.0.0.146</privateIpAddress>
         <sourceDestCheck>true</sourceDestCheck>
         <groupSet>
           <item>
             <groupId>sg-3f4b5653</groupId>
             <groupName>default</groupName>
           </item>
         </groupSet>
         <attachment>
           <attachmentId>eni-attach-6537fc0c</attachmentId>
           <instanceId>i-1234567890abcdef0</instanceId>
           <instanceOwnerId>053230519467</instanceOwnerId>
           <deviceIndex>0</deviceIndex>
           <status>attached</status>
           <attachTime>2012-07-01T21:45:27.000Z</attachTime>
           <deleteOnTermination>true</deleteOnTermination>
         </attachment>
         <tagSet/>
         <privateIpAddressesSet>
           <item>
             <privateIpAddress>10.0.0.146</privateIpAddress>
             <primary>true</primary>
           </item>
           <item>
             <privateIpAddress>10.0.0.148</privateIpAddress>
             <primary>false</primary>
           </item>
           <item>
             <privateIpAddress>10.0.0.150</privateIpAddress>
             <primary>false</primary>
           </item>
         </privateIpAddressesSet>
         <ipv6AddressesSet/>
       </item>
       <item>
         <networkInterfaceId>eni-a66ed5cf</networkInterfaceId>
         <subnetId>subnet-cd8a35a4</subnetId>
         <vpcId>vpc-f28a359b</vpcId>
         <availabilityZone>ap-southeast-1b</availabilityZone>
         <description>Primary network interface</description>
         <ownerId>053230519467</ownerId>
         <requesterManaged>false</requesterManaged>
         <status>in-use</status>
         <macAddress>02:78:d7:00:8a:1e</macAddress>
         <privateIpAddress>10.0.1.233</privateIpAddress>
         <sourceDestCheck>true</sourceDestCheck>
         <groupSet>
           <item>
             <groupId>sg-a2a0b2ce</groupId>
             <groupName>quick-start-1</groupName>
           </item>
         </groupSet>
         <attachment>
           <attachmentId>eni-attach-a99c57c0</attachmentId>
           <instanceId>i-0598c7d356eba48d7</instanceId>
           <instanceOwnerId>053230519467</instanceOwnerId>
           <deviceIndex>0</deviceIndex>
           <status>attached</status>
           <attachTime>2012-06-27T20:08:44.000Z</attachTime>
           <deleteOnTermination>true</deleteOnTermination>
         </attachment>
         <tagSet/>
         <privateIpAddressesSet>
           <item>
             <privateIpAddress>10.0.1.233</privateIpAddress>
             <primary>true</primary>
           </item>
           <item>
             <privateIpAddress>10.0.1.20</privateIpAddress>
             <primary>false</primary>
           </item>
         </privateIpAddressesSet>
         <ipv6AddressesSet>
          <item>
            <ipv6Address>2001:db8:1234:1a00::123</ipv6Address>
          </item>
          <item>
            <ipv6Address>2001:db8:1234:1a00::456</ipv6Address>
          </item>
        </ipv6AddressesSet>
       </item>
     </networkInterfaceSet>
</DescribeNetworkInterfacesResponse>";

            var response = Ec2Serializer <DescribeNetworkInterfacesResponse> .Deserialize(text);

            Assert.Equal(2, response.NetworkInterfaces.Length);

            var ni = response.NetworkInterfaces[0];

            Assert.Equal("eni-0f62d866", ni.NetworkInterfaceId);
            Assert.Equal("vpc-cc3c87a5", ni.VpcId);
            Assert.Equal("02:81:60:cb:27:37", ni.MacAddress);

            Assert.Equal("eni-attach-6537fc0c", ni.Attachment.AttachmentId);
            Assert.Equal("i-1234567890abcdef0", ni.Attachment.InstanceId);
            Assert.Equal("attached", ni.Attachment.Status);
            Assert.Equal(0, ni.Attachment.DeviceIndex);
        }