projects

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2020 License: Apache-2.0 Imports: 7 Imported by: 4

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Delete

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

Create requests a creation of the project.

func Get

Get returns a single project by its id.

func List

List gets a list of projects in the current domain.

func Update

Update requests an update of the project referenced by its id.

func (*Project) UnmarshalJSON

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

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 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 *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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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