/// <summary>Updates compute resource properties of a Server </summary> /// <param name="reconfigureServer">Details of the server to be updated</param> /// <returns> A standard CaaS response </returns> public async Task <ResponseType> ReconfigureServer(ReconfigureServerType reconfigureServer) { return(await _apiClient.PostAsync <ReconfigureServerType, ResponseType>( ApiUris.ReconfigureServer(_apiClient.OrganizationId), reconfigureServer)); }
/// <summary>Deploys a server to MCP1.0 or MCP 2.0 data centers </summary> /// <param name="serverDetails">Details of the server to be deployed</param> /// <returns>Response containing the server id</returns> public async Task <ResponseType> DeployServer(DeployServerType serverDetails) { return(await _apiClient.PostAsync <DeployServerType, ResponseType>( ApiUris.DeployMCP20Server(_apiClient.OrganizationId), serverDetails)); }
/// <summary>Edit metadata of the server</summary> /// <param name="editServerMetadata">Server metadata change model.</param> /// <returns>The async type of <see cref="ResponseType"/></returns> public async Task <ResponseType> EditServerMetadata(editServerMetadata editServerMetadata) { return(await _apiClient.PostAsync <editServerMetadata, ResponseType>(ApiUris.EditServerMetadata(_apiClient.OrganizationId), editServerMetadata)); }
public void ReturnsDeletePoolMemberUri() { var uri = ApiUris.DeletePoolMember(_orgId); Assert.AreEqual(ApiUris.MCP2_10_PREFIX + _orgId + "/networkDomainVip/removePoolMember", uri.OriginalString); }
/// <summary> /// Get SSL Certificate Chain for given Id. /// </summary> /// <param name="sslCertificateChainId">The SSL Certificate Chain Id</param> /// <returns>The SSL Certificate Chain <see cref="SslCertificateChainType"/></returns> public async Task <SslCertificateChainType> GetSslCertificateChain(Guid sslCertificateChainId) { return(await _apiClient.GetAsync <SslCertificateChainType>( ApiUris.GetSslCertificateChain(_apiClient.OrganizationId, sslCertificateChainId))); }
/// <summary>The get mcp 2 deployed server.</summary> /// <param name="serverId">The server id.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task <ServerType> GetServer(Guid serverId) { return(await _apiClient.GetAsync <ServerType>(ApiUris.GetMcp2Server(_apiClient.OrganizationId, serverId))); }
/// <summary> /// Creates a new ACL rule at a specified line using your organization ID and the ID of the target network. /// It is possible to create both inbound (OUTSIDE_ACL) and outbound (INSIDE_ACL) rule types. /// </summary> /// <param name="client">The <see cref="ComputeApiClient"/> object.</param> /// <param name="networkId">The target network id.</param> /// <param name="aclRuleName">The name of the ACL rule.</param> /// <param name="position">The position of the rule between 100-500 inclusive.</param> /// <param name="action">The action (Permit/deny) of the ACL rule.</param> /// <param name="protocol">The protocol to use (IP, ICMP, TCP, UDP).</param> /// <param name="portRangeType">The port range type (ALL, EQUAL_TO, RANGE, GREATER_THAN, LESS_THAN).</param> /// <param name="sourceIpAddress"> /// Optional. If no source IP Address is supplied, the assumption is that any source IP address is allowed. /// If a source IP address is supplied without the <paramref name="sourceNetmask"/>, source IP Address represent a single host. /// </param> /// <param name="sourceNetmask"> /// Optional. When specified, the <paramref name="sourceIpAddress"/> must be the CIDR boundary for the network. /// </param> /// <param name="destIpAddress"> /// Optional. If no destination IP Address is supplied, the assumption is that any destination IP address is allowed. /// If a destination IP address is supplied without the <paramref name="destNetmask"/>, source IP Address represent a single host. /// </param> /// <param name="destNetmask"> /// Optional. When specified, the <paramref name="destIpAddress"/> must be the CIDR boundary for the network. /// </param> /// <param name="port1">Optional depending on <paramref name="portRangeType"/>. Value within a range of 1-65535.</param> /// <param name="port2">Optional depending on <paramref name="portRangeType"/>. Value within a range of 1-65535.</param> /// <param name="aclType">Optional. One of (OUTSIDE_ACL, INSIDE_ACL). Default if not specified is OUTSIDE_ACL.</param> /// <returns>The ACL rules.</returns> public static async Task <AclRuleType> CreateAclRuleAsync( this IComputeApiClient client, string networkId, string aclRuleName, int position, AclActionType action, AclProtocolType protocol, PortRangeTypeType portRangeType, IPAddress sourceIpAddress = null, IPAddress sourceNetmask = null, IPAddress destIpAddress = null, IPAddress destNetmask = null, int port1 = 0, int port2 = 0, AclType aclType = AclType.OUTSIDE_ACL) { if (string.IsNullOrWhiteSpace(networkId)) { throw new ArgumentException("argument cannot be null, empty or composed of whitespaces only!", "networkId"); } if (string.IsNullOrWhiteSpace(aclRuleName)) { throw new ArgumentException("argument cannot be null, empty or composed of whitespaces only!", "aclRuleName"); } if (aclRuleName.Length >= 60) { throw new ArgumentException("ACL rule name cannot exceed 60 chars", "aclRuleName"); } if (position < 100 || position > 500) { throw new ArgumentException("Position must be between 100 and 500 inclusive", "position"); } if (aclType != AclType.INSIDE_ACL && aclType != AclType.OUTSIDE_ACL) { throw new ArgumentException("ACL Type must be one of (OUTSIDE_ACL, INSIDE_ACL)", "aclType"); } var portRange = new PortRangeType { type = portRangeType }; // Validate that the ports are specified when needed switch (portRangeType) { case PortRangeTypeType.EQUAL_TO: case PortRangeTypeType.GREATER_THAN: case PortRangeTypeType.LESS_THAN: { if (port1 < 1 || port1 > 65535) { throw new ArgumentOutOfRangeException( "port1", port1, string.Format( "Port1 must be between 1-65535 when the port range type is {0}", portRangeType)); } portRange.port1 = port1; portRange.port1Specified = true; break; } case PortRangeTypeType.RANGE: { if (port1 < 1 || port1 > 65535) { throw new ArgumentOutOfRangeException( "port1", port1, string.Format( "Port1 must be between 1-65535 when the port range type is {0}", portRangeType)); } if (port2 < 1 || port2 > 65535) { throw new ArgumentOutOfRangeException( "port2", port2, string.Format( "Port2 must be between 1-65535 when the port range type is {0}", portRangeType)); } portRange.port1 = port1; portRange.port2 = port2; portRange.port1Specified = portRange.port2Specified = true; break; } } // create the acl rule object var rule = new AclRuleType { name = aclRuleName, action = action, position = position, protocol = protocol.ToString(), portRange = portRange, type = aclType }; if (sourceIpAddress != null) { rule.sourceIpRange = new IpRangeType { ipAddress = sourceIpAddress.ToString() }; if (sourceNetmask != null) { rule.sourceIpRange.netmask = sourceNetmask.ToString(); } } if (destIpAddress != null) { rule.destinationIpRange = new IpRangeType { ipAddress = destIpAddress.ToString() }; if (destNetmask != null) { rule.destinationIpRange.netmask = destNetmask.ToString(); } } return (await client.WebApi.ApiPostAsync <AclRuleType, AclRuleType>( ApiUris.CreateAclRule(client.Account.OrganizationId, networkId), rule)); }
public void ReturnsEditVipNodeUri() { var uri = ApiUris.EditVipNode(_orgId); Assert.AreEqual(ApiUris.MCP2_7_PREFIX + _orgId + "/networkDomainVip/editNode", uri.OriginalString); }
public void ReturnsDeleteNatRuleUri() { var uri = ApiUris.DeleteNatRule(_orgId); Assert.AreEqual(ApiUris.MCP2_7_PREFIX + _orgId + "/network/deleteNatRule", uri.OriginalString); }
/// <summary> /// This function deploys a new network domains to Cloud /// </summary> /// <param name="client"> /// The client. /// </param> /// <param name="server"> /// The network Domain. /// </param> /// <returns> /// Response containing status. /// </returns> public static async Task <ResponseType> DeployServerOnNetworkDomain(this IComputeApiClient client, DeployServerType server) { var response = await client.WebApi.PostAsync <DeployServerType, ResponseType>(ApiUris.DeployServerOnNetworkDomain(client.WebApi.OrganizationId), server); return(response); }
/// <summary> /// An IComputeApiClient extension method that adds a NIC to server to 'addNic'. /// </summary> /// <remarks> Anthony, 4/24/2015. </remarks> /// <param name="client"> The compute client. </param> /// <param name="addNic"> The add NIC. </param> /// <returns> A standard response. </returns> public static async Task <ResponseType> AddNicToServer(this IComputeApiClient client, AddNicType addNic) { return (await client.WebApi.PostAsync <AddNicType, ResponseType>(ApiUris.AddNic(client.WebApi.OrganizationId), addNic)); }
/// <summary>The unreserve ipv 6 address.</summary> /// <param name="unreserveIpv6Address">The unreserve ipv 6 address.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task <ResponseType> UnreserveIpv6Address(UnreserveIpv6AddressType unreserveIpv6Address) { return(await _apiClient.PostAsync <UnreserveIpv6AddressType, ResponseType>(ApiUris.UnreserveIpv6Address(_apiClient.OrganizationId), unreserveIpv6Address)); }
/// <summary>The reserve private ipv 4 address.</summary> /// <param name="reservePrivateIpv4Address">The reserve private ipv 4 address.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task <ResponseType> ReservePrivateIpv4Address(ReservePrivateIpv4AddressType reservePrivateIpv4Address) { return(await _apiClient.PostAsync <ReservePrivateIpv4AddressType, ResponseType>(ApiUris.ReservePrivateIpv4Address(_apiClient.OrganizationId), reservePrivateIpv4Address)); }
public ApiUrisTests() { _apiUris = new ApiUris( new Uri("https://api.unsplash.com/") ); }
/// <summary>The add disk.</summary> /// <param name="addDisk">The add disk.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task <ResponseType> AddDisk(AddDiskType addDisk) { return(await _apiClient.PostAsync <AddDiskType, ResponseType>(ApiUris.AddDisk(_apiClient.OrganizationId), addDisk)); }
public void ReturnsDeletePoolUri() { var uri = ApiUris.DeletePool(_orgId); Assert.AreEqual(ApiUris.MCP2_7_PREFIX + _orgId + "/networkDomainVip/deletePool", uri.OriginalString); }
/// <summary>The remove disk.</summary> /// <param name="removeDisk">The remove disk.</param> /// <returns>The <see cref="Task"/>.</returns> public async Task <ResponseType> RemoveDisk(RemoveDiskType removeDisk) { return(await _apiClient.PostAsync <RemoveDiskType, ResponseType>(ApiUris.RemoveDisk(_apiClient.OrganizationId), removeDisk)); }
public void ReturnsGetPoolMembersUri() { var uri = ApiUris.GetPoolMembers(_orgId); Assert.AreEqual(ApiUris.MCP2_7_PREFIX + _orgId + "/networkDomainVip/poolMember", uri.OriginalString); }
/// <summary> Deletes the server described by serverId. </summary> /// <param name="serverId"> The server id. </param> /// <returns> A standard CaaS response. </returns> /// <seealso cref="M:DD.CBU.Compute.Api.Client.Interfaces.Server20.IServerAccessor.DeleteServer(Guid)"/> public async Task <ResponseType> DeleteServer(Guid serverId) { return(await _apiClient.PostAsync <DeleteServerType, ResponseType>(ApiUris.DeleteServer(_apiClient.OrganizationId), new DeleteServerType { id = serverId.ToString() })); }
/// <summary> Updates the v mware tools described by serverId. </summary> /// <param name="serverId"> The server id. </param> /// <returns> A standard CaaS response. </returns> /// <seealso cref="M:DD.CBU.Compute.Api.Client.Interfaces.Server20.IServerAccessor.UpdateVmwareTools(Guid)"/> public async Task <ResponseType> UpdateVmwareTools(Guid serverId) { return(await _apiClient.PostAsync <UpdateVmwareToolsServerType, ResponseType>(ApiUris.UpdateVmwareTools(_apiClient.OrganizationId), new UpdateVmwareToolsServerType { id = serverId.ToString() })); }
/// <summary> /// Gets the networks with locations /// </summary> /// <param name="client">The <see cref="IComputeApiClient"/> object.</param> /// <returns>The networks</returns> public static async Task <IEnumerable <NetworkWithLocationsNetwork> > GetNetworksAsync(this IComputeApiClient client) { var networks = await client.WebApi.ApiGetAsync <NetworkWithLocations>(ApiUris.NetworkWithLocations(client.Account.OrganizationId)); return(networks.Items); }
/// <summary> Upgrade virtual hardware for the server. </summary> /// <param name="serverId"> The server id. </param> /// <returns> A standard CaaS response. </returns> public async Task <ResponseType> UpgradeVirtualHardware(Guid serverId) { return(await _apiClient.PostAsync <UpgradeVirtualHardware, ResponseType>(ApiUris.UpgradeVirtualHardware(_apiClient.OrganizationId), new UpgradeVirtualHardware { id = serverId.ToString() })); }
public void ReturnsAddVipNodeUri() { var uri = ApiUris.AddVipNode(_orgId); Assert.AreEqual(ApiUris.MCP2_10_PREFIX + _orgId + "/networkDomainVip/createNode", uri.OriginalString); }
/// <summary> /// Get SSL Offload Profile for given Id. /// </summary> /// <param name="sslOffloadProfileId">The SSL Offload Profile Id</param> /// <returns>The SSL Offload Profile/></returns> public async Task <SslOffloadProfileType> GetSslOffloadProfile(Guid sslOffloadProfileId) { return(await _apiClient.GetAsync <SslOffloadProfileType>( ApiUris.GetSslSslOffloadProfile(_apiClient.OrganizationId, sslOffloadProfileId))); }