зеркало из https://github.com/Azure/ipam.git
Updated admin api path, reservation tag id, and improved reservation api output
This commit is contained in:
Родитель
28e82c7b36
Коммит
9a83ff82fe
|
@ -1,4 +1,4 @@
|
|||
from pydantic import BaseModel, ValidationError, EmailStr
|
||||
from pydantic import BaseModel, ValidationError, EmailStr, root_validator
|
||||
from typing import Optional, List, Any
|
||||
|
||||
from netaddr import IPSet, IPNetwork, IPAddress
|
||||
|
@ -166,6 +166,13 @@ class Reservation(BaseModel):
|
|||
userId: str
|
||||
createdOn: float
|
||||
status: str
|
||||
tag: Optional[dict]
|
||||
|
||||
@root_validator
|
||||
def format_tag(cls, values) -> dict:
|
||||
values["tag"] = { "X-IPAM-RES-ID": values["id"]}
|
||||
|
||||
return values
|
||||
|
||||
class BlockBasic(BaseModel):
|
||||
"""DOCSTRING"""
|
||||
|
|
|
@ -30,8 +30,8 @@ from app.routers.common.helper import (
|
|||
)
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/admins",
|
||||
tags=["admins"],
|
||||
prefix="/admin",
|
||||
tags=["admin"],
|
||||
dependencies=[Depends(check_token_expired)]
|
||||
)
|
||||
|
||||
|
@ -49,7 +49,7 @@ async def new_admin_db(admin_list, exclusion_list, tenant_id):
|
|||
return query_results
|
||||
|
||||
@router.get(
|
||||
"",
|
||||
"/admins",
|
||||
summary = "Get All Admins",
|
||||
response_model = List[Admin],
|
||||
status_code = 200
|
||||
|
@ -75,7 +75,7 @@ async def get_admins(
|
|||
return []
|
||||
|
||||
@router.post(
|
||||
"",
|
||||
"/admins",
|
||||
summary = "Create IPAM Admin",
|
||||
status_code=201
|
||||
)
|
||||
|
@ -118,7 +118,7 @@ async def create_admin(
|
|||
return Response(status_code=status.HTTP_201_CREATED)
|
||||
|
||||
@router.put(
|
||||
"",
|
||||
"/admins",
|
||||
summary = "Replace IPAM Admins",
|
||||
status_code=200
|
||||
)
|
||||
|
@ -163,7 +163,7 @@ async def update_admins(
|
|||
return PlainTextResponse(status_code=status.HTTP_200_OK)
|
||||
|
||||
@router.delete(
|
||||
"/{objectId}",
|
||||
"/admins/{objectId}",
|
||||
summary = "Delete IPAM Admin",
|
||||
status_code=200
|
||||
)
|
||||
|
|
|
@ -48,7 +48,7 @@ VNET="""
|
|||
resources
|
||||
| where type =~ 'Microsoft.Network/virtualNetworks'
|
||||
| where subscriptionId !in~ {}
|
||||
| project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = properties.addressSpace.addressPrefixes, resv = tostring(tags["ipam-res-id"])
|
||||
| project name, id, resource_group = resourceGroup, subscription_id = subscriptionId, tenant_id = tenantId, prefixes = properties.addressSpace.addressPrefixes, resv = tostring(coalesce(tags['X-IPAM-RES-ID'], tags['ipam-res-id']))
|
||||
| join kind = leftouter(
|
||||
resources
|
||||
| where type =~ 'Microsoft.Network/virtualNetworks'
|
||||
|
|
|
@ -358,7 +358,7 @@ export function fetchTreeView(token) {
|
|||
}
|
||||
|
||||
export function getAdmins(token) {
|
||||
const url = new URL(`${ENGINE_URL}/api/admins`);
|
||||
const url = new URL(`${ENGINE_URL}/api/admin/admins`);
|
||||
|
||||
return axios
|
||||
.get(url, {
|
||||
|
@ -375,7 +375,7 @@ export function getAdmins(token) {
|
|||
}
|
||||
|
||||
export function replaceAdmins(token, body) {
|
||||
const url = new URL(`${ENGINE_URL}/api/admins`);
|
||||
const url = new URL(`${ENGINE_URL}/api/admin/admins`);
|
||||
|
||||
return axios
|
||||
.put(url, body, {
|
||||
|
@ -392,7 +392,7 @@ export function replaceAdmins(token, body) {
|
|||
}
|
||||
|
||||
export function getExclusions(token) {
|
||||
const url = new URL(`${ENGINE_URL}/api/admins/exclusions`);
|
||||
const url = new URL(`${ENGINE_URL}/api/admin/exclusions`);
|
||||
|
||||
return axios
|
||||
.get(url, {
|
||||
|
@ -409,7 +409,7 @@ export function getExclusions(token) {
|
|||
}
|
||||
|
||||
export function replaceExclusions(token, body) {
|
||||
const url = new URL(`${ENGINE_URL}/api/admins/exclusions`);
|
||||
const url = new URL(`${ENGINE_URL}/api/admin/exclusions`);
|
||||
|
||||
return axios
|
||||
.put(url, body, {
|
||||
|
|
Загрузка…
Ссылка в новой задаче