client

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2018 License: Apache-2.0 Imports: 21 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) 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) ShowResultObject added in v0.0.19

func (c *Client) ShowResultObject(ctx context.Context, teamID, cloudID, level string) ([]*ResultObject, 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.

type CloudAccount

type CloudAccount struct {
	TeamID   string `json:"teamId"`
	Name     string `json:"name"`
	RoleID   string `json:"roleId"`
	RoleName string `json:"roleName"`
	Links    []Link `json:"links"`
	ID       string `json:"id"`
}

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 CloudPayLoad added in v0.0.20

type CloudPayLoad 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"`
}

CloudPayLoad ...

type CreateCloudAccountInput added in v0.0.20

type CreateCloudAccountInput struct {
	TeamID          string
	AccessKeyID     string
	SecretAccessKey string
	CloudName       string
	RoleName        string
	ExternalID      string
	RoleArn         string
	AwsProfile      string
	AwsProfilePath  string
	Policy          string
}

CreateCloudAccountInput for function CreateCloudAccount

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"`
}

The ResultObject struct decodes json file returned by webapp

type ResultRule added in v0.0.19

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

ResultRule struct decodes json file returned by webapp

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