subnetwork

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Commands = []*common.CliCommand{
	common.NewCliSubcommand(
		"subnetwork",
		[]*common.CliCommand{
			common.NewCliCommand(
				"list",
				"Retrieves all existing subnetworks",
				"",
				func(args []string, conn *grpc.ClientConn) (exits.ExitCode, error) {
					client := pb.NewSubnetworkServiceClient(conn)
					if err := List(client); err != nil {
						return exits.SUBNETWORK_ERROR, err
					}
					return exits.SUCCESS, nil
				},
			),
			common.NewCliCommand(
				"get",
				"Retrieves a specified subnetwork",
				"<id>",
				func(args []string, conn *grpc.ClientConn) (exits.ExitCode, error) {
					client := pb.NewSubnetworkServiceClient(conn)
					id, exitCode, err := common.ParseUint32Arg(&args)
					if err != nil {
						return exitCode, fmt.Errorf("failed to parse 'id' argument: %w", err)
					}

					if err := Get(client, id); err != nil {
						return exits.SUBNETWORK_ERROR, err
					}
					return exits.SUCCESS, nil
				},
			),
			common.NewCliCommand(
				"delete",
				"Deletes a specified subnetwork",
				"<id>",
				func(args []string, conn *grpc.ClientConn) (exits.ExitCode, error) {
					client := pb.NewSubnetworkServiceClient(conn)
					id, exitCode, err := common.ParseUint32Arg(&args)
					if err != nil {
						return exitCode, fmt.Errorf("failed to parse 'id' argument: %w", err)
					}

					if err := Delete(client, id); err != nil {
						return exits.SUBNETWORK_ERROR, err
					}
					return exits.SUCCESS, nil
				},
			),
			common.NewCliCommand(
				"create",
				"Creates a new subnetwork resource",
				"< file.yaml",
				func(args []string, conn *grpc.ClientConn) (exits.ExitCode, error) {
					client := pb.NewSubnetworkServiceClient(conn)

					yamlBytes, err := io.ReadAll(os.Stdin)
					if err != nil {
						return exits.SUBNETWORK_ERROR, err
					}

					if err := Create(client, yamlBytes); err != nil {
						return exits.SUBNETWORK_ERROR, err
					}
					return exits.SUCCESS, nil
				},
			),
			common.NewCliCommand(
				"update",
				"Updates an existing network resource",
				"< file.yaml",
				func(args []string, conn *grpc.ClientConn) (exits.ExitCode, error) {
					client := pb.NewSubnetworkServiceClient(conn)

					yamlBytes, err := io.ReadAll(os.Stdin)
					if err != nil {
						return exits.SUBNETWORK_ERROR, err
					}

					id, exitCode, err := common.ParseUint32Arg(&args)
					if err != nil {
						return exitCode, fmt.Errorf("failed to parse 'id' argument: %w", err)
					}

					if err := Update(client, id, yamlBytes); err != nil {
						return exits.SUBNETWORK_ERROR, err
					}
					return exits.SUCCESS, nil
				},
			),
		},
	),
}

Functions

func Create

func Create(client pb.SubnetworkServiceClient, yamlBytes []byte) error

func Delete

func Delete(client pb.SubnetworkServiceClient, id uint32) error

func Get

func Get(client pb.SubnetworkServiceClient, id uint32) error

func List

func List(client pb.SubnetworkServiceClient) error

func Update

func Update(client pb.SubnetworkServiceClient, id uint32, yamlBytes []byte) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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