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

     1  /*
     2  Package domains manages and retrieves Domains in the OpenStack Identity Service.
     3  
     4  Example to List Domains
     5  
     6  	var iTrue bool = true
     7  	listOpts := domains.ListOpts{
     8  		Enabled: &iTrue,
     9  	}
    10  
    11  	allPages, err := domains.List(identityClient, listOpts).AllPages()
    12  	if err != nil {
    13  		panic(err)
    14  	}
    15  
    16  	allDomains, err := domains.ExtractDomains(allPages)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	for _, domain := range allDomains {
    22  		fmt.Printf("%+v\n", domain)
    23  	}
    24  
    25  Example to Create a Domain
    26  
    27  	createOpts := domains.CreateOpts{
    28  		Name:             "domain name",
    29  		Description:      "Test domain",
    30  	}
    31  
    32  	domain, err := domains.Create(identityClient, createOpts).Extract()
    33  	if err != nil {
    34  		panic(err)
    35  	}
    36  
    37  Example to Update a Domain
    38  
    39  	domainID := "0fe36e73809d46aeae6705c39077b1b3"
    40  
    41  	var iFalse bool = false
    42  	updateOpts := domains.UpdateOpts{
    43  		Enabled: &iFalse,
    44  	}
    45  
    46  	domain, err := domains.Update(identityClient, domainID, updateOpts).Extract()
    47  	if err != nil {
    48  		panic(err)
    49  	}
    50  
    51  Example to Delete a Domain
    52  
    53  	domainID := "0fe36e73809d46aeae6705c39077b1b3"
    54  	err := domains.Delete(identityClient, domainID).ExtractErr()
    55  	if err != nil {
    56  		panic(err)
    57  	}
    58  */
    59  package domains