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" } 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) }
Example to Delete a Project
projectID := "966b3c7d36a24facaf20b7e458bf2192" err := projects.Delete(identityClient, projectID).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 Projects to which the current token has access.
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"` }
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.
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"` }
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 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"` }
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.
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"` }
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.