jumpserver

package module
v0.0.0-...-3c4243e Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2019 License: MIT Imports: 10 Imported by: 0

README

jumpserver-go-sdk

jumpserver golang sdk

WIP!!!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 200 range. The caller is responsible to analyze the response body. The body can contain JSON (if the error is intended) or xml (sometimes JIRA just failes).

Types

type Asset

type Asset struct {
	Id           string   `json:"id"`
	OrgId        string   `json:"org_id"`
	Ip           string   `json:"ip"`
	Hostname     string   `json:"hostname"`
	Protocol     string   `json:"protocol"`
	Port         int      `json:"port"`
	Platform     string   `json:"platform"`
	IsActive     bool     `json:"is_active"`
	PublicIp     string   `json:"public_ip"`
	Number       string   `json:"number"`
	Vendor       string   `json:"vendor"`
	Model        string   `json:"model"`
	Sn           string   `json:"sn"`
	CpuModel     string   `json:"cpu_model"`
	CpuCount     string   `json:"cpu_count"`
	CpuCores     string   `json:"cpu_cores"`
	CpuVcpus     string   `json:"cpu_vcpus"`
	Memory       string   `json:"memory"`
	DiskTotal    string   `json:"disk_total"`
	DiskInfo     string   `json:"disk_info"`
	Os           string   `json:"os"`
	OsVersion    string   `json:"os_version"`
	OsArch       string   `json:"os_arch"`
	HostnameRaw  string   `json:"hostname_raw"`
	CreatedBy    string   `json:"created_by"`
	DateCreated  string   `json:"date_created"`
	Comment      string   `json:"comment"`
	Domain       string   `json:"domain"`
	AdminUser    string   `json:"admin_user"`
	Nodes        []string `json:"nodes"`
	Labels       []string `json:"labels"`
	HardwareInfo string   `json:"hardware_info"`
	Connectivity int      `json:"connectivity"`
	OrgName      string   `json:"org_name"`
}

User represents a GitHub user.

type AssetsService

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

UsersService handles communication with the user related methods of the GitHub API.

GitHub API docs: https://developer.github.com/v3/users/

func (*AssetsService) Get

func (s *AssetsService) Get(AssetId string) (*Asset, *Response, error)

func (*AssetsService) GetList

func (s *AssetsService) GetList() ([]*Asset, *Response, error)

func (*AssetsService) Search

func (s *AssetsService) Search(assetName string) ([]*Asset, *Response, error)

type AuthenticateInfo

type AuthenticateInfo struct {
	Token string `json:"token,omitempty"`
	User  *User  `json:"user"`
}

type BasicAuthTransport

type BasicAuthTransport struct {
	Username string // GitHub username
	Password string // GitHub password
	OTP      string // one-time password for users with two-factor auth enabled

	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password. It additionally supports users who have two-factor authentication enabled on their GitHub account.

func (*BasicAuthTransport) Client

func (t *BasicAuthTransport) Client() *http.Client

Client returns an *http.Client that makes requests that are authenticated using HTTP Basic Authentication.

func (*BasicAuthTransport) RoundTrip

func (t *BasicAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type Client

type Client struct {

	// Services used for talking to different parts of the JIRA API.
	Users  *UsersService
	Assets *AssetsService
	// contains filtered or unexported fields
}

A Client manages communication with the JIRA API.

func NewClient

func NewClient(httpClient httpClient, baseURL string) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*Response, error)

Do sends an API request and returns the API response. The API response is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occurred.

func (*Client) GetBaseURL

func (c *Client) GetBaseURL() url.URL

GetBaseURL will return you the Base URL. This is the same URL as in the NewClient constructor

func (*Client) NewRequest

func (c *Client) NewRequest(method, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request. A relative URL can be provided in urlStr, in which case it is resolved relative to the baseURL of the Client. If specified, the value pointed to by body is JSON encoded and included as the request body.

type Response

type Response struct {
	*http.Response

	StartAt    int
	MaxResults int
	Total      int

	NextPage  int
	PrevPage  int
	FirstPage int
	LastPage  int
}

Response represents JIRA API response. It wraps http.Response returned from API and provides information about paging.

type Timestamp

type Timestamp struct {
	time.Time
}

Timestamp represents a time that can be unmarshalled from a JSON string formatted as either an RFC3339 or Unix timestamp. This is necessary for some fields since the GitHub API is inconsistent in how it represents times. All exported methods of time.Time can be called on Timestamp.

func (Timestamp) Equal

func (t Timestamp) Equal(u Timestamp) bool

Equal reports whether t and u are equal based on time.Equal

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalJSON

func (t *Timestamp) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON implements the json.Unmarshaler interface. Time is expected in RFC3339 or Unix format.

type TokenAuthTransport

type TokenAuthTransport struct {
	Username string // JumpServer username
	Password string // JumpServer password
	AuthURL  string // JumpServer auth url

	Token string

	OTP string // one-time password for users with two-factor auth enabled

	// Transport is the underlying HTTP transport to use when making requests.
	// It will default to http.DefaultTransport if nil.
	Transport http.RoundTripper
}

BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password. It additionally supports users who have two-factor authentication enabled on their GitHub account.

func (*TokenAuthTransport) Client

func (t *TokenAuthTransport) Client() *http.Client

Client returns an *http.Client that makes requests that are authenticated using HTTP Basic Authentication.

func (*TokenAuthTransport) RoundTrip

func (t *TokenAuthTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements the RoundTripper interface.

type User

type User struct {
	Id                      string    `json:"id,omitempty"`
	Name                    string    `json:"name,omitempty"`
	Username                string    `json:"username,omitempty"`
	Email                   string    `json:"email,omitempty"`
	Groups                  *[]string `json:"groups,omitempty"`
	GroupsDisplay           string    `json:"groups_display,omitempty"`
	Role                    string    `json:"role,omitempty"`
	RoleDisplay             string    `json:"role_display,omitempty"`
	AvatarUrl               string    `json:"avatar_url,omitempty"`
	Wechat                  string    `json:"wechat,omitempty"`
	Phone                   string    `json:"phone,omitempty"`
	OtpLevel                *int      `json:"otp_level,omitempty"`
	Comment                 string    `json:"comment,omitempty"`
	Source                  string    `json:"source,omitempty"`
	SourceDisplay           string    `json:"source_display,omitempty"`
	IsValid                 *bool     `json:"is_valid,omitempty"`
	IsExpired               *bool     `json:"is_expired,omitempty"`
	IsActive                *bool     `json:"is_active,omitempty"`
	CreatedBy               string    `json:"created_by,omitempty"`
	IsFirstLogin            *bool     `json:"is_first_login,omitempty"`
	DatePasswordLastUpdated string    `json:"date_password_last_updated,omitempty"`
	DateExpired             string    `json:"date_expired,omitempty"`

	// API URLs
	URL               string `json:"url,omitempty"`
	EventsURL         string `json:"events_url,omitempty"`
	FollowingURL      string `json:"following_url,omitempty"`
	FollowersURL      string `json:"followers_url,omitempty"`
	GistsURL          string `json:"gists_url,omitempty"`
	OrganizationsURL  string `json:"organizations_url,omitempty"`
	ReceivedEventsURL string `json:"received_events_url,omitempty"`
	ReposURL          string `json:"repos_url,omitempty"`
	StarredURL        string `json:"starred_url,omitempty"`
	SubscriptionsURL  string `json:"subscriptions_url,omitempty"`

	// Permissions identifies the permissions that a user has on a given
	// repository. This is only populated when calling Repositories.ListCollaborators.
	Permissions *map[string]bool `json:"permissions,omitempty"`
}

User represents a GitHub user.

type UsersService

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

UsersService handles communication with the user related methods of the GitHub API.

GitHub API docs: https://developer.github.com/v3/users/

func (*UsersService) GetList

func (s *UsersService) GetList() ([]*User, *Response, error)

func (*UsersService) Search

func (s *UsersService) Search(username string) ([]*User, *Response, error)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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