go-selvpcclient: github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/projects Index | Files | Directories

package projects

import "github.com/selectel/go-selvpcclient/selvpcclient/resell/v2/projects"

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

Package Files

doc.go requests.go requests_opts.go schemas.go

func Delete Uses

func Delete(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*selvpcclient.ResponseResult, error)

Delete deletes a single project by its id.

type CreateOpts Uses

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 Uses

func (opts *CreateOpts) MarshalJSON() ([]byte, error)

MarshalJSON implements custom marshalling method for the CreateOpts.

type Project Uses

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 Uses

func Create(ctx context.Context, client *selvpcclient.ServiceClient, createOpts CreateOpts) (*Project, *selvpcclient.ResponseResult, error)

Create requests a creation of the project.

func Get Uses

func Get(ctx context.Context, client *selvpcclient.ServiceClient, id string) (*Project, *selvpcclient.ResponseResult, error)

Get returns a single project by its id.

func List Uses

func List(ctx context.Context, client *selvpcclient.ServiceClient) ([]*Project, *selvpcclient.ResponseResult, error)

List gets a list of projects in the current domain.

func Update Uses

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 Uses

func (result *Project) UnmarshalJSON(b []byte) error

UnmarshalJSON implements custom unmarshalling method for the Project type.

type Theme Uses

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.
     string `json:"logo"`
}

Theme represents theme settings for a single project.

type ThemeUpdateOpts Uses

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.
     *string `json:"logo,omitempty"`
}

ThemeUpdateOpts represents project theme options for the Update request.

type UpdateOpts Uses

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.

Directories

PathSynopsis
testing

Package projects imports 7 packages (graph) and is imported by 1 packages. Updated 2018-12-12. Refresh now. Tools for package owners.