github.com/gophercloud/gophercloud@v1.11.0/openstack/baremetal/v1/ports/doc.go (about)

     1  /*
     2  	Package ports contains the functionality to Listing, Searching, Creating, Updating,
     3  	and Deleting of bare metal Port resources
     4  
     5  	API reference: https://developer.openstack.org/api-ref/baremetal/#ports-ports
     6  
     7  Example to List Ports with Detail
     8  
     9  	ports.ListDetail(client, nil).EachPage(func(page pagination.Page) (bool, error) {
    10  		portList, err := ports.ExtractPorts(page)
    11  		if err != nil {
    12  			return false, err
    13  		}
    14  
    15  		for _, n := range portList {
    16  			// Do something
    17  		}
    18  
    19  		return true, nil
    20  	})
    21  
    22  Example to List Ports
    23  
    24  		listOpts := ports.ListOpts{
    25  	 		Limit: 10,
    26  		}
    27  
    28  	 	ports.List(client, listOpts).EachPage(func(page pagination.Page) (bool, error) {
    29  	 		portList, err := ports.ExtractPorts(page)
    30  	 		if err != nil {
    31  	 			return false, err
    32  	 		}
    33  
    34  	 		for _, n := range portList {
    35  	 			// Do something
    36  	 		}
    37  
    38  	 		return true, nil
    39  	 	})
    40  
    41  Example to Create a Port
    42  
    43  		createOpts := ports.CreateOpts{
    44  	 		NodeUUID: "e8920409-e07e-41bb-8cc1-72acb103e2dd",
    45  			Address: "00:1B:63:84:45:E6",
    46  	    PhysicalNetwork: "my-network",
    47  		}
    48  
    49  	 	createPort, err := ports.Create(client, createOpts).Extract()
    50  	 	if err != nil {
    51  	 		panic(err)
    52  	 	}
    53  
    54  Example to Get a Port
    55  
    56  	showPort, err := ports.Get(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474").Extract()
    57  	if err != nil {
    58  		panic(err)
    59  	}
    60  
    61  Example to Update a Port
    62  
    63  		updateOpts := ports.UpdateOpts{
    64  	 		ports.UpdateOperation{
    65  	 			Op:    ReplaceOp,
    66  	 			Path:  "/address",
    67  	 			Value: "22:22:22:22:22:22",
    68  	 		},
    69  		}
    70  
    71  	 	updatePort, err := ports.Update(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474", updateOpts).Extract()
    72  	 	if err != nil {
    73  	 		panic(err)
    74  	 	}
    75  
    76  Example to Delete a Port
    77  
    78  	 	err = ports.Delete(client, "c9afd385-5d89-4ecb-9e1c-68194da6b474").ExtractErr()
    79  	 	if err != nil {
    80  	 		panic(err)
    81  		}
    82  */
    83  package ports