Starting a Scheme SDK for Equinix Metal
This commit is contained in:
34
metalapi/vlan.scm
Normal file
34
metalapi/vlan.scm
Normal file
@@ -0,0 +1,34 @@
|
||||
(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))
|
||||
Reference in New Issue
Block a user