2017-01-24 15:09:23 +00:00
|
|
|
// Package database provides the Chrome Debugging Protocol
|
|
|
|
// commands, types, and events for the Chrome Database domain.
|
|
|
|
//
|
|
|
|
// 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{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes Database.enable.
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *EnableParams) Do(ctxt context.Context, h cdp.FrameHandler) (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-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrContextDone
|
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{}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes Database.disable.
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *DisableParams) Do(ctxt context.Context, h cdp.FrameHandler) (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-01-26 07:28:34 +00:00
|
|
|
return cdp.ErrContextDone
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes Database.getDatabaseTableNames.
|
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// tableNames
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *GetDatabaseTableNamesParams) Do(ctxt context.Context, h cdp.FrameHandler) (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-01-26 07:28:34 +00:00
|
|
|
return nil, cdp.ErrContextDone
|
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"`
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do executes Database.executeSQL.
|
|
|
|
//
|
|
|
|
// returns:
|
|
|
|
// columnNames
|
|
|
|
// values
|
|
|
|
// sqlError
|
2017-01-26 07:28:34 +00:00
|
|
|
func (p *ExecuteSQLParams) Do(ctxt context.Context, h cdp.FrameHandler) (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-01-26 07:28:34 +00:00
|
|
|
return nil, nil, nil, cdp.ErrContextDone
|
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
|
|
|
}
|