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 ¶
- func GetCatalog(client *gophercloud.ServiceClient) (r catalogResult)
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListService(client *gophercloud.ServiceClient, opts ListServiceOptsBuilder) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type ListOpts
- type ListOptsBuilder
- type ListServiceOpts
- type ListServiceOptsBuilder
- type Service
- type ServiceDetail
- type ServicePage
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCatalog ¶ added in v1.0.25
func GetCatalog(client *gophercloud.ServiceClient) (r catalogResult)
Get returns additional information about a service, given its ID.
func List ¶
func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
List enumerates the services available to a specific user.
func ListService ¶ added in v1.0.25
func ListService(client *gophercloud.ServiceClient, opts ListServiceOptsBuilder) pagination.Pager
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.
func (CreateResult) Extract ¶
Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. An error is returned if the original call or the extraction failed.
func (CreateResult) ExtractService ¶ added in v1.0.25
func (r CreateResult) ExtractService() (*ServiceDetail, error)
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.
func (GetResult) Extract ¶
Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. An error is returned if the original call or the extraction failed.
func (GetResult) ExtractService ¶ added in v1.0.25
func (r GetResult) ExtractService() (*ServiceDetail, error)
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 ListServiceOpts ¶ added in v1.0.25
type ListServiceOpts struct {
Type string `q:"type"`
}
ListOpts provides options for filtering the List results.
func (ListServiceOpts) ToServiceListDetailMap ¶ added in v1.0.25
func (opts ListServiceOpts) ToServiceListDetailMap() (string, error)
type ListServiceOptsBuilder ¶ added in v1.0.25
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 ServiceDetail ¶ added in v1.0.25
type ServiceDetail 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"` Description string `json:"description"` }
func ExtractListServices ¶ added in v1.0.25
func ExtractListServices(r pagination.Page) ([]ServiceDetail, error)
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.
func (UpdateResult) Extract ¶
Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. An error is returned if the original call or the extraction failed.
func (UpdateResult) ExtractService ¶ added in v1.0.25
func (r UpdateResult) ExtractService() (*ServiceDetail, error)