Files
equinix-scm/src/metalapi/vlan.scm
2024-06-09 15:47:58 -04:00

35 lines
902 B
Scheme

(define-module (metalapi vlan)
#:use-module (metalapi requests)
#:use-module (metalapi project)
#:export (build-vlan
vlan->project
vlan->metro-code
vlan->vxlan
vlan-request-body
list-all-vlans))
(define (build-vlan vlan-alist)
(extract-attrs vlan-alist "id" "description" "vxlan" "metro_code"))
(define (vlan->project vlan)
(project->id (assoc-ref vlan "project")))
(define (vlan->metro-code vlan)
(assoc-ref vlan "metro_code"))
(define (vlan->description vlan)
(assoc-ref vlan "description"))
(define (vlan-request-body vlan)
(scm->json-string
`(("metro" . ,(assoc-ref vlan "metro_code"))
("description" . ,(vlan->description vlan)))))
(define (vlan->vxlan vlan)
(assoc-ref vlan "vxlan"))
(define (list-all-vlans project)
(handle-pagination (format #f "/projects/~a/virtual-networks" (project->id project)) "virtual_networks" build-vlan))