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

     1  /*
     2  Package services provides information and interaction with the services API
     3  resource for the OpenStack Identity service.
     4  
     5  Example to List Services
     6  
     7  	listOpts := services.ListOpts{
     8  		ServiceType: "compute",
     9  	}
    10  
    11  	allPages, err := services.List(identityClient, listOpts).AllPages()
    12  	if err != nil {
    13  		panic(err)
    14  	}
    15  
    16  	allServices, err := services.ExtractServices(allPages)
    17  	if err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	for _, service := range allServices {
    22  		fmt.Printf("%+v\n", service)
    23  	}
    24  
    25  Example to Create a Service
    26  
    27  	createOpts := services.CreateOpts{
    28  		Type: "compute",
    29  		Extra: map[string]interface{}{
    30  			"name": "compute-service",
    31  			"description": "Compute Service",
    32  		},
    33  	}
    34  
    35  	service, err := services.Create(identityClient, createOpts).Extract()
    36  	if err != nil {
    37  		panic(err)
    38  	}
    39  
    40  Example to Update a Service
    41  
    42  	serviceID :=  "3c7bbe9a6ecb453ca1789586291380ed"
    43  
    44  	var iFalse bool = false
    45  	updateOpts := services.UpdateOpts{
    46  		Enabled: &iFalse,
    47  		Extra: map[string]interface{}{
    48  			"description": "Disabled Compute Service"
    49  		},
    50  	}
    51  
    52  	service, err := services.Update(identityClient, serviceID, updateOpts).Extract()
    53  	if err != nil {
    54  		panic(err)
    55  	}
    56  
    57  Example to Delete a Service
    58  
    59  	serviceID := "3c7bbe9a6ecb453ca1789586291380ed"
    60  	err := services.Delete(identityClient, serviceID).ExtractErr()
    61  	if err != nil {
    62  		panic(err)
    63  	}
    64  
    65  */
    66  package services