private ServerDensityApi(ServerDensitySettings settings) { _apiKey = settings.ApiKey; _credentials = settings.Credentials; _account = settings.Account; _apiUrl = settings.ApiUrl; _version = settings.Version; Alerts = new AlertsApi(this); Metrics = new MetricsApi(this); }
internal static IServerDensityApi Initialise(ServerDensitySettings settings, IRequestClient requestClient) { if (string.IsNullOrEmpty(settings.ApiKey)) throw new ArgumentException("Api key missing. Api key is required to initialise API"); if (settings.Credentials == null || string.IsNullOrEmpty(settings.Credentials.UserName) || string.IsNullOrEmpty(settings.Credentials.Password)) throw new ArgumentException("Credetials are required for the api calls to function correctly."); if (string.IsNullOrEmpty(settings.Account)) throw new ArgumentException("Account missing. Account is required to initialise API. It will be in the form of [name].serverdensity.com"); return new ServerDensityApi(settings) { RequestClient = requestClient ?? new RequestClient(settings.Credentials) }; }
public static ServerDensitySettings GetFromAppConfig() { var settings = new ServerDensitySettings(); settings.Account = ConfigurationManager.AppSettings["ServerDensity.Account"]; Validate("ServerDensity.Account", settings.Account); settings.ApiKey = ConfigurationManager.AppSettings["ServerDensity.ApiKey"]; Validate("ServerDensity.ApiKey", settings.ApiKey); var username = ConfigurationManager.AppSettings["ServerDensity.Username"]; var password = ConfigurationManager.AppSettings["ServerDensity.Password"]; Validate("ServerDensity.Username", username); Validate("ServerDensity.Password", password); settings.Credentials = new NetworkCredential(username, password); var version = ConfigurationManager.AppSettings["ServerDensity.Version"] ?? "1.4"; settings.Version = version; var apiUrl = ConfigurationManager.AppSettings["ServerDensity.ApiUrl"] ?? "api.serverdensity.com"; settings.ApiUrl = apiUrl; return settings; }
public static ServerDensitySettings GetFromAppConfig() { var settings = new ServerDensitySettings(); settings.Account = ConfigurationManager.AppSettings["ServerDensity.Account"]; Validate("ServerDensity.Account", settings.Account); settings.ApiKey = ConfigurationManager.AppSettings["ServerDensity.ApiKey"]; Validate("ServerDensity.ApiKey", settings.ApiKey); var username = ConfigurationManager.AppSettings["ServerDensity.Username"]; var password = ConfigurationManager.AppSettings["ServerDensity.Password"]; Validate("ServerDensity.Username", username); Validate("ServerDensity.Password", password); settings.Credentials = new NetworkCredential(username, password); var version = ConfigurationManager.AppSettings["ServerDensity.Version"] ?? "1.4"; settings.Version = version; var apiUrl = ConfigurationManager.AppSettings["ServerDensity.ApiUrl"] ?? "api.serverdensity.com"; settings.ApiUrl = apiUrl; return(settings); }
internal static IServerDensityApi Initialise(ServerDensitySettings settings, IRequestClient requestClient) { if (string.IsNullOrEmpty(settings.ApiKey)) { throw new ArgumentException("Api key missing. Api key is required to initialise API"); } if (settings.Credentials == null || string.IsNullOrEmpty(settings.Credentials.UserName) || string.IsNullOrEmpty(settings.Credentials.Password)) { throw new ArgumentException("Credetials are required for the api calls to function correctly."); } if (string.IsNullOrEmpty(settings.Account)) { throw new ArgumentException("Account missing. Account is required to initialise API. It will be in the form of [name].serverdensity.com"); } return(new ServerDensityApi(settings) { RequestClient = requestClient ?? new RequestClient(settings.Credentials) }); }
public static IServerDensityApi Initialise(ServerDensitySettings settings) { return Initialise(settings, null); }
public static IServerDensityApi Initialise(ServerDensitySettings settings) { return(Initialise(settings, null)); }
public static IServerDensityApi Initialise() { return(Initialise(ServerDensitySettings.GetFromAppConfig())); }