github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/availabilityzones/doc.go (about)

     1  /*
     2  Package availabilityzones provides the ability to get lists and detailed
     3  availability zone information and to extend a server result with
     4  availability zone information.
     5  
     6  Example of Extend server result with Availability Zone Information:
     7  
     8  	type ServerWithAZ struct {
     9  		servers.Server
    10  		availabilityzones.ServerAvailabilityZoneExt
    11  	}
    12  
    13  	var allServers []ServerWithAZ
    14  
    15  	allPages, err := servers.List(client, nil).AllPages()
    16  	if err != nil {
    17  		panic("Unable to retrieve servers: %s", err)
    18  	}
    19  
    20  	err = servers.ExtractServersInto(allPages, &allServers)
    21  	if err != nil {
    22  		panic("Unable to extract servers: %s", err)
    23  	}
    24  
    25  	for _, server := range allServers {
    26  		fmt.Println(server.AvailabilityZone)
    27  	}
    28  
    29  Example of Get Availability Zone Information
    30  
    31  	allPages, err := availabilityzones.List(computeClient).AllPages()
    32  	if err != nil {
    33  		panic(err)
    34  	}
    35  
    36  	availabilityZoneInfo, err := availabilityzones.ExtractAvailabilityZones(allPages)
    37  	if err != nil {
    38  		panic(err)
    39  	}
    40  
    41  	for _, zoneInfo := range availabilityZoneInfo {
    42    		fmt.Printf("%+v\n", zoneInfo)
    43  	}
    44  
    45  Example of Get Detailed Availability Zone Information
    46  
    47  	allPages, err := availabilityzones.ListDetail(computeClient).AllPages()
    48  	if err != nil {
    49  		panic(err)
    50  	}
    51  
    52  	availabilityZoneInfo, err := availabilityzones.ExtractAvailabilityZones(allPages)
    53  	if err != nil {
    54  		panic(err)
    55  	}
    56  
    57  	for _, zoneInfo := range availabilityZoneInfo {
    58    		fmt.Printf("%+v\n", zoneInfo)
    59  	}
    60  */
    61  package availabilityzones