Skip to content

Commit

Permalink
chore: Cleanup comments (#2092)
Browse files Browse the repository at this point in the history
* Add missing doc to account

* Add missing doc to alert

* Add missing doc to comment

* Add missing doc to database

* Add missing doc to failover groups

* Add missing doc to file format

* Add missing doc to grants

* Add missing doc to masking policy

* Add missing doc to parameters

* Add missing doc to password policy

* Add missing doc to pipes

* Add missing replication function docs and fix name

* Add missing docs to resource monitor

* Add missing docs to roles

* Add missing docs to schema

* Add missing docs to sessions

* Add missing docs to share

* Add missing docs to user

* Add missing docs to warehouse
  • Loading branch information
sfc-gh-asawicki authored Oct 4, 2023
1 parent 07c4f14 commit 3a06a66
Show file tree
Hide file tree
Showing 21 changed files with 87 additions and 140 deletions.
5 changes: 5 additions & 0 deletions pkg/sdk/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
EditionBusinessCritical AccountEdition = "BUSINESS_CRITICAL"
)

// CreateAccountOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-account.
type CreateAccountOptions struct {
create bool `ddl:"static" sql:"CREATE"`
account bool `ddl:"static" sql:"ACCOUNT"`
Expand Down Expand Up @@ -79,6 +80,7 @@ func (c *accounts) Create(ctx context.Context, id AccountObjectIdentifier, opts
return validateAndExec(c.client, ctx, opts)
}

// AlterAccountOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-account.
type AlterAccountOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
account bool `ddl:"static" sql:"ACCOUNT"`
Expand Down Expand Up @@ -270,6 +272,7 @@ func (c *accounts) Alter(ctx context.Context, opts *AlterAccountOptions) error {
return validateAndExec(c.client, ctx, opts)
}

// ShowAccountOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-organisation-accounts.
type ShowAccountOptions struct {
show bool `ddl:"static" sql:"SHOW"`
accounts bool `ddl:"static" sql:"ORGANIZATION ACCOUNTS"`
Expand Down Expand Up @@ -386,6 +389,7 @@ func (c *accounts) ShowByID(ctx context.Context, id AccountObjectIdentifier) (*A
return nil, errObjectNotExistOrAuthorized
}

// DropAccountOptions is based on https://docs.snowflake.com/en/sql-reference/sql/drop-account.
type DropAccountOptions struct {
drop bool `ddl:"static" sql:"DROP"`
account bool `ddl:"static" sql:"ACCOUNT"`
Expand Down Expand Up @@ -413,6 +417,7 @@ func (c *accounts) Drop(ctx context.Context, id AccountObjectIdentifier, gracePe
return validateAndExec(c.client, ctx, opts)
}

// undropAccountOptions is based on https://docs.snowflake.com/en/sql-reference/sql/undrop-account.
type undropAccountOptions struct {
undrop bool `ddl:"static" sql:"UNDROP"`
account bool `ddl:"static" sql:"ACCOUNT"`
Expand Down
12 changes: 5 additions & 7 deletions pkg/sdk/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,19 @@ var (
)

type Alerts interface {
// Create creates a new alert.
Create(ctx context.Context, id SchemaObjectIdentifier, warehouse AccountObjectIdentifier, schedule string, condition string, action string, opts *CreateAlertOptions) error
// Alter modifies an existing alert.
Alter(ctx context.Context, id SchemaObjectIdentifier, opts *AlterAlertOptions) error
// Drop removes an alert.
Drop(ctx context.Context, id SchemaObjectIdentifier) error
// Show returns a list of alerts
Show(ctx context.Context, opts *ShowAlertOptions) ([]Alert, error)
// ShowByID returns an alert by ID
ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Alert, error)
// Describe returns the details of an alert.
Describe(ctx context.Context, id SchemaObjectIdentifier) (*AlertDetails, error)
}

// alerts implements Alerts
type alerts struct {
client *Client
}

// CreateAlertOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-alert.
type CreateAlertOptions struct {
create bool `ddl:"static" sql:"CREATE"`
OrReplace *bool `ddl:"keyword" sql:"OR REPLACE"`
Expand Down Expand Up @@ -105,6 +99,7 @@ var (
AlertStateSuspended AlertState = "suspended"
)

// AlterAlertOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-alert.
type AlterAlertOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
alert bool `ddl:"static" sql:"ALERT"`
Expand Down Expand Up @@ -172,6 +167,7 @@ func (v *alerts) Alter(ctx context.Context, id SchemaObjectIdentifier, opts *Alt
return err
}

// DropAlertOptions is based on https://docs.snowflake.com/en/sql-reference/sql/drop-alert.
type dropAlertOptions struct {
drop bool `ddl:"static" sql:"DROP"`
alert bool `ddl:"static" sql:"ALERT"`
Expand Down Expand Up @@ -204,6 +200,7 @@ func (v *alerts) Drop(ctx context.Context, id SchemaObjectIdentifier) error {
return err
}

// ShowAlertOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-alerts.
type ShowAlertOptions struct {
show bool `ddl:"static" sql:"SHOW"`
Terse *bool `ddl:"keyword" sql:"TERSE"`
Expand Down Expand Up @@ -303,6 +300,7 @@ func (v *alerts) ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*Aler
return nil, errObjectNotExistOrAuthorized
}

// describeAlertOptions is based on https://docs.snowflake.com/en/sql-reference/sql/desc-alert.
type describeAlertOptions struct {
describe bool `ddl:"static" sql:"DESCRIBE"`
alert bool `ddl:"static" sql:"ALERT"`
Expand Down
2 changes: 2 additions & 0 deletions pkg/sdk/comments.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type comments struct {

var _ Comments = (*comments)(nil)

// SetCommentOptions is based on https://docs.snowflake.com/en/sql-reference/sql/comment.
type SetCommentOptions struct {
comment bool `ddl:"static" sql:"COMMENT"`
IfExists *bool `ddl:"keyword" sql:"IF EXISTS"`
Expand Down Expand Up @@ -49,6 +50,7 @@ func (c *comments) Set(ctx context.Context, opts *SetCommentOptions) error {
return err
}

// SetColumnCommentOptions is based on https://docs.snowflake.com/en/sql-reference/sql/comment.
type SetColumnCommentOptions struct {
comment bool `ddl:"static" sql:"COMMENT"`
IfExists *bool `ddl:"keyword" sql:"IF EXISTS"`
Expand Down
23 changes: 11 additions & 12 deletions pkg/sdk/databases.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,17 @@ var (
)

type Databases interface {
// Create creates a database.
Create(ctx context.Context, id AccountObjectIdentifier, opts *CreateDatabaseOptions) error
// CreateShared creates a database from a shared database.
CreateShared(ctx context.Context, id AccountObjectIdentifier, shareID ExternalObjectIdentifier, opts *CreateSharedDatabaseOptions) error
// CreateSecondary creates a secondary database.
CreateSecondary(ctx context.Context, id AccountObjectIdentifier, primaryID ExternalObjectIdentifier, opts *CreateSecondaryDatabaseOptions) error
// Alter modifies an existing database
Alter(ctx context.Context, id AccountObjectIdentifier, opts *AlterDatabaseOptions) error
// AlterReplication modifies an existing database replica
AlterReplication(ctx context.Context, id AccountObjectIdentifier, opts *AlterDatabaseReplicationOptions) error
// AlterFailover modifies an existing database failover group
AlterFailover(ctx context.Context, id AccountObjectIdentifier, opts *AlterDatabaseFailoverOptions) error
// Drop removes a database.
Drop(ctx context.Context, id AccountObjectIdentifier, opts *DropDatabaseOptions) error
// Undrop restores the most recent version of a dropped database
Undrop(ctx context.Context, id AccountObjectIdentifier) error
// Show returns a list of databases.
Show(ctx context.Context, opts *ShowDatabasesOptions) ([]Database, error)
// ShowByID returns a database by ID
ShowByID(ctx context.Context, id AccountObjectIdentifier) (*Database, error)
// Describe returns the details of a database.
Describe(ctx context.Context, id AccountObjectIdentifier) (*DatabaseDetails, error)
// Use sets the active database for the current session.
Use(ctx context.Context, id AccountObjectIdentifier) error
}

Expand Down Expand Up @@ -144,6 +132,7 @@ func (row databaseRow) convert() *Database {
return database
}

// CreateDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-database.
type CreateDatabaseOptions struct {
create bool `ddl:"static" sql:"CREATE"`
OrReplace *bool `ddl:"keyword" sql:"OR REPLACE"`
Expand Down Expand Up @@ -186,6 +175,7 @@ func (v *databases) Create(ctx context.Context, id AccountObjectIdentifier, opts
return err
}

// CreateSharedDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-database.
type CreateSharedDatabaseOptions struct {
create bool `ddl:"static" sql:"CREATE"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -223,6 +213,7 @@ func (v *databases) CreateShared(ctx context.Context, id AccountObjectIdentifier
return err
}

// CreateSecondaryDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-database.
type CreateSecondaryDatabaseOptions struct {
create bool `ddl:"static" sql:"CREATE"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -258,6 +249,7 @@ func (v *databases) CreateSecondary(ctx context.Context, id AccountObjectIdentif
return err
}

// AlterDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-database.
type AlterDatabaseOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -341,6 +333,7 @@ func (v *databases) Alter(ctx context.Context, id AccountObjectIdentifier, opts
return err
}

// AlterDatabaseReplicationOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-database.
type AlterDatabaseReplicationOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -406,6 +399,7 @@ func (v *databases) AlterReplication(ctx context.Context, id AccountObjectIdenti
return err
}

// AlterDatabaseFailoverOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-database.
type AlterDatabaseFailoverOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -470,6 +464,7 @@ func (v *databases) AlterFailover(ctx context.Context, id AccountObjectIdentifie
return err
}

// DropDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/drop-database.
type DropDatabaseOptions struct {
drop bool `ddl:"static" sql:"DROP"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -500,6 +495,7 @@ func (v *databases) Drop(ctx context.Context, id AccountObjectIdentifier, opts *
return err
}

// undropDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/undrop-database.
type undropDatabaseOptions struct {
undrop bool `ddl:"static" sql:"UNDROP"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -528,6 +524,7 @@ func (v *databases) Undrop(ctx context.Context, id AccountObjectIdentifier) erro
return err
}

// ShowDatabasesOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-databases.
type ShowDatabasesOptions struct {
show bool `ddl:"static" sql:"SHOW"`
Terse *bool `ddl:"keyword" sql:"TERSE"`
Expand Down Expand Up @@ -579,6 +576,7 @@ type DatabaseDetailsRow struct {
Kind string
}

// describeDatabaseOptions is based on https://docs.snowflake.com/en/sql-reference/sql/desc-database.
type describeDatabaseOptions struct {
describe bool `ddl:"static" sql:"DESCRIBE"`
database bool `ddl:"static" sql:"DATABASE"`
Expand Down Expand Up @@ -614,6 +612,7 @@ func (v *databases) Describe(ctx context.Context, id AccountObjectIdentifier) (*
return &details, err
}

// Use is based on https://docs.snowflake.com/en/sql-reference/sql/use-database.
func (v *databases) Use(ctx context.Context, id AccountObjectIdentifier) error {
// proxy to sessions
return v.client.Sessions.UseDatabase(ctx, id)
Expand Down
21 changes: 8 additions & 13 deletions pkg/sdk/failover_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"golang.org/x/exp/slices"
)

// Compile-time proof of interface implementation.
var _ FailoverGroups = (*failoverGroups)(nil)

var (
Expand All @@ -26,26 +25,15 @@ var (
_ validatable = new(describeDatabaseOptions)
)

// FailoverGroups describes all the failover group related methods that the
// Snowflake API supports.
type FailoverGroups interface {
// Create creates a new failover group.
Create(ctx context.Context, id AccountObjectIdentifier, objectTypes []PluralObjectType, allowedAccounts []AccountIdentifier, opts *CreateFailoverGroupOptions) error
// CreateSecondaryReplicationGroup creates a new secondary replication group.
CreateSecondaryReplicationGroup(ctx context.Context, id AccountObjectIdentifier, primaryFailoverGroupID ExternalObjectIdentifier, opts *CreateSecondaryReplicationGroupOptions) error
// Alter modifies an existing failover group in a source acount.
AlterSource(ctx context.Context, id AccountObjectIdentifier, opts *AlterSourceFailoverGroupOptions) error
// AlterTarget modifies an existing failover group in a target acount.
AlterTarget(ctx context.Context, id AccountObjectIdentifier, opts *AlterTargetFailoverGroupOptions) error
// Drop removes a failover group.
Drop(ctx context.Context, id AccountObjectIdentifier, opts *DropFailoverGroupOptions) error
// Show returns a list of failover groups.
Show(ctx context.Context, opts *ShowFailoverGroupOptions) ([]FailoverGroup, error)
// ShowByID returns a failover group by ID
ShowByID(ctx context.Context, id AccountObjectIdentifier) (*FailoverGroup, error)
// ShowDatabases returns a list of databases in a failover group.
ShowDatabases(ctx context.Context, id AccountObjectIdentifier) ([]AccountObjectIdentifier, error)
// ShowShares returns a list of shares in a failover group.
ShowShares(ctx context.Context, id AccountObjectIdentifier) ([]AccountObjectIdentifier, error)
}

Expand All @@ -63,6 +51,7 @@ const (
IntegrationTypeNotificationIntegrations IntegrationType = "NOTIFICATION INTEGRATIONS"
)

// CreateFailoverGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-failover-group.
type CreateFailoverGroupOptions struct {
create bool `ddl:"static" sql:"CREATE"`
failoverGroup bool `ddl:"static" sql:"FAILOVER GROUP"`
Expand Down Expand Up @@ -103,6 +92,7 @@ func (v *failoverGroups) Create(ctx context.Context, id AccountObjectIdentifier,
return err
}

// CreateSecondaryReplicationGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-failover-group.
type CreateSecondaryReplicationGroupOptions struct {
create bool `ddl:"static" sql:"CREATE"`
failoverGroup bool `ddl:"static" sql:"FAILOVER GROUP"`
Expand Down Expand Up @@ -138,6 +128,7 @@ func (v *failoverGroups) CreateSecondaryReplicationGroup(ctx context.Context, id
return err
}

// AlterSourceFailoverGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-failover-group.
type AlterSourceFailoverGroupOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
failoverGroup bool `ddl:"static" sql:"FAILOVER GROUP"`
Expand Down Expand Up @@ -244,6 +235,7 @@ func (v *failoverGroups) AlterSource(ctx context.Context, id AccountObjectIdenti
return err
}

// AlterTargetFailoverGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-failover-group.
type AlterTargetFailoverGroupOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
failoverGroup bool `ddl:"static" sql:"FAILOVER GROUP"`
Expand Down Expand Up @@ -281,6 +273,7 @@ func (v *failoverGroups) AlterTarget(ctx context.Context, id AccountObjectIdenti
return err
}

// DropFailoverGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/drop-failover-group.
type DropFailoverGroupOptions struct {
drop bool `ddl:"static" sql:"DROP"`
failoverGroup bool `ddl:"static" sql:"FAILOVER GROUP"`
Expand Down Expand Up @@ -314,7 +307,7 @@ func (v *failoverGroups) Drop(ctx context.Context, id AccountObjectIdentifier, o
return err
}

// ShowFailoverGroupOptions represents the options for listing failover groups.
// ShowFailoverGroupOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-failover-groups.
type ShowFailoverGroupOptions struct {
show bool `ddl:"static" sql:"SHOW"`
failoverGroups bool `ddl:"static" sql:"FAILOVER GROUPS"`
Expand Down Expand Up @@ -485,6 +478,7 @@ func (v *failoverGroups) ShowByID(ctx context.Context, id AccountObjectIdentifie
return nil, errObjectNotExistOrAuthorized
}

// showFailoverGroupDatabasesOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-databases-in-failover-group.
type showFailoverGroupDatabasesOptions struct {
show bool `ddl:"static" sql:"SHOW"`
databases bool `ddl:"static" sql:"DATABASES"`
Expand Down Expand Up @@ -523,6 +517,7 @@ func (v *failoverGroups) ShowDatabases(ctx context.Context, id AccountObjectIden
return resultList, nil
}

// showFailoverGroupSharesOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-shares-in-failover-group.
type showFailoverGroupSharesOptions struct {
show bool `ddl:"static" sql:"SHOW"`
databases bool `ddl:"static" sql:"SHARES"`
Expand Down
11 changes: 5 additions & 6 deletions pkg/sdk/file_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,11 @@ var (
)

type FileFormats interface {
// Create creates a FileFormat.
Create(ctx context.Context, id SchemaObjectIdentifier, opts *CreateFileFormatOptions) error
// Alter modifies an existing FileFormat
Alter(ctx context.Context, id SchemaObjectIdentifier, opts *AlterFileFormatOptions) error
// Drop removes a FileFormat.
Drop(ctx context.Context, id SchemaObjectIdentifier, opts *DropFileFormatOptions) error
// Show returns a list of fileFormats.
Show(ctx context.Context, opts *ShowFileFormatsOptions) ([]FileFormat, error)
// ShowByID returns a FileFormat by ID
ShowByID(ctx context.Context, id SchemaObjectIdentifier) (*FileFormat, error)
// Describe returns the details of a FileFormat.
Describe(ctx context.Context, id SchemaObjectIdentifier) (*FileFormatDetails, error)
}

Expand Down Expand Up @@ -326,6 +320,7 @@ type NullString struct {
S string `ddl:"parameter,no_equals,single_quotes"`
}

// CreateFileFormatOptions is based on https://docs.snowflake.com/en/sql-reference/sql/create-file-format.
type CreateFileFormatOptions struct {
create bool `ddl:"static" sql:"CREATE"`
OrReplace *bool `ddl:"keyword" sql:"OR REPLACE"`
Expand Down Expand Up @@ -374,6 +369,7 @@ func (v *fileFormats) Create(ctx context.Context, id SchemaObjectIdentifier, opt
return err
}

// AlterFileFormatOptions is based on https://docs.snowflake.com/en/sql-reference/sql/alter-file-format.
type AlterFileFormatOptions struct {
alter bool `ddl:"static" sql:"ALTER"`
fileFormat bool `ddl:"static" sql:"FILE FORMAT"`
Expand Down Expand Up @@ -600,6 +596,7 @@ func (v *fileFormats) Alter(ctx context.Context, id SchemaObjectIdentifier, opts
return err
}

// DropFileFormatOptions is based on https://docs.snowflake.com/en/sql-reference/sql/drop-file-format.
type DropFileFormatOptions struct {
drop bool `ddl:"static" sql:"DROP"`
fileFormat string `ddl:"static" sql:"FILE FORMAT"`
Expand Down Expand Up @@ -627,6 +624,7 @@ func (v *fileFormats) Drop(ctx context.Context, id SchemaObjectIdentifier, opts
return err
}

// ShowFileFormatsOptions is based on https://docs.snowflake.com/en/sql-reference/sql/show-file-formats.
type ShowFileFormatsOptions struct {
show bool `ddl:"static" sql:"SHOW"`
fileFormats bool `ddl:"static" sql:"FILE FORMATS"`
Expand Down Expand Up @@ -680,6 +678,7 @@ type FileFormatDetailsRow struct {
Property_Default string
}

// describeFileFormatOptions is based on https://docs.snowflake.com/en/sql-reference/sql/desc-file-format.
type describeFileFormatOptions struct {
describe bool `ddl:"static" sql:"DESCRIBE"`
fileFormat string `ddl:"static" sql:"FILE FORMAT"`
Expand Down
Loading

0 comments on commit 3a06a66

Please sign in to comment.