# Networking v2

## Setup

### Rackspace setup

The first step is to pass in your credentials and set up a client. For Rackspace users, you will need your username and API key:

    use OpenCloud\Rackspace;

    $client = new Rackspace(Rackspace::US_IDENTITY_ENDPOINT, array(
      'username' => '{username}',
      'apiKey'   => '{apiKey}',
    ));

### OpenStack setup

If you’re an OpenStack user, you will also need to prove a few other configuration parameters:

    $client = new OpenCloud\OpenStack('{keystoneUrl}', array(
      'username' => '{username}',
      'password' => '{apiKey}',
      'tenantId' => '{tenantId}',
    ));

### Networking service

Now to instantiate the Networking service:

    $service = $client->networkingService('{catalogName}', '{region}', '{urlType}');

- `{catalogName}` is the name of the service as it appears in the service catalog. OpenStack users must set this value. For Rackspace users, a default will be provided if you pass in `null`.
- `{region}` is the region the service will operate in. For Rackspace users, you can select one of the following from the supported regions page.
- `{urlType}` is the type of URL to use, depending on which endpoints your catalog provides. If omitted, it will default to the public network.

## Operations

- Networks
  - Create a network
  - Create multiple networks
  - List networks
  - Get a network
  - Update a network
    - Delete a network
- Subnets
  - Create a subnet
  - Create multiple subnets
  - List subnets
  - Get a subnet
  - Update a subnet
  - Delete a subnet
- Ports
  - Create a port
  - Create multiple ports
  - List ports
  - Get a port
  - Update a port
  - Delete a port
- Security Groups
  - Create a security group
  - List security groups
  - Get a security group
  - Delete a security group
- Security Group Rules
  - Create a security group rule
  - List security group rules

## Glossary

network
  A network is an isolated virtual layer-2 broadcast domain that is typically reserved for the tenant who created it unless you configure the network to be shared. The network is the main entity in the Networking service. Ports and subnets are always associated with a network.
subnet
  A subnet represents an IP address block that can be used to assign IP addresses to virtual instances (such as servers created using the Compute service). Each subnet must have a CIDR and must be associated with a network.
port
  A port represents a virtual switch port on a logical network switch. Virtual instances (such as servers created using the Compute service) attach their interfaces into ports. The port also defines the MAC address and the IP address(es) to be assigned to the interfaces plugged into them. When IP addresses are associated to a port, this also implies the port is associated with a subet, as the IP address is taken from the allocation pool for a specific subnet.
security group
  A security group is a named container for security group rules.
security group rule
  A security group rule provides users the ability to specify the types of traffic that are allowed to pass through to and from ports on a virtual server instance.

## Further links

- Getting Started Guide for the API
- API Developer Guide
- API release history