Here are the examples of the csharp api System.Collections.Generic.List.Add(serverInstance) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
7 Examples
19
View Source File : ServerOperation.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
public static async Task<List<serverInstance>> GetServerInstanceList(List<string> instanceNoList)
{
try
{
DataManager dataManager = DataManager.Instance;
List<serverInstance> serverInstances = new List<serverInstance>();
string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
string action = @"/server/v2/getServerInstanceList";
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));
int i = 0;
foreach (var instanceNo in instanceNoList)
{
i++;
string serverInstanceNoListKey = "serverInstanceNoList." + i;
string serverInstanceNoListValue = instanceNo;
parameters.Add(new KeyValuePair<string, string>(serverInstanceNoListKey, serverInstanceNoListValue));
}
SoaCall soaCall = new SoaCall();
var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
string response = await task;
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
else
{
getServerInstanceList getServerInstanceList = JsonConvert.DeserializeObject<getServerInstanceList>(response, options);
if (getServerInstanceList.getServerInstanceListResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in getServerInstanceList.getServerInstanceListResponse.serverInstanceList)
{
//var item = new serverInstance
//{
// serverInstanceNo = a.serverInstanceNo,
// serverName = a.serverName,
// publicIp = a.publicIp,
// privateIp = a.privateIp,
// serverInstanceStatus = a.serverInstanceStatus,
// serverInstanceOperation = a.serverInstanceOperation
//};
//serverInstances.Add(item);
serverInstances.Add(a);
}
if (getServerInstanceList.getServerInstanceListResponse.totalRows == 0)
{
throw new Exception("server not founds");
}
}
return serverInstances;
}
}
catch (Exception)
{
throw;
}
}
19
View Source File : UcCreateServer.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
private async Task ServerNameCheck(bool message = true)
{
try
{
if (textBoxServerName.Text.Length < 3)
throw new Exception("check server name first");
List<serverInstance> serverInstances = new List<serverInstance>();
string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
string action = @"/server/v2/getServerInstanceList";
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));
parameters.Add(new KeyValuePair<string, string>("searchFilterName", "serverName"));
parameters.Add(new KeyValuePair<string, string>("searchFilterValue", textBoxServerName.Text.Trim()));
SoaCall soaCall = new SoaCall();
var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
string response = await task;
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
else
{
getServerInstanceList getServerInstanceList = JsonConvert.DeserializeObject<getServerInstanceList>(response, options);
if (getServerInstanceList.getServerInstanceListResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in getServerInstanceList.getServerInstanceListResponse.serverInstanceList)
{
var item = new serverInstance
{
serverInstanceNo = a.serverInstanceNo,
serverName = a.serverName,
publicIp = a.publicIp,
privateIp = a.privateIp,
serverInstanceStatus = new codeCodeName
{
code = a.serverInstanceStatus.code,
codeName = a.serverInstanceStatus.codeName
},
serverInstanceOperation = new codeCodeName
{
code = a.serverInstanceOperation.code,
codeName = a.serverInstanceOperation.codeName
}
};
serverInstances.Add(item);
}
if (getServerInstanceList.getServerInstanceListResponse.totalRows == 0)
{
CheckedServer = new serverInstance();
if (message)
MessageBox.Show("You can use the name as the server name.");
}
else
{
bool matched = false;
foreach (var a in serverInstances)
{
if (a.serverName.Equals(textBoxServerName.Text.Trim(), StringComparison.OrdinalIgnoreCase))
{
matched = true;
CheckedServer = a;
if (message)
MessageBox.Show($"You have a server with that name. serverInstanceNo : {CheckedServer.serverInstanceNo}");
}
}
if (!matched)
if (message)
MessageBox.Show("You can use the name as the server name.");
}
}
}
}
catch (Exception)
{
throw;
}
}
19
View Source File : UcCreateServer.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
private async Task ResponseFileDbSave(string response)
{
try
{
List<serverInstance> serverInstances = new List<serverInstance>();
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
else
{
createServerInstances createServerInstances = JsonConvert.DeserializeObject<createServerInstances>(response, options);
if (createServerInstances.createServerInstancesResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in createServerInstances.createServerInstancesResponse.serverInstanceList)
{
var item = new serverInstance
{
serverName = a.serverName,
serverInstanceNo = a.serverInstanceNo,
publicIp = a.publicIp,
privateIp = a.privateIp,
region = new region
{
regionNo = a.region.regionNo,
regionCode = a.region.regionCode,
regionName = a.region.regionName
},
zone = new zone
{
zoneNo = a.zone.zoneNo,
zoneName = a.zone.zoneName,
zoneCode = a.zone.zoneCode,
zoneDescription = a.zone.zoneDescription,
regionNo = a.zone.regionNo
},
serverImageProductCode = a.serverImageProductCode,
serverProductCode = a.serverProductCode,
feeSystemTypeCode = "FXSUM",
loginKeyName = a.loginKeyName,
// where is acg list ?
};
serverInstances.Add(item);
}
if (createServerInstances.createServerInstancesResponse.totalRows == 0)
{
CheckedServer = new serverInstance();
new Exception ("createServerInstances response error.");
}
else
{
foreach (var a in serverInstances)
{
var p = new List<KeyValuePair<string, string>>();
p.Add(new KeyValuePair<string, string>("serverName", a.serverName));
p.Add(new KeyValuePair<string, string>("serverInstanceNo", a.serverInstanceNo));
p.Add(new KeyValuePair<string, string>("serverPublicIp", a.publicIp));
p.Add(new KeyValuePair<string, string>("serverPrivateIp", a.privateIp));
p.Add(new KeyValuePair<string, string>("regionNo", a.region.regionNo));
p.Add(new KeyValuePair<string, string>("zoneNo", a.zone.zoneNo));
p.Add(new KeyValuePair<string, string>("serverImageProductCode", a.serverImageProductCode));
p.Add(new KeyValuePair<string, string>("serverProductCode", a.serverProductCode));
p.Add(new KeyValuePair<string, string>("feeSystemTypeCode", a.feeSystemTypeCode));
p.Add(new KeyValuePair<string, string>("loginKeyName", a.loginKeyName));
if (comboBoxACG1.Text.Equals(""))
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_1", "NULL"));
else
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_1", (comboBoxACG1.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo));
if (comboBoxACG2.Text.Equals(""))
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_2", "NULL"));
else
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_2", (comboBoxACG2.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo));
if (comboBoxACG3.Text.Equals(""))
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_3", "NULL"));
else
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_3", (comboBoxACG3.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo));
if (comboBoxACG4.Text.Equals(""))
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_4", "NULL"));
else
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_4", (comboBoxACG4.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo));
if (comboBoxACG5.Text.Equals(""))
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_5", "NULL"));
else
p.Add(new KeyValuePair<string, string>("accessControlGroupConfigurationNoList_5", (comboBoxACG5.SelectedItem as accessControlGroup).accessControlGroupConfigurationNo));
await fileDb.UpSertTable(FileDb.TableName.TBL_SERVER, p);
}
}
}
}
}
catch (Exception)
{
throw;
}
}
19
View Source File : UcPublicIp.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
private async Task StopServerInstances(List<string> instanceNoList)
{
try
{
string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
string action = @"/server/v2/stopServerInstances";
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));
int i = 0;
foreach (var instanceNo in instanceNoList)
{
i++;
string serverInstanceNoListKey = "serverInstanceNoList." + i;
string serverInstanceNoListValue = instanceNo;
parameters.Add(new KeyValuePair<string, string>(serverInstanceNoListKey, serverInstanceNoListValue));
}
SoaCall soaCall = new SoaCall();
var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
string response = await task;
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
stopServerInstances stopServerInstances = JsonConvert.DeserializeObject<stopServerInstances>(response, options);
if (stopServerInstances.stopServerInstancesResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in stopServerInstances.stopServerInstancesResponse.serverInstanceList)
{
var item = new serverInstance
{
serverInstanceNo = a.serverInstanceNo,
serverName = a.serverName,
publicIp = a.publicIp,
privateIp = a.privateIp,
serverInstanceStatus = a.serverInstanceStatus,
serverInstanceOperation = a.serverInstanceOperation
};
serverInstances.Add(item);
}
if (stopServerInstances.stopServerInstancesResponse.totalRows == 0)
{
MessageBox.Show("server not founds");
}
}
}
catch (Exception)
{
throw;
}
}
19
View Source File : UcPublicIp.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
private async Task TerminateServerInstances(List<string> instanceNoList)
{
try
{
string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
string action = @"/server/v2/terminateServerInstances";
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));
int i = 0;
foreach (var instanceNo in instanceNoList)
{
i++;
string serverInstanceNoListKey = "serverInstanceNoList." + i;
string serverInstanceNoListValue = instanceNo;
parameters.Add(new KeyValuePair<string, string>(serverInstanceNoListKey, serverInstanceNoListValue));
}
SoaCall soaCall = new SoaCall();
var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
string response = await task;
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
terminateServerInstances terminateServerInstances = JsonConvert.DeserializeObject<terminateServerInstances>(response, options);
if (terminateServerInstances.terminateServerInstancesResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in terminateServerInstances.terminateServerInstancesResponse.serverInstanceList)
{
var item = new serverInstance
{
serverInstanceNo = a.serverInstanceNo,
serverName = a.serverName,
publicIp = a.publicIp,
privateIp = a.privateIp,
serverInstanceStatus = a.serverInstanceStatus,
serverInstanceOperation = a.serverInstanceOperation
};
serverInstances.Add(item);
}
if (terminateServerInstances.terminateServerInstancesResponse.totalRows == 0)
{
throw new Exception("server not founds");
}
}
}
catch (Exception)
{
throw;
}
}
19
View Source File : UcPublicIp.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
private async Task StartServerInstances(List<string> instanceNoList)
{
try
{
string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
string action = @"/server/v2/startServerInstances";
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));
int i = 0;
foreach (var instanceNo in instanceNoList)
{
i++;
string serverInstanceNoListKey = "serverInstanceNoList." + i;
string serverInstanceNoListValue = instanceNo;
parameters.Add(new KeyValuePair<string, string>(serverInstanceNoListKey, serverInstanceNoListValue));
}
SoaCall soaCall = new SoaCall();
var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
string response = await task;
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
startServerInstances startServerInstances = JsonConvert.DeserializeObject<startServerInstances>(response, options);
if (startServerInstances.startServerInstancesResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in startServerInstances.startServerInstancesResponse.serverInstanceList)
{
var item = new serverInstance
{
serverInstanceNo = a.serverInstanceNo,
serverName = a.serverName,
publicIp = a.publicIp,
privateIp = a.privateIp,
serverInstanceStatus = a.serverInstanceStatus,
serverInstanceOperation = a.serverInstanceOperation
};
serverInstances.Add(item);
}
if (startServerInstances.startServerInstancesResponse.totalRows == 0)
{
throw new Exception("server not founds");
}
}
}
catch (Exception)
{
throw;
}
}
19
View Source File : UcSetServerDisk.cs
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
License : GNU Lesser General Public License v3.0
Project Creator : NaverCloudPlatform
private async Task GetServerInstanceList(List<string> instanceNoList)
{
try
{
string endpoint = dataManager.GetValue(DataManager.Category.ApiGateway, DataManager.Key.Endpoint);
string action = @"/server/v2/getServerInstanceList";
List<KeyValuePair<string, string>> parameters = new List<KeyValuePair<string, string>>();
parameters.Add(new KeyValuePair<string, string>("responseFormatType", "json"));
int i = 0;
foreach (var instanceNo in instanceNoList)
{
i++;
string serverInstanceNoListKey = "serverInstanceNoList."+i;
string serverInstanceNoListValue = instanceNo;
parameters.Add(new KeyValuePair<string, string>(serverInstanceNoListKey, serverInstanceNoListValue));
}
SoaCall soaCall = new SoaCall();
var task = soaCall.WebApiCall(endpoint, RequestType.POST, action, parameters, LogClient.Config.Instance.GetValue(Category.Api, Key.AccessKey), LogClient.Config.Instance.GetValue(Category.Api, Key.SecretKey));
string response = await task;
JsonSerializerSettings options = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore,
MissingMemberHandling = MissingMemberHandling.Ignore
};
if (response.Contains("responseError"))
{
hasError hasError = JsonConvert.DeserializeObject<hasError>(response, options);
throw new Exception(hasError.responseError.returnMessage);
}
else
{
getServerInstanceList getServerInstanceList = JsonConvert.DeserializeObject<getServerInstanceList>(response, options);
if (getServerInstanceList.getServerInstanceListResponse.returnCode.Equals("0"))
{
serverInstances.Clear();
foreach (var a in getServerInstanceList.getServerInstanceListResponse.serverInstanceList)
{
var item = new serverInstance
{
serverInstanceNo = a.serverInstanceNo,
serverName = a.serverName,
publicIp = a.publicIp,
privateIp = a.privateIp,
serverInstanceStatus = a.serverInstanceStatus,
serverInstanceOperation = a.serverInstanceOperation
};
serverInstances.Add(item);
}
if (getServerInstanceList.getServerInstanceListResponse.totalRows == 0)
{
MessageBox.Show("server not founds");
}
}
}
}
catch (Exception)
{
throw;
}
}