Skip to main content
Projects are organizational units that group cloud resources for access control and billing. Each client can have multiple projects, with one designated as the default project.

Methods

New

Create a new project.
func (r *ProjectService) New(ctx context.Context, body ProjectNewParams, opts ...option.RequestOption) (*Project, error)
name
string
required
Unique project name
description
string
Project description
id
int64
Automatically generated project ID
name
string
Project name
description
string
Project description
client_id
int64
Associated client ID
is_default
bool
Whether this is the default project
state
string
Project state
created_at
time.Time
Creation timestamp
deleted_at
time.Time
Deletion timestamp (if deleted)

Update

Update project name or description.
func (r *ProjectService) Update(ctx context.Context, params ProjectUpdateParams, opts ...option.RequestOption) (*Project, error)
project_id
int64
required
Project ID to update
name
string
New project name
description
string
New project description

List

List all projects with optional filtering.
func (r *ProjectService) List(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) (*pagination.OffsetPage[Project], error)
func (r *ProjectService) ListAutoPaging(ctx context.Context, query ProjectListParams, opts ...option.RequestOption) *pagination.OffsetPageAutoPager[Project]
client_id
int64
Filter by client ID (admin only)
name
string
Filter by project name
include_deleted
bool
Include deleted projects in results
order_by
string
Sort order: created_at.asc, created_at.desc, name.asc, name.desc
limit
int64
Maximum number of results per page
offset
int64
Number of results to skip

Get

Retrieve a specific project by ID.
func (r *ProjectService) Get(ctx context.Context, query ProjectGetParams, opts ...option.RequestOption) (*Project, error)
project_id
int64
required
Project ID

Delete

Delete a project and all associated resources.
func (r *ProjectService) Delete(ctx context.Context, body ProjectDeleteParams, opts ...option.RequestOption) (*TaskIDList, error)
func (r *ProjectService) DeleteAndPoll(ctx context.Context, body ProjectDeleteParams, opts ...option.RequestOption) error
project_id
int64
required
Project ID to delete
This operation is irreversible and will delete all cloud resources in all regions. Default projects cannot be deleted.

Examples

Create a Project

import (
    "context"
    "github.com/G-Core/gcore-go"
    "github.com/G-Core/gcore-go/cloud"
)

client := gcore.NewClient()

project, err := client.Cloud.Projects.New(context.Background(), cloud.ProjectNewParams{
    Name:        "my-production-project",
    Description: gcore.String("Production environment resources"),
})
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Created project ID: %d\n", project.ID)

List All Projects

projects, err := client.Cloud.Projects.List(context.Background(), cloud.ProjectListParams{})
if err != nil {
    log.Fatal(err)
}

for _, project := range projects.Results {
    fmt.Printf("Project: %s (ID: %d)\n", project.Name, project.ID)
}

List Projects with Auto-Paging

iter := client.Cloud.Projects.ListAutoPaging(context.Background(), 
    cloud.ProjectListParams{
        Limit: gcore.Int(10),
    },
)

for iter.Next() {
    project := iter.Current()
    fmt.Printf("Project: %s\n", project.Name)
}

if err := iter.Err(); err != nil {
    log.Fatal(err)
}

Update a Project

project, err := client.Cloud.Projects.Update(context.Background(), 
    cloud.ProjectUpdateParams{
        ProjectID:   gcore.Int(projectID),
        Name:        gcore.String("updated-name"),
        Description: gcore.String("Updated description"),
    },
)

Get Project Details

project, err := client.Cloud.Projects.Get(context.Background(), 
    cloud.ProjectGetParams{
        ProjectID: gcore.Int(projectID),
    },
)

Delete a Project

// Delete and wait for completion
err := client.Cloud.Projects.DeleteAndPoll(context.Background(), 
    cloud.ProjectDeleteParams{
        ProjectID: gcore.Int(projectID),
    },
)
if err != nil {
    log.Fatal(err)
}

Common Use Cases

Organizing Resources by Environment

Create separate projects for different environments:
envs := []string{"development", "staging", "production"}

for _, env := range envs {
    project, err := client.Cloud.Projects.New(context.Background(), 
        cloud.ProjectNewParams{
            Name:        fmt.Sprintf("myapp-%s", env),
            Description: gcore.String(fmt.Sprintf("%s environment", env)),
        },
    )
    if err != nil {
        log.Fatal(err)
    }
    fmt.Printf("Created %s project: %d\n", env, project.ID)
}

Finding Projects by Name

projects, err := client.Cloud.Projects.List(context.Background(), 
    cloud.ProjectListParams{
        Name: gcore.String("production"),
    },
)

Build docs developers (and LLMs) love