Documentation
¶
Overview ¶
Package projects manages and retrieves Projects in the OpenStack Identity Service.
Example to List Projects
listOpts := projects.ListOpts{ Enabled: gophercloud.Enabled, } allPages, err := projects.List(identityClient, listOpts).AllPages() if err != nil { panic(err) } allProjects, err := projects.ExtractProjects(allPages) if err != nil { panic(err) } for _, project := range allProjects { fmt.Printf("%+v\n", project) }
Example to Create a Project
createOpts := projects.CreateOpts{ Name: "project_name", Description: "Project Description", Tags: []string{"FirstTag", "SecondTag"}, } project, err := projects.Create(identityClient, createOpts).Extract() if err != nil { panic(err) }
Example to Update a Project
projectID := "966b3c7d36a24facaf20b7e458bf2192" updateOpts := projects.UpdateOpts{ Enabled: gophercloud.Disabled, } project, err := projects.Update(identityClient, projectID, updateOpts).Extract() if err != nil { panic(err) } updateOpts = projects.UpdateOpts{ Tags: &[]string{"FirstTag"}, } project, err = projects.Update(identityClient, projectID, updateOpts).Extract() if err != nil { panic(err) }
Example to Delete a Project
projectID := "966b3c7d36a24facaf20b7e458bf2192" err := projects.Delete(identityClient, projectID).ExtractErr() if err != nil { panic(err) }
Index ¶
- func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager
- func ListAvailable(client *gophercloud.ServiceClient) pagination.Pager
- type CreateOpts
- type CreateOptsBuilder
- type CreateResult
- type DeleteResult
- type GetResult
- type InvalidListFilter
- type ListOpts
- type ListOptsBuilder
- type Option
- type Project
- type ProjectPage
- type UpdateOpts
- type UpdateOptsBuilder
- type UpdateResult
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 Projects to which the current token has access.
func ListAvailable ¶ added in v0.16.0
func ListAvailable(client *gophercloud.ServiceClient) pagination.Pager
ListAvailable enumerates the Projects which are available to a specific user.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // DomainID is the ID this project will belong under. DomainID string `json:"domain_id,omitempty"` // Enabled sets the project status to enabled or disabled. Enabled *bool `json:"enabled,omitempty"` // IsDomain indicates if this project is a domain. IsDomain *bool `json:"is_domain,omitempty"` // Name is the name of the project. Name string `json:"name" required:"true"` // ParentID specifies the parent project of this new project. ParentID string `json:"parent_id,omitempty"` // Description is the description of the project. Description string `json:"description,omitempty"` // Tags is a list of tags to associate with the project. Tags []string `json:"tags,omitempty"` // Extra is free-form extra key/value pairs to describe the project. Extra map[string]interface{} `json:"-"` // Options are defined options in the API to enable certain features. Options map[Option]interface{} `json:"options,omitempty"` }
CreateOpts represents parameters used to create a project.
func (CreateOpts) ToProjectCreateMap ¶
func (opts CreateOpts) ToProjectCreateMap() (map[string]interface{}, error)
ToProjectCreateMap 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 result of a Create request. Call its Extract method to interpret it as a Project.
func Create ¶
func Create(client *gophercloud.ServiceClient, opts CreateOptsBuilder) (r CreateResult)
Create creates a new Project.
type DeleteResult ¶
type DeleteResult struct {
gophercloud.ErrResult
}
DeleteResult is the result of a Delete request. Call its ExtractErr method to determine if the request succeeded or failed.
func Delete ¶
func Delete(client *gophercloud.ServiceClient, projectID string) (r DeleteResult)
Delete deletes a project.
type GetResult ¶
type GetResult struct {
// contains filtered or unexported fields
}
GetResult is the result of a Get request. Call its Extract method to interpret it as a Project.
func Get ¶
func Get(client *gophercloud.ServiceClient, id string) (r GetResult)
Get retrieves details on a single project, by ID.
type InvalidListFilter ¶
type InvalidListFilter struct {
FilterName string
}
InvalidListFilter is returned by the ToUserListQuery method when validation of a filter does not pass
func (InvalidListFilter) Error ¶
func (e InvalidListFilter) Error() string
type ListOpts ¶
type ListOpts struct { // DomainID filters the response by a domain ID. DomainID string `q:"domain_id"` // Enabled filters the response by enabled projects. Enabled *bool `q:"enabled"` // IsDomain filters the response by projects that are domains. // Setting this to true is effectively listing domains. IsDomain *bool `q:"is_domain"` // Name filters the response by project name. Name string `q:"name"` // ParentID filters the response by projects of a given parent project. ParentID string `q:"parent_id"` // Tags filters on specific project tags. All tags must be present for the project. Tags string `q:"tags"` // TagsAny filters on specific project tags. At least one of the tags must be present for the project. TagsAny string `q:"tags-any"` // NotTags filters on specific project tags. All tags must be absent for the project. NotTags string `q:"not-tags"` // NotTagsAny filters on specific project tags. At least one of the tags must be absent for the project. NotTagsAny string `q:"not-tags-any"` // Filters filters the response by custom filters such as // 'name__contains=foo' Filters map[string]string `q:"-"` }
ListOpts enables filtering of a list request.
func (ListOpts) ToProjectListQuery ¶
ToProjectListQuery formats a ListOpts into a query string.
type ListOptsBuilder ¶
ListOptsBuilder allows extensions to add additional parameters to the List request
type Option ¶ added in v0.11.0
type Option string
Option is a specific option defined at the API to enable features on a project.
const (
Immutable Option = "immutable"
)
type Project ¶
type Project struct { // IsDomain indicates whether the project is a domain. IsDomain bool `json:"is_domain"` // Description is the description of the project. Description string `json:"description"` // DomainID is the domain ID the project belongs to. DomainID string `json:"domain_id"` // Enabled is whether or not the project is enabled. Enabled bool `json:"enabled"` // ID is the unique ID of the project. ID string `json:"id"` // Name is the name of the project. Name string `json:"name"` // ParentID is the parent_id of the project. ParentID string `json:"parent_id"` // Tags is the list of tags associated with the project. Tags []string `json:"tags,omitempty"` // Extra is free-form extra key/value pairs to describe the project. Extra map[string]interface{} `json:"-"` // Options are defined options in the API to enable certain features. Options map[Option]interface{} `json:"options,omitempty"` }
Project represents an OpenStack Identity Project.
func ExtractProjects ¶
func ExtractProjects(r pagination.Page) ([]Project, error)
ExtractProjects returns a slice of Projects contained in a single page of results.
func (*Project) UnmarshalJSON ¶ added in v0.11.0
type ProjectPage ¶
type ProjectPage struct {
pagination.LinkedPageBase
}
ProjectPage is a single page of Project results.
func (ProjectPage) IsEmpty ¶
func (r ProjectPage) IsEmpty() (bool, error)
IsEmpty determines whether or not a page of Projects contains any results.
func (ProjectPage) NextPageURL ¶
func (r ProjectPage) NextPageURL() (string, error)
NextPageURL extracts the "next" link from the links section of the result.
type UpdateOpts ¶
type UpdateOpts struct { // DomainID is the ID this project will belong under. DomainID string `json:"domain_id,omitempty"` // Enabled sets the project status to enabled or disabled. Enabled *bool `json:"enabled,omitempty"` // IsDomain indicates if this project is a domain. IsDomain *bool `json:"is_domain,omitempty"` // Name is the name of the project. Name string `json:"name,omitempty"` // ParentID specifies the parent project of this new project. ParentID string `json:"parent_id,omitempty"` // Description is the description of the project. Description *string `json:"description,omitempty"` // Tags is a list of tags to associate with the project. Tags *[]string `json:"tags,omitempty"` // Extra is free-form extra key/value pairs to describe the project. Extra map[string]interface{} `json:"-"` // Options are defined options in the API to enable certain features. Options map[Option]interface{} `json:"options,omitempty"` }
UpdateOpts represents parameters to update a project.
func (UpdateOpts) ToProjectUpdateMap ¶
func (opts UpdateOpts) ToProjectUpdateMap() (map[string]interface{}, error)
ToUpdateCreateMap 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 result of an Update request. Call its Extract method to interpret it as a Project.
func Update ¶
func Update(client *gophercloud.ServiceClient, id string, opts UpdateOptsBuilder) (r UpdateResult)
Update modifies the attributes of a project.