ipam-api

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

README

Infratographer IP Address Management API

Infratographer IP Address Management implements a GraphQL API that provides a way to manage IP Addresses

IPAM Structure

erDiagram
    NODE ||--o| IPBlockType : "has"
    IPBlockType {
        string Name
        id OwnerID
    }

    IPBlockType ||--o{ IPBlock : "has"
    IPBlock {
        string Prefix
        id BlockTypeID
        id LocationID
        id ParentBlockID
        boolean AllowAutoSubnet
        boolean AllowAutoAllocate
    }

    IPBlock ||--o{ IPAddress : "has"
    IPAddress {
        string IP
        id BlockID
        id NodeID
        id NodeOwnerID
        boolean Reserved
    }

Development and Contributing

Getting Started

To begin start by opening the devcontainer as outlined in the Development Guide

To initialize the database:

  1. go build
  2. ./ipam-api migrate up

To run the api

make go-run

To subscribe to the NATS stream:

# if not created already
nats --server=nats:4222 --creds=/nsc/nkeys/creds/LOCAL/IPAM/USER.creds stream add $NAME --subjects='com.example.>'

nats --server=nats:4222 --creds=/nsc/nkeys/creds/LOCAL/IPAM/USER.creds sub --stream=$NAME

Interacting with the GraphQL queries:

Go to localhost:XXXX/playground

Example GraphQL Queries

Create IP Block Mutation

Input:

mutation{
  createIPBlockType(
    input: {
        name:"super-sweet-ip-block-type",
        ownerID:"tenants-df234a22-f849-11ed-b67e-0242ac120002"
    }
  )
  {
    ip_block_type{
      name,
      id
    }
  }
}

Output:

{
  "data": {
    "createIPBlockType": {
      "ip_block_type": {
        "name": "super-sweet-ip-block-type",
        "id": "ipamibt-9xaBQDAFmLOdceu9zO6Rj"
      }
    }
  }
}
Get IP Block by ID

Input:

query{
  ip_block_type(id:"ipamibt-9xaBQDAFmLOdceu9zO6Rj"){
    name,
    id
  }
}

Output:

{
  "data": {
    "ip_block_type": {
      "name": "super-sweet-ip-block-type",
      "id": "ipamibt-9xaBQDAFmLOdceu9zO6Rj"
    }
  }
}

Code of Conduct

Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

Contact

To contact the maintainers, please open a GithHub Issue

License

Apache 2.0

Documentation

Overview

package main is the entry point

Directories

Path Synopsis
Package cmd is our cobra/viper cli implementation
Package cmd is our cobra/viper cli implementation
Package db provides an embedded filesystem containing all the database migrations
Package db provides an embedded filesystem containing all the database migrations
internal
config
Package config provides a struct to store the applications config
Package config provides a struct to store the applications config
ent/schema
Package schema contains the ent schema definitions for the ipam API.
Package schema contains the ent schema definitions for the ipam API.
ent/schema/validator
Package validator provides methods for validation
Package validator provides methods for validation
graphapi
Package graphapi provides the graph api handler and resolver for ipam api
Package graphapi provides the graph api handler and resolver for ipam api
testclient
Package testclient provides the graph client for interacting with the exampe api.
Package testclient provides the graph client for interacting with the exampe api.
pkg
ipamclient
Package ipamclient provides a client for interacting with the IPAM service
Package ipamclient provides a client for interacting with the IPAM service
ipamclient/internal/mock
Package mock provides mock implementations of the ipam api client
Package mock provides mock implementations of the ipam api client

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL