github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/identity/v3/regions/doc.go (about)

     1  /*
     2  Package regions manages and retrieves Regions in the OpenStack Identity Service.
     3  
     4  Example to List Regions
     5  
     6  	listOpts := regions.ListOpts{
     7  		ParentRegionID: "RegionOne",
     8  	}
     9  
    10  	allPages, err := regions.List(identityClient, listOpts).AllPages()
    11  	if err != nil {
    12  		panic(err)
    13  	}
    14  
    15  	allRegions, err := regions.ExtractRegions(allPages)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	for _, region := range allRegions {
    21  		fmt.Printf("%+v\n", region)
    22  	}
    23  
    24  Example to Create a Region
    25  
    26  	createOpts := regions.CreateOpts{
    27  		ID:             "TestRegion",
    28  		Description: "Region for testing"
    29  		Extra: map[string]interface{}{
    30  			"email": "testregionsupport@example.com",
    31  		}
    32  	}
    33  
    34  	region, err := regions.Create(identityClient, createOpts).Extract()
    35  	if err != nil {
    36  		panic(err)
    37  	}
    38  
    39  Example to Update a Region
    40  
    41  	regionID := "TestRegion"
    42  
    43  	// There is currently a bug in Keystone where updating the optional Extras
    44  	// attributes set in regions.Create is not supported, see:
    45  	// https://bugs.launchpad.net/keystone/+bug/1729933
    46  	updateOpts := regions.UpdateOpts{
    47  		Description: "Updated Description for region",
    48  	}
    49  
    50  	region, err := regions.Update(identityClient, regionID, updateOpts).Extract()
    51  	if err != nil {
    52  		panic(err)
    53  	}
    54  
    55  Example to Delete a Region
    56  
    57  	regionID := "TestRegion"
    58  	err := regions.Delete(identityClient, regionID).ExtractErr()
    59  	if err != nil {
    60  		panic(err)
    61  	}
    62  */
    63  package regions