protected void WriteComponentApiKey(ApplicationInsightsComponentAPIKey apiKey) { if (apiKey != null) { WriteObject(new PSApiKey(apiKey)); } }
public ApiKey(ApplicationInsightsComponentAPIKey apiKey) { Name = apiKey.Name; Key = apiKey.ApiKey; Id = GetApiKeyId(apiKey); CreatedDate = apiKey.CreatedDate; }
private static string GetApiKeyId(ApplicationInsightsComponentAPIKey apiKey) { var fullId = apiKey.Id; var pos = fullId.LastIndexOf("/", StringComparison.OrdinalIgnoreCase) + 1; var id = fullId.Substring(pos, fullId.Length - pos); return(id); }
private static void AreEqual(APIKeyRequest request, ApplicationInsightsComponentAPIKey response) { Assert.Equal(request.Name, response.Name, ignoreCase: true); Assert.True(response.LinkedReadProperties.Count >= request.LinkedReadProperties.Count); Assert.True(response.LinkedWriteProperties.Count >= request.LinkedWriteProperties.Count); foreach (var readaccess in request.LinkedReadProperties) { Assert.Contains(response.LinkedReadProperties, r => r == readaccess); } foreach (var writeaccess in request.LinkedWriteProperties) { Assert.Contains(response.LinkedWriteProperties, w => w == writeaccess); } }
public PSApiKey(ApplicationInsightsComponentAPIKey key) { this.ApiKey = key.ApiKey; this.CreatedDate = key.CreatedDate; this.Id = key.Id.Split('/')[10]; this.Description = key.Name; List <string> accessPermission = new List <string>(); ApiKeyRole[] roles = new ApiKeyRole[] { ReadTelemetry, WriteAnnotations, ReadAgentConfiguration }; if (key.LinkedReadProperties != null) { foreach (var readaccess in key.LinkedReadProperties) { var role = ExtraRole(roles, readaccess); if (role != null) { accessPermission.Add(role.roleName); } } } if (key.LinkedWriteProperties != null) { foreach (var writeAccess in key.LinkedWriteProperties) { var role = ExtraRole(roles, writeAccess); if (role != null) { accessPermission.Add(role.roleName); } } } this.Permissions = accessPermission.ToArray(); }
public PSApiKeyTableView(ApplicationInsightsComponentAPIKey key) : base(key) { }