Documentation ¶
Overview ¶
Package projects provides the ability to retrieve and manage projects through the Resell v2 API.
Example of getting a single project referenced by its id
project, _, err := projects.Get(context, resellClient, projectID) if err != nil { log.Fatal(err) } fmt.Println(project)
Example of listing all projects in the domain
allProjects, _, err := projects.List(context, resellClient) if err != nil { log.Fatal(err) } for _, myProject := range allProjects { fmt.Println(myProject) }
Example of creating a single project
createOpts := projects.CreateOpts{ Name: "test000", Quotas: []quotas.QuotaOpts{ { Name: "compute_cores", ResourceQuotasOpts: []quotas.ResourceQuotaOpts{ { Region: "ru-1", Zone: "ru-1b", Value: 1, }, }, }, { Name: "compute_ram", ResourceQuotasOpts: []quotas.ResourceQuotaOpts{ { Region: "ru-1", Zone: "ru-1b", Value: 1024, }, }, }, }, } newProject, _, err := projects.Create(context, resellClient, createOpts) if err != nil { log.Fatal(err) } fmt.Println(newProject)
Example of updating a single project
themeColor := "ffffff" logo := "123" themeUpdateOpts := projects.ThemeUpdateOpts{ Color: &themeColor, Logo: &logo, } name := "test001" updateOpts := projects.UpdateOpts{ Name: &name, Theme: &themeUpdateOpts, } updatedProject, _, err := projects.Update(context, resellClient, newProject.ID, updateOpts) if err != nil { log.Fatal(err) } fmt.Println(updatedProject)
Example of deleting a single project
_, err = projects.Delete(context, resellClient, newProject.ID) if err != nil { log.Fatal(err) }
Index ¶
- func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
- type CreateOpts
- type Project
- func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts CreateOpts) (*Project, *selvpcclient.ResponseResult, error)
- func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*Project, *selvpcclient.ResponseResult, error)
- func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Project, *selvpcclient.ResponseResult, error)
- func Update(ctx context.Context, client *selvpcclient.ServiceClient, id string, ...) (*Project, *selvpcclient.ResponseResult, error)
- type Theme
- type ThemeUpdateOpts
- type UpdateOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)
Delete deletes a single project by its id.
Types ¶
type CreateOpts ¶
type CreateOpts struct { // Name sets the name for a new project. Name string `json:"-"` // Quotas sets quotas for a new project. Quotas []quotas.QuotaOpts `json:"-"` // AutoQuotas allows to automatically set quotas for the new project. // Quota values will be calculated in the Resell V2 service. AutoQuotas bool `json:"-"` }
CreateOpts represents options for the project Create request.
func (*CreateOpts) MarshalJSON ¶
func (opts *CreateOpts) MarshalJSON() ([]byte, error)
MarshalJSON implements custom marshalling method for the CreateOpts.
type Project ¶
type Project struct { // ID is a unique id of a project. ID string `json:"-"` // Name is a human-readable name of a project. Name string `json:"-"` // URL is a public url of a project that is set by the admin API. URL string `json:"-"` // Enabled shows if project is active or it was disabled by the admin API. Enabled bool `json:"-"` // CustomURL is a public url of a project that can be set by a user. CustomURL string `json:"-"` // Theme represents project theme settings. Theme Theme `json:"-"` // Quotas contains information about project quotas. Quotas []quotas.Quota `json:"-"` }
Project represents a single Identity service project.
func Create ¶
func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts CreateOpts) (*Project, *selvpcclient.ResponseResult, error)
Create requests a creation of the project.
func Get ¶
func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*Project, *selvpcclient.ResponseResult, error)
Get returns a single project by its id.
func List ¶
func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Project, *selvpcclient.ResponseResult, error)
List gets a list of projects in the current domain.
func Update ¶
func Update(ctx context.Context, client *selvpcclient.ServiceClient, id string, updateOpts UpdateOpts) (*Project, *selvpcclient.ResponseResult, error)
Update requests an update of the project referenced by its id.
func (*Project) UnmarshalJSON ¶
UnmarshalJSON implements custom unmarshalling method for the Project type.
type Theme ¶
type Theme struct { // Color is a hex string with a custom background color. Color string `json:"color"` // Logo contains url for the project custom header logotype. Logo string `json:"logo"` }
Theme represents theme settings for a single project.
type ThemeUpdateOpts ¶
type ThemeUpdateOpts struct { // Color is a hex string with a custom background color. Color *string `json:"color,omitempty"` // Logo contains url for the project custom header logotype. Logo *string `json:"logo,omitempty"` }
ThemeUpdateOpts represents project theme options for the Update request.
type UpdateOpts ¶
type UpdateOpts struct { // Name represents the name of a project. Name string `json:"name,omitempty"` // CustomURL is a public url of a project that can be set by a user. CustomURL *string `json:"custom_url,omitempty"` // Theme represents project theme settings. Theme *ThemeUpdateOpts `json:"theme,omitempty"` }
UpdateOpts represents options for the project Update request.