Documentation ¶
Overview ¶
Package services provides information and interaction with the services API resource for the OpenStack Identity service.
Example to List Services
listOpts := services.ListOpts{ ServiceType: "compute", } allPages, err := services.List(identityClient, listOpts).AllPages() if err != nil { panic(err) } allServices, err := services.ExtractServices(allPages) if err != nil { panic(err) } for _, service := range allServices { fmt.Printf("%+v\n", service) }
Example to Create a Service
createOpts := services.CreateOpts{ Type: "compute", Extra: map[string]interface{}{ "name": "compute-service", "description": "Compute Service", }, } service, err := services.Create(identityClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Service
serviceID := "3c7bbe9a6ecb453ca1789586291380ed" var iFalse bool = false updateOpts := services.UpdateOpts{ Enabled: &iFalse, Extra: map[string]interface{}{ "description": "Disabled Compute Service" }, } service, err := services.Update(identityClient, serviceID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Service
serviceID := "3c7bbe9a6ecb453ca1789586291380ed" err := services.Delete(identityClient, serviceID).ExtractErr() if err != nil { panic(err) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List enumerates the services available to a specific user.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // Type is the type of the service. Type string `json:"type"` // Enabled is whether or not the service is enabled. Enabled *bool `json:"enabled,omitempty"` // Extra is free-form extra key/value pairs to describe the service. Extra map[string]interface{} `json:"-"` }
CreateOpts provides options used to create a service.
func (CreateOpts) ToServiceCreateMap ¶
func (opts CreateOpts) ToServiceCreateMap() (map[string]interface{}, error)
ToServiceCreateMap formats a CreateOpts into a create request.
type CreateOptsBuilder ¶
CreateOptsBuilder allows extensions to add additional parameters to the Create request.
type CreateResult ¶
type CreateResult struct {
// contains filtered or unexported fields
}
CreateResult is the response from a Create request. Call its Extract method to interpret it as a Service.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create adds a new service of the requested type to the catalog.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the response from a Delete request. Call its ExtractErr method to interpret it as a Service.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, serviceID string) (r DeleteResult)
Delete removes an existing service. It either deletes all associated endpoints, or fails until all endpoints are deleted.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the response from a Get request. Call its Extract method to interpret it as a Service.
func Get ¶
func Get(client *gophercloud.ServiceClient, serviceID string) (r GetResult)
Get returns additional information about a service, given its ID.
type ListOpts ¶
type ListOpts struct { // ServiceType filter the response by a type of service. ServiceType string `q:"type"` // Name filters the response by a service name. Name string `q:"name"` }
ListOpts provides options for filtering the List results.
func (ListOpts) ToServiceListMap ¶
ToServiceListMap builds a list query from the list options.
type ListOptsBuilder ¶
ListOptsBuilder enables extensions to add additional parameters to the List request.
type Service ¶
type Service struct { // ID is the unique ID of the service. ID string `json:"id"` // Type is the type of the service. Name string `json:"name"` // Type is the type of the service. Type string `json:"type"` // Enabled is whether or not the service is enabled. Enabled bool `json:"enabled"` // Links contains referencing links to the service. Links map[string]interface{} `json:"links"` // Extra is a collection of miscellaneous key/values. Extra map[string]interface{} `json:"-"` }
Service represents an OpenStack Service.
func ExtractServices ¶
func ExtractServices(r pagination.Page) ([]Service, error)
ExtractServices extracts a slice of Services from a Collection acquired from List.
func (*Service) UnmarshalJSON ¶
type ServicePage ¶
type ServicePage struct {
pagination.LinkedPageBase
}
ServicePage is a single page of Service results.
func (ServicePage) IsEmpty ¶
func (p ServicePage) IsEmpty() (bool, error)
IsEmpty returns true if the ServicePage contains no results.
func (ServicePage) NextPageURL ¶
func (r ServicePage) NextPageURL() (string, error)
NextPageURL extracts the "next" link from the links section of the result.
type UpdateOpts ¶
type UpdateOpts struct { // Type is the type of the service. Type string `json:"type"` // Enabled is whether or not the service is enabled. Enabled *bool `json:"enabled,omitempty"` // Extra is free-form extra key/value pairs to describe the service. Extra map[string]interface{} `json:"-"` }
UpdateOpts provides options for updating a service.
func (UpdateOpts) ToServiceUpdateMap ¶
func (opts UpdateOpts) ToServiceUpdateMap() (map[string]interface{}, error)
ToServiceUpdateMap formats a UpdateOpts into an update request.
type UpdateOptsBuilder ¶
UpdateOptsBuilder allows extensions to add additional parameters to the Update request.
type UpdateResult ¶
type UpdateResult struct {
// contains filtered or unexported fields
}
UpdateResult is the response from an Update request. Call its Extract method to interpret it as a Service.
func Update ¶
func Update(client *gophercloud.ServiceClient, serviceID string, opts UpdateOptsBuilder) (r UpdateResult)
Update updates an existing Service.