services

package
v0.5.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

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 *golangsdk.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

type CreateOptsBuilder interface {
	ToServiceCreateMap() (map[string]interface{}, error)
}

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 *golangsdk.ServiceClient, opts CreateOptsBuilder) (r CreateResult)

Create adds a new service of the requested type to the catalog.

func (CreateResult) Extract

func (r CreateResult) Extract() (*Service, error)

Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. An error is returned if the original call or the extraction failed.

type DeleteResult

type DeleteResult struct {
	golangsdk.ErrResult
}

DeleteResult is the response from a Delete request. Call its ExtractErr method to interpret it as a Service.

func Delete

func Delete(client *golangsdk.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 *golangsdk.ServiceClient, serviceID string) (r GetResult)

Get returns additional information about a service, given its ID.

func (GetResult) Extract

func (r GetResult) Extract() (*Service, error)

Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. An error is returned if the original call or the extraction failed.

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

func (opts ListOpts) ToServiceListMap() (string, error)

ToServiceListMap builds a list query from the list options.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToServiceListMap() (string, error)
}

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]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

func (r *Service) UnmarshalJSON(b []byte) error

type ServicePage

type ServicePage struct {
	pagination.LinkedPageBase
}

ServicePage is a single page of Service results.

func (ServicePage) IsEmpty

func (r 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

type UpdateOptsBuilder interface {
	ToServiceUpdateMap() (map[string]interface{}, error)
}

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 *golangsdk.ServiceClient, serviceID string, opts UpdateOptsBuilder) (r UpdateResult)

Update updates an existing Service.

func (UpdateResult) Extract

func (r UpdateResult) Extract() (*Service, error)

Extract interprets a GetResult, CreateResult or UpdateResult as a concrete Service. An error is returned if the original call or the extraction failed.

Directories

Path Synopsis
services unit tests
services unit tests

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL