Skip to content

Conversation

@just-be-dev
Copy link
Contributor

@just-be-dev just-be-dev commented Dec 16, 2022

See #2028

This PR adds V1 versions of the developer facing networking APIs. Firewall rules aren't in this PR. I'll do that in a follow up.

New Endpoints

All endpoints here are scoped via query parameters by their parent selectors. So for vpc-subnets if you provide the vpc by name, you'll also need to provide the project. If the projected is specified by name you'll need the org.

So /v1/vpc-subnet?vpc={vpc_id}, /v1/vpc-subnet?vpc={vpc_name}&project={project_id}, etc

# Scoped via  ?project={project}
GET    /v1/vpcs       # List VPCs
POST   /v1/vpcs       # Create a VPC
GET    /v1/vpcs/{vpc} # Get a VPC
DELETE /v1/vpcs/{vpc} # Delete a VPC

# Scoped via  ?vpc={vpc}
GET    /v1/vpc-subnets          # List VPC subnets
POST   /v1/vpc-subnets          # Create a VPC subnet
GET    /v1/vpc-subnets/{subnet} # Get a VPC subnet
DELETE /v1/vpc-subnets/{subnet} # Delete a VPC subnet

# Scoped via  ?vpc={vpc}
GET    /v1/vpc-routers          # List VPCs
POST   /v1/vpc-routers          # Create a VPC
GET    /v1/vpc-routers/{router} # Get a VPC
DELETE /v1/vpc-routers/{router} # Delete a VPC

# Scoped via  ?router={router}
GET    /v1/vpc-router-routes         # List VPC router routes
POST   /v1/vpc-router-routes         # Create a VPC router route
GET    /v1/vpc-router-routes/{route} # Get a VPC router route
DELETE /v1/vpc-router-routes/{route} # Delete a VPC router route

# Scoped via ?instance={instance}
GET    /v1/network-interfaces             # List network interfaces
POST   /v1/network-interfaces             # Create network interface
GET    /v1/network-interfaces/{interface} # Get a network interface
DELETE /v1/network-interfaces/{interface} # Delete network interface

For a quick overview of the entire API (and the changes introduced in this PR) check out the nexus_tags.txt file

Notable changes

  • I pulled app level network interface functions out into their own file.
  • I've slowly started to update the naming convention of app and datastore level functions to be less nested (and closer to the operation names) as per this comment. It's a little bit inconsistent now but the intent is to do a larger follow up to clean these all up. At present I'm just updating them as I come across them.
  • I've begun moving all possible contents of an http entrypoint into its handler for more timing information as per this comment

@just-be-dev just-be-dev marked this pull request as ready for review February 9, 2023 18:30
Comment on lines -1560 to -1577
/// Create-time parameters for a [`RouterRoute`]
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct RouterRouteCreateParams {
#[serde(flatten)]
pub identity: IdentityMetadataCreateParams,
pub target: RouteTarget,
pub destination: RouteDestination,
}

/// Updateable properties of a [`RouterRoute`]
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
pub struct RouterRouteUpdateParams {
#[serde(flatten)]
pub identity: IdentityMetadataUpdateParams,
pub target: RouteTarget,
pub destination: RouteDestination,
}

Copy link
Contributor Author

@just-be-dev just-be-dev Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this over to the params file to be co-located with the other resource params that were already there.

Copy link
Contributor

@david-crespo david-crespo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whew, this is a BIG one

pub struct RoutePath {
pub route: NameOrId,
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something to be addressed in this PR, but it's a little silly that these are all the same. If we called it resource in all cases maybe they could share the struct. Something like:

#[derive(Deserialize, JsonSchema)]
pub struct NameOrIdPath {
    pub resource: NameOrId,
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the ultimate intent here I think is to have it be generated by a macro. Unfortunately the name matters as it shows up in documentation, the API spec, etc.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We did that at "previous job" (have a common "resource" struct), and it was such a pain when we needed to add additional fields for a new version, it ended up being a spaghetti nightmare 😅

Ok(disk)
}

/// Create a network interface attached to the provided instance.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I relocated the network interface logic in its own file. We break this resource at the data store layer, might as well be consistent with it.

@just-be-dev
Copy link
Contributor Author

I'm going to push forward here. Please, if folks have any feedback don't hesitate to add it after the merge. I'm more than happy to follow up with any fixes or re-work that may be needed.

@bnaecker
Copy link
Collaborator

Sorry for the delay! I'm nearly done with my comments!

Copy link
Collaborator

@bnaecker bnaecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Justin! This is an enormous amount of work. Thank you so much for taking it on, this looks like a big improvement. I have a few comments, all related to documentation and comments. There's nothing in the code itself that appears out of order. Thanks again, great work!

@just-be-dev just-be-dev merged commit 6c426af into main Feb 15, 2023
@just-be-dev just-be-dev deleted the rfd-322-networking branch February 15, 2023 20:17
david-crespo added a commit that referenced this pull request Feb 17, 2023
Followup to #2057. Noticed these while upgrading the docs site —
deprecated endpoints are filtered out to give priority to the v1 ones,
but these were not being filtered out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants