Skip to content

Commit

Permalink
[v9.2.x] AzureMonitor: Automate location retrieval (#59810)
Browse files Browse the repository at this point in the history
* AzureMonitor: Automate location retrieval (#59602)

* Automate location retrieval

- Add function to retrieve provider information
- Add function to retrieve subscription locations
- Add parsers for each function
- Add types
- Update resourcePickerData with new functions
- Remove old location metadata file

* Improve types

- Add types for responses
- Use correct name parameter
- Update response parser (parseProvider unnecessary)

* Fix tests

- Add necessary mocks

* Fix logic and ensure maps are consistent

* Add tests

* Review

* Lint issue

(cherry picked from commit c52d4e2)

* Lint issues

Co-authored-by: Andreas Christou <andreas.christou@grafana.com>
  • Loading branch information
grafanabot and aangelisc committed Dec 5, 2022
1 parent 74ec072 commit e7e20a3
Show file tree
Hide file tree
Showing 11 changed files with 274 additions and 373 deletions.
Expand Up @@ -24,6 +24,17 @@ export default function createMockDatasource(overrides?: DeepPartial<Datasource>
supportedTimeGrains: [],
dimensions: [],
}),
getProvider: jest.fn().mockResolvedValueOnce({
namespace: 'Microsoft.Insights',
resourceTypes: [
{ resourceType: 'logs', locations: ['North Europe'], apiVersions: ['2022-11-11'], capabilities: '' },
],
}),
getLocations: jest
.fn()
.mockResolvedValueOnce(
new Map([['northeurope', { displayName: 'North Europe', name: 'northeurope', supportsLogs: false }]])
),
},

getAzureLogAnalyticsWorkspaces: jest.fn().mockResolvedValueOnce([]),
Expand Down
@@ -1,4 +1,5 @@
import { ResourceRowGroup, ResourceRowType } from '../components/ResourcePicker/types';
import { AzureMonitorLocations } from '../types';

export const createMockSubscriptions = (): ResourceRowGroup => [
{
Expand Down Expand Up @@ -117,3 +118,6 @@ export const mockSearchResults = (): ResourceRowGroup => [
location: 'northeurope',
},
];

export const mockGetValidLocations = (): Map<string, AzureMonitorLocations> =>
new Map([['northeurope', { displayName: 'North Europe', name: 'northeurope', supportsLogs: true }]]);
@@ -1,3 +1,2 @@
export * from './locations';
export * from './resourceTypes';
export * from './logsResourceTypes';

This file was deleted.

0 comments on commit e7e20a3

Please sign in to comment.