client

package
v0.0.28 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Copyright © 2018 Zechen Jiang <zechen@cloudcoreo.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2018 Zechen Jiang <zechen@cloudcoreo.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewError

func NewError(text string) error

NewError returns an error that formats as the given text.

Types

type Auth

type Auth struct {
	APIKey, SecretKey string
}

Auth struct for API and secret key

func (*Auth) SignRequest

func (a *Auth) SignRequest(req *http.Request) error

SignRequest method to sign all requests

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client struct

func MakeClient

func MakeClient(apiKey, secretKey, endpoint string) (*Client, error)

MakeClient make client

func (*Client) CreateCloudAccount

func (c *Client) CreateCloudAccount(ctx context.Context, input *CreateCloudAccountInput) (*CloudAccount, error)

CreateCloudAccount method to create a cloud object

func (*Client) CreateTeam added in v0.0.7

func (c *Client) CreateTeam(ctx context.Context, teamName, teamDescription string) (*Team, error)

CreateTeam method to create a new team

func (*Client) CreateToken

func (c *Client) CreateToken(ctx context.Context, name, description string) (*Token, error)

CreateToken method to create a token object

func (*Client) DeleteCloudAccountByID

func (c *Client) DeleteCloudAccountByID(ctx context.Context, teamID, cloudID string) error

DeleteCloudAccountByID method to delete cloud object

func (*Client) DeleteTokenByID

func (c *Client) DeleteTokenByID(ctx context.Context, tokenID string) error

DeleteTokenByID method to delete token object

func (*Client) Do

func (c *Client) Do(ctx context.Context, method, path string, body io.Reader, obj interface{}) error

Do performs an HTTP request with a given context - the response will be decoded into obj.

func (*Client) GetCloudAccountByID

func (c *Client) GetCloudAccountByID(ctx context.Context, teamID, cloudID string) (*CloudAccount, error)

GetCloudAccountByID method getting cloud account by user ID

func (*Client) GetCloudAccounts

func (c *Client) GetCloudAccounts(ctx context.Context, teamID string) ([]*CloudAccount, error)

GetCloudAccounts method for cloud command

func (*Client) GetRemoveConfig added in v0.0.23

func (c *Client) GetRemoveConfig(ctx context.Context, teamID, cloudID string) (*EventRemoveConfig, error)

GetRemoveConfig get the config for event stream removal from secure state

func (*Client) GetRoleCreationInfo added in v0.0.21

func (c *Client) GetRoleCreationInfo(ctx context.Context, input *CreateCloudAccountInput) (*RoleCreationInfo, error)

GetRoleCreationInfo returns the configuration for creating a new role

func (*Client) GetSetupConfig added in v0.0.20

func (c *Client) GetSetupConfig(ctx context.Context, teamID, cloudID string) (*EventStreamConfig, error)

GetSetupConfig get the config for event stream setup from secure state

func (*Client) GetTeamByID

func (c *Client) GetTeamByID(ctx context.Context, teamID string) (*Team, error)

GetTeamByID method to get Team info object by team ID

func (*Client) GetTeams

func (c *Client) GetTeams(ctx context.Context) ([]*Team, error)

GetTeams method to get Teams info array object

func (*Client) GetTokenByID

func (c *Client) GetTokenByID(ctx context.Context, tokenID string) (*Token, error)

GetTokenByID method for token command

func (*Client) GetTokens

func (c *Client) GetTokens(ctx context.Context) ([]*Token, error)

GetTokens method for token command

func (*Client) GetUser

func (c *Client) GetUser(ctx context.Context) (*User, error)

GetUser method for getting user info command

func (*Client) ReValidateRole added in v0.0.27

func (c *Client) ReValidateRole(ctx context.Context, teamID, cloudID string) (*RoleReValidationResult, error)

ReValidateRole checks role validation and re-validate it

func (*Client) ShowResultObject added in v0.0.19

func (c *Client) ShowResultObject(ctx context.Context, teamID, cloudID, level string) (*ResultObjectWrapper, error)

ShowResultObject shows violated objects. If the filter condition (teamID, cloudID in this case) is valid, objects will be filtered. Otherwise return all violation objects under this user account.

func (*Client) ShowResultRule added in v0.0.19

func (c *Client) ShowResultRule(ctx context.Context, teamID, cloudID, level string) ([]*ResultRule, error)

ShowResultRule show violated rules. If the filter condition (teamID, cloudID in this case) is valid, rules will be filtered. Otherwise return all violation rules under this user account.

func (*Client) UpdateCloudAccount added in v0.0.27

func (c *Client) UpdateCloudAccount(ctx context.Context, input *UpdateCloudAccountInput) (*CloudAccount, error)

UpdateCloudAccount updates cloud account

type CloudAccount

type CloudAccount struct {
	RoleID    string `json:"roleId"`
	RoleName  string `json:"roleName"`
	Links     []Link `json:"links"`
	ID        string `json:"id"`
	AccountID string `json:"accountId"`
	CloudPayLoad
}

CloudAccount Information

type CloudAccountInfo added in v0.0.19

type CloudAccountInfo struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

CloudAccountInfo records the info of a cloud account

type CloudInfo added in v0.0.27

type CloudInfo struct {
	Name         string   `json:"name"`
	Arn          string   `json:"arn"`
	ScanEnabled  bool     `json:"scanEnabled"`
	ScanInterval string   `json:"scanInterval"`
	ScanRegion   string   `json:"scanRegion"`
	ExternalID   string   `json:"externalId"`
	IsDraft      bool     `json:"isDraft"`
	Provider     string   `json:"provider"`
	Email        string   `json:"email"`
	UserName     string   `json:"username"`
	Environment  []string `json:"environment"`
}

type CloudPayLoad added in v0.0.20

type CloudPayLoad struct {
	CloudInfo
	TeamID string `json:"teamId"`
}

CloudPayLoad ...

type CreateCloudAccountInput added in v0.0.20

type CreateCloudAccountInput struct {
	TeamID      string
	CloudName   string
	RoleName    string
	ExternalID  string
	RoleArn     string
	Policy      string
	IsDraft     bool
	Email       string
	UserName    string
	Environment string
	ScanEnabled bool
	Provider    string
}

CreateCloudAccountInput for function CreateCloudAccount

type EventRemoveConfig added in v0.0.23

type EventRemoveConfig struct {
	StackName      string   `json:"stackName"`
	TopicName      string   `json:"topicName"`
	Regions        []string `json:"regions"`
	ArnType        string   `json:"arnType"`
	CloudAccountId string   `json:"cloudAccountId"`
}

EventRemoveConfig for event stream removal

type EventStreamConfig added in v0.0.20

type EventStreamConfig struct {
	TemplateURL     string   `json:"templateURL"`
	TopicName       string   `json:"topicName"`
	StackName       string   `json:"stackName"`
	DevtimeQueueArn string   `json:"devtimeQueueArn"`
	Version         string   `json:"version"`
	MonitorRule     string   `json:"monitorRule"`
	Regions         []string `json:"regions"`
}

EventStreamConfig for event stream setup

type Info added in v0.0.19

type Info struct {
	SuggestedAction          string `json:"suggested_action"`
	Link                     string `json:"link"`
	Description              string `json:"description"`
	DisplayName              string `json:"display_name"`
	Level                    string `json:"level"`
	Service                  string `json:"service"`
	Name                     string `json:"name"`
	Region                   string `json:"region"`
	IncludeViolationsInCount bool   `json:"include_violations_in_count"`
	TimeStamp                string `json:"timestamp"`
}

Info is the struct for rule_report

type Interceptor

type Interceptor func(*http.Request) error

Interceptor is a generic request interceptor, useful for modifying or canceling the request.

type Link struct {
	Ref    string `json:"ref"`
	Method string `json:"method"`
	Href   string `json:"href"`
}

Link struct

func GetLinkByRef

func GetLinkByRef(links []Link, ref string) (Link, error)

GetLinkByRef get link object for given property

type Option

type Option func(*clientOptions)

Option type

func WithInterceptor

func WithInterceptor(ci Interceptor) Option

WithInterceptor returns a ClientOption for adding an interceptor to a Client.

type ResultObject added in v0.0.19

type ResultObject struct {
	ID        string           `json:"id"`
	Info      Info             `json:"rule_report"`
	TInfo     TeamInfo         `json:"team"`
	CInfo     CloudAccountInfo `json:"cloud_account"`
	RunID     string           `json:"run_id"`
	RiskScore int              `json:"riskScore"`
}

The ResultObject struct decodes json file returned by webapp

type ResultObjectWrapper added in v0.0.24

type ResultObjectWrapper struct {
	Objects    []*ResultObject `json:"violations"`
	TotalItems *int            `json:"totalItems"`
}

ResultObjectWrapper contains an object array and number of total items

type ResultRule added in v0.0.19

type ResultRule struct {
	ID     string             `json:"id"`
	Info   Info               `json:"info"`
	TInfo  []TeamInfoWrapper  `json:"teamAndPlan"`
	CInfo  []CloudAccountInfo `json:"accounts"`
	Object int                `json:"objects"`
}

ResultRule struct decodes json file returned by webapp

type ResultRuleWrapper added in v0.0.28

type ResultRuleWrapper struct {
	Rules []*ResultRule `json:"rules"`
}

type RoleCreationInfo added in v0.0.21

type RoleCreationInfo struct {
	AwsAccount string
	ExternalID string
	RoleName   string
	Policy     string
}

RoleCreationInfo contains the info required for role creation

type RoleReValidationResult added in v0.0.27

type RoleReValidationResult struct {
	Message string `json:"message"`
	IsValid bool   `json:"isValid"`
}

RoleReValidationResult is the result for role re-validation

type Team

type Team struct {
	TeamName        string      `json:"teamName"`
	OwnerID         string      `json:"ownerId"`
	TeamIcon        string      `json:"teamIcon"`
	TeamDescription interface{} `json:"teamDescription"`
	Default         bool        `json:"default"`
	Links           []Link      `json:"links"`
	ID              string      `json:"id"`
}

Team for team information

type TeamInfo added in v0.0.19

type TeamInfo struct {
	Name string `json:"name"`
	ID   string `json:"id"`
}

TeamInfo records the info of a team

type TeamInfoWrapper added in v0.0.24

type TeamInfoWrapper struct {
	TeamInfo *TeamInfo `json:"team"`
}

TeamInfoWrapper is a wrapper for team Info

type Token

type Token struct {
	Name         string    `json:"name"`
	Description  string    `json:"description"`
	CreationDate time.Time `json:"creationDate"`
	Links        []Link    `json:"links"`
	ID           string    `json:"id"`
}

Token struct

type UpdateCloudAccountInput added in v0.0.27

type UpdateCloudAccountInput struct {
	CreateCloudAccountInput
	CloudId string
}

UpdateCloudAccountInput is the info needed for update cloud account

type User

type User struct {
	Username        string    `json:"username"`
	Email           string    `json:"email"`
	GravatarIconURL string    `json:"gravatarIconUrl"`
	CreatedAt       time.Time `json:"createdAt"`
	DefaultTeamID   string    `json:"defaultTeamId"`
	Links           []Link    `json:"links"`
	ID              string    `json:"id"`
}

User struct for api payload

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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