projects

package
v0.0.0-...-d74374d Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Overview

Package projects provides interaction with Limes at the project hierarchical level.

Here is an example on how you would list all the projects in the current domain:

import (
  "fmt"
  "log"

  "github.com/gophercloud/gophercloud"
  "github.com/gophercloud/gophercloud/openstack/identity/v3/tokens"
  "github.com/gophercloud/utils/openstack/clientconfig"

  "github.com/sapcc/gophercloud-sapcc/clients"
  "github.com/sapcc/gophercloud-sapcc/resources/v1/projects"
)

func main() {
  provider, err := clientconfig.AuthenticatedClient(nil)
  if err != nil {
    log.Fatalf("could not initialize openstack client: %v", err)
  }

  limesClient, err := clients.NewLimesV1(provider, gophercloud.EndpointOpts{})
  if err != nil {
    log.Fatalf("could not initialize Limes client: %v", err)
  }

  project, err := provider.GetAuthResult().(tokens.CreateResult).ExtractProject()
  if err != nil {
    log.Fatalf("could not get project from token: %v", err)
  }

  result := projects.List(limesClient, project.Domain.ID, projects.ListOpts{Detail: true})
  if result.Err != nil {
    log.Fatalf("could not get projects: %v", result.Err)
  }

  projectList, err := result.ExtractProjects()
  if err != nil {
    log.Fatalf("could not get projects: %v", err)
  }
  for _, project := range projectList {
    fmt.Printf("%+v\n", project.Services)
  }
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonResult

type CommonResult struct {
	gophercloud.Result
}

CommonResult is the result of a Get/List operation. Call its appropriate Extract method to interpret it as a Project or a slice of Projects.

func Get

func Get(c *gophercloud.ServiceClient, domainID, projectID string, opts GetOptsBuilder) (r CommonResult)

Get retrieves details on a single project, by ID.

func List

func List(c *gophercloud.ServiceClient, domainID string, opts ListOptsBuilder) (r CommonResult)

List enumerates the projects in a specific domain.

func (CommonResult) Extract

Extract interprets a CommonResult as a Project.

func (CommonResult) ExtractProjects

func (r CommonResult) ExtractProjects() ([]limesresources.ProjectReport, error)

ExtractProjects interprets a CommonResult as a slice of Projects.

type GetOpts

type GetOpts struct {
	Detail    bool                          `q:"detail"`
	Areas     []string                      `q:"area"`
	Services  []limes.ServiceType           `q:"service"`
	Resources []limesresources.ResourceName `q:"resource"`
}

GetOpts contains parameters for filtering a Get request.

func (GetOpts) ToProjectGetParams

func (opts GetOpts) ToProjectGetParams() (headers map[string]string, queryString string, err error)

ToProjectGetParams formats a GetOpts into a map of headers and a query string.

type GetOptsBuilder

type GetOptsBuilder interface {
	ToProjectGetParams() (map[string]string, string, error)
}

GetOptsBuilder allows extensions to add additional parameters to the Get request.

type ListOpts

type ListOpts struct {
	Detail    bool                          `q:"detail"`
	Areas     []string                      `q:"area"`
	Services  []limes.ServiceType           `q:"service"`
	Resources []limesresources.ResourceName `q:"resource"`
}

ListOpts contains parameters for filtering a List request.

func (ListOpts) ToProjectListParams

func (opts ListOpts) ToProjectListParams() (headers map[string]string, queryString string, err error)

ToProjectListParams formats a ListOpts into a map of headers and a query string.

type ListOptsBuilder

type ListOptsBuilder interface {
	ToProjectListParams() (map[string]string, string, error)
}

ListOptsBuilder allows extensions to add additional parameters to the List request.

type SyncResult

type SyncResult struct {
	gophercloud.ErrResult
}

SyncResult is the result of an Sync operation. Call its appropriate ExtractErr method to extract the error from the result.

func Sync

func Sync(c *gophercloud.ServiceClient, domainID, projectID string) (r SyncResult)

Sync schedules a sync task that pulls a project's data from the backing services into Limes' local database.

type UpdateOpts

type UpdateOpts struct {
	Services limesresources.QuotaRequest         `json:"services"`
	Bursting *limesresources.ProjectBurstingInfo `json:"bursting,omitempty"`
}

UpdateOpts contains parameters to update a project.

func (UpdateOpts) ToProjectUpdateMap

func (opts UpdateOpts) ToProjectUpdateMap() (headers map[string]string, requestBody map[string]interface{}, err error)

ToProjectUpdateMap formats a UpdateOpts into a map of headers and a request body.

type UpdateOptsBuilder

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

UpdateOptsBuilder allows extensions to add additional parameters to the Update request.

type UpdateResult

type UpdateResult struct {
	gophercloud.Result
	Body []byte
}

UpdateResult is the result of an Update operation. Call its appropriate Extract method to extract the error and the warning body from the result.

func Update

func Update(c *gophercloud.ServiceClient, domainID, projectID string, opts UpdateOptsBuilder) (r UpdateResult)

Update modifies the attributes of a project and returns the response body which contains non-fatal error messages.

func (UpdateResult) Extract

func (r UpdateResult) Extract() ([]byte, error)

Extract interprets a UpdateResult as an update warning body and error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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