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(context.TODO())
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]any{
"name": "compute-service",
"description": "Compute Service",
},
}
service, err := services.Create(context.TODO(), 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]any{
"description": "Disabled Compute Service"
},
}
service, err := services.Update(context.TODO(), identityClient, serviceID, updateOpts).Extract()
if err != nil {
panic(err)
}
Example to Delete a Service
serviceID := "3c7bbe9a6ecb453ca1789586291380ed"
err := services.Delete(context.TODO(), 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]any `json:"-"`
}
CreateOpts provides options used to create a service.
func (CreateOpts) ToServiceCreateMap ¶
func (opts CreateOpts) ToServiceCreateMap() (map[string]any, 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(ctx context.Context, 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.
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.
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.
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]any `json:"links"`
// Extra is a collection of miscellaneous key/values.
Extra map[string]any `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]any `json:"-"`
}
UpdateOpts provides options for updating a service.
func (UpdateOpts) ToServiceUpdateMap ¶
func (opts UpdateOpts) ToServiceUpdateMap() (map[string]any, 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(ctx context.Context, client *gophercloud.ServiceClient, serviceID string, opts UpdateOptsBuilder) (r UpdateResult)
Update updates an existing Service.