2017-01-24 15:09:23 +00:00
|
|
|
// Package database provides the Chrome Debugging Protocol
|
2017-02-12 04:59:33 +00:00
|
|
|
// commands, types, and events for the Database domain.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// Generated by the chromedp-gen command.
|
|
|
|
package database
|
|
|
|
|
|
|
|
// AUTOGENERATED. DO NOT EDIT.
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
cdp "github.com/knq/chromedp/cdp"
|
2017-01-24 15:09:23 +00:00
|
|
|
"github.com/mailru/easyjson"
|
|
|
|
)
|
|
|
|
|
|
|
|
// EnableParams enables database tracking, database events will now be
|
|
|
|
// delivered to the client.
|
|
|
|
type EnableParams struct{}
|
|
|
|
|
|
|
|
// Enable enables database tracking, database events will now be delivered to
|
|
|
|
// the client.
|
|
|
|
func Enable() *EnableParams {
|
|
|
|
return &EnableParams{}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Database.enable against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *EnableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
|
2017-01-24 15:09:23 +00:00
|
|
|
if ctxt == nil {
|
|
|
|
ctxt = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandDatabaseEnable, cdp.Empty)
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
// read response
|
|
|
|
select {
|
|
|
|
case res := <-ch:
|
|
|
|
if res == nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
return nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DisableParams disables database tracking, prevents database events from
|
|
|
|
// being sent to the client.
|
|
|
|
type DisableParams struct{}
|
|
|
|
|
|
|
|
// Disable disables database tracking, prevents database events from being
|
|
|
|
// sent to the client.
|
|
|
|
func Disable() *DisableParams {
|
|
|
|
return &DisableParams{}
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Database.disable against the provided context and
|
|
|
|
// target handler.
|
|
|
|
func (p *DisableParams) Do(ctxt context.Context, h cdp.Handler) (err error) {
|
2017-01-24 15:09:23 +00:00
|
|
|
if ctxt == nil {
|
|
|
|
ctxt = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandDatabaseDisable, cdp.Empty)
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
// read response
|
|
|
|
select {
|
|
|
|
case res := <-ch:
|
|
|
|
if res == nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
return nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
// GetDatabaseTableNamesParams [no description].
|
2017-01-24 15:09:23 +00:00
|
|
|
type GetDatabaseTableNamesParams struct {
|
2017-01-26 07:28:34 +00:00
|
|
|
DatabaseID ID `json:"databaseId"`
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
// GetDatabaseTableNames [no description].
|
|
|
|
//
|
2017-01-24 15:09:23 +00:00
|
|
|
// parameters:
|
2017-01-26 07:28:34 +00:00
|
|
|
// databaseID
|
|
|
|
func GetDatabaseTableNames(databaseID ID) *GetDatabaseTableNamesParams {
|
2017-01-24 15:09:23 +00:00
|
|
|
return &GetDatabaseTableNamesParams{
|
2017-01-26 07:28:34 +00:00
|
|
|
DatabaseID: databaseID,
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// GetDatabaseTableNamesReturns return values.
|
|
|
|
type GetDatabaseTableNamesReturns struct {
|
|
|
|
TableNames []string `json:"tableNames,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Database.getDatabaseTableNames against the provided context and
|
|
|
|
// target handler.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// tableNames
|
2017-02-12 04:59:33 +00:00
|
|
|
func (p *GetDatabaseTableNamesParams) Do(ctxt context.Context, h cdp.Handler) (tableNames []string, err error) {
|
2017-01-24 15:09:23 +00:00
|
|
|
if ctxt == nil {
|
|
|
|
ctxt = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// marshal
|
|
|
|
buf, err := easyjson.Marshal(p)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandDatabaseGetDatabaseTableNames, easyjson.RawMessage(buf))
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
// read response
|
|
|
|
select {
|
|
|
|
case res := <-ch:
|
|
|
|
if res == nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
// unmarshal
|
|
|
|
var r GetDatabaseTableNamesReturns
|
|
|
|
err = easyjson.Unmarshal(v, &r)
|
|
|
|
if err != nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, cdp.ErrInvalidResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r.TableNames, nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return nil, v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return nil, ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
// ExecuteSQLParams [no description].
|
2017-01-24 15:09:23 +00:00
|
|
|
type ExecuteSQLParams struct {
|
2017-01-26 07:28:34 +00:00
|
|
|
DatabaseID ID `json:"databaseId"`
|
|
|
|
Query string `json:"query"`
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
// ExecuteSQL [no description].
|
|
|
|
//
|
2017-01-24 15:09:23 +00:00
|
|
|
// parameters:
|
2017-01-26 07:28:34 +00:00
|
|
|
// databaseID
|
2017-01-24 15:09:23 +00:00
|
|
|
// query
|
2017-01-26 07:28:34 +00:00
|
|
|
func ExecuteSQL(databaseID ID, query string) *ExecuteSQLParams {
|
2017-01-24 15:09:23 +00:00
|
|
|
return &ExecuteSQLParams{
|
2017-01-26 07:28:34 +00:00
|
|
|
DatabaseID: databaseID,
|
2017-01-24 15:09:23 +00:00
|
|
|
Query: query,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ExecuteSQLReturns return values.
|
|
|
|
type ExecuteSQLReturns struct {
|
|
|
|
ColumnNames []string `json:"columnNames,omitempty"`
|
|
|
|
Values []easyjson.RawMessage `json:"values,omitempty"`
|
|
|
|
SQLError *Error `json:"sqlError,omitempty"`
|
|
|
|
}
|
|
|
|
|
2017-02-12 04:59:33 +00:00
|
|
|
// Do executes Database.executeSQL against the provided context and
|
|
|
|
// target handler.
|
2017-01-24 15:09:23 +00:00
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// columnNames
|
|
|
|
// values
|
|
|
|
// sqlError
|
2017-02-12 04:59:33 +00:00
|
|
|
func (p *ExecuteSQLParams) Do(ctxt context.Context, h cdp.Handler) (columnNames []string, values []easyjson.RawMessage, sqlError *Error, err error) {
|
2017-01-24 15:09:23 +00:00
|
|
|
if ctxt == nil {
|
|
|
|
ctxt = context.Background()
|
|
|
|
}
|
|
|
|
|
|
|
|
// marshal
|
|
|
|
buf, err := easyjson.Marshal(p)
|
|
|
|
if err != nil {
|
|
|
|
return nil, nil, nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// execute
|
2017-01-26 07:28:34 +00:00
|
|
|
ch := h.Execute(ctxt, cdp.CommandDatabaseExecuteSQL, easyjson.RawMessage(buf))
|
2017-01-24 15:09:23 +00:00
|
|
|
|
|
|
|
// read response
|
|
|
|
select {
|
|
|
|
case res := <-ch:
|
|
|
|
if res == nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, nil, nil, cdp.ErrChannelClosed
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
switch v := res.(type) {
|
|
|
|
case easyjson.RawMessage:
|
|
|
|
// unmarshal
|
|
|
|
var r ExecuteSQLReturns
|
|
|
|
err = easyjson.Unmarshal(v, &r)
|
|
|
|
if err != nil {
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, nil, nil, cdp.ErrInvalidResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return r.ColumnNames, r.Values, r.SQLError, nil
|
|
|
|
|
|
|
|
case error:
|
|
|
|
return nil, nil, nil, v
|
|
|
|
}
|
|
|
|
|
|
|
|
case <-ctxt.Done():
|
2017-02-12 04:59:33 +00:00
|
|
|
return nil, nil, nil, ctxt.Err()
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|
|
|
|
|
2017-01-26 07:28:34 +00:00
|
|
|
return nil, nil, nil, cdp.ErrUnknownResult
|
2017-01-24 15:09:23 +00:00
|
|
|
}
|