Documentation ¶
Overview ¶
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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.
Package helper consists of helping functions.
Copyright 2021 Michael Bungenstock ¶
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 ¶
- Variables
- func AddPagingFlags(params *api.PageParams, flags *pflag.FlagSet)
- func AddPagingFlagsToken(params *api.PageParams, flags *pflag.FlagSet)
- func CheckErr(err error)
- func CheckErrEOF(err error)
- func CheckErrInfo(err error)
- func CheckErrParams(params api.ParametersE) *api.Request
- func CheckErrs(err ...error)
- func PrintError(msg string, cmd *cobra.Command)
- type Configuration
- func (a *Configuration) AddAuthenticationFlags(cmd *cobra.Command)
- func (a *Configuration) NoDryRun() *api.AuthenticationConfig
- func (a *Configuration) Path(path ...string) string
- func (a *Configuration) ReadCache() bool
- func (a *Configuration) Sandboxed() util.PathProvider
- func (a *Configuration) UniqueSandboxPath(path ...string) string
- func (a *Configuration) Update(cmd *cobra.Command) error
- func (a *Configuration) Validate(cmd *cobra.Command) error
- func (a *Configuration) WriteCache() bool
- type Decoder
- type DownloadConfig
- type FileConfig
- type FileIterator
- type OutputConf
- func (o *OutputConf) AddOutputFlags(cmd *cobra.Command)
- func (o *OutputConf) AddOutputFlagsPaging(cmd *cobra.Command)
- func (o *OutputConf) PrintPaged(pager *Pager) error
- func (o *OutputConf) PrintResponse(res *http.Response, err error) error
- func (o *OutputConf) PrintTable(pager *Pager) error
- func (o *OutputConf) SetTransformation(tf Transformer)
- func (o *OutputConf) SetTransformationDesc(def string) error
- func (o *OutputConf) ValidateFlags() error
- type OutputType
- type Pager
- func (p *Pager) Call() error
- func (p *Pager) Next() bool
- func (p *Pager) OF(path ...string) *Pager
- func (p *Pager) P(params ...string) *Pager
- func (p *Pager) PF(path ...string) *Pager
- func (p *Pager) PP(path ...string) *Pager
- func (p *Pager) Prepare()
- func (p *Pager) Run() error
- func (p *Pager) RunOnce() error
- func (p *Pager) SetObjectHandler(f func(util.JSONResponse) error)
- func (p *Pager) SingleCall() (*http.Response, error)
- type RefTransformer
- type Transformer
- type TreeTransformer
Constants ¶
This section is empty.
Variables ¶
var ChannelLToS = ChannelSToL.Invert()
ChannelLToS maps long channel names to short ones
var ChannelSToL = util.Mapper{
"email": "https://ns.adobe.com/xdm/channel-types/email",
"offline": "https://ns.adobe.com/xdm/channel-types/offline",
"social": "https://ns.adobe.com/xdm/channel-types/social",
"web": "https://ns.adobe.com/xdm/channel-types/web",
}
ChannelSToL maps short channel names to long ones
var ContentLToS = ContentSToL.Invert()
ContentLToS maps long content names to short ones
var ContentSToL = util.Mapper{
"image": "https://ns.adobe.com/experience/offer-management/content-component-imagelink",
"text": "https://ns.adobe.com/experience/offer-management/content-component-text",
"html": "https://ns.adobe.com/experience/offer-management/content-component-html",
"json": "https://ns.adobe.com/experience/offer-management/content-component-json",
}
ContentSToL maps short content names to long ones
var FilterTypeSToL = util.Mapper{
"all": "allTags",
"any": "anyTags",
}
FilterTypeSToL maps short filter types to long ones
Functions ¶
func AddPagingFlags ¶ added in v0.3.2
func AddPagingFlags(params *api.PageParams, flags *pflag.FlagSet)
func AddPagingFlagsToken ¶ added in v0.3.2
func AddPagingFlagsToken(params *api.PageParams, flags *pflag.FlagSet)
func CheckErrEOF ¶
func CheckErrEOF(err error)
CheckErrEOF prints a user friendly error message to stderr but ignores EOF
func CheckErrInfo ¶ added in v0.3.1
func CheckErrInfo(err error)
func CheckErrParams ¶ added in v0.3.0
func CheckErrParams(params api.ParametersE) *api.Request
func CheckErrs ¶
func CheckErrs(err ...error)
CheckErrs prints a user friendly error message to stderr
func PrintError ¶ added in v0.3.1
Types ¶
type Configuration ¶ added in v0.2.0
type Configuration struct { Root *util.RootConfig Authentication *api.AuthenticationConfig Read bool Write bool }
Configuration encapsulates the global settings
func NewConfiguration ¶ added in v0.2.0
func NewConfiguration(gcfg *util.RootConfig) *Configuration
NewConfiguration creates an initialized Authentication object
func (*Configuration) AddAuthenticationFlags ¶ added in v0.2.0
func (a *Configuration) AddAuthenticationFlags(cmd *cobra.Command)
AddAuthenticationFlags adds all required flags for authentication
func (*Configuration) NoDryRun ¶ added in v0.2.0
func (a *Configuration) NoDryRun() *api.AuthenticationConfig
NoDryRun creates a copy of the current AuthenticationConfig and disables the dry-run falg
func (*Configuration) Path ¶ added in v0.2.0
func (a *Configuration) Path(path ...string) string
UniquePath generates a unique path based on the client id
func (*Configuration) ReadCache ¶ added in v0.2.0
func (a *Configuration) ReadCache() bool
ReadCache returns the read-cache flag
func (*Configuration) Sandboxed ¶ added in v0.2.0
func (a *Configuration) Sandboxed() util.PathProvider
func (*Configuration) UniqueSandboxPath ¶ added in v0.2.0
func (a *Configuration) UniqueSandboxPath(path ...string) string
UniqueSandboxPath generates a unique path based on the client id and sandbox name
func (*Configuration) Update ¶ added in v0.2.0
func (a *Configuration) Update(cmd *cobra.Command) error
Update loads the configuration and updates the command flags
func (*Configuration) Validate ¶ added in v0.2.0
func (a *Configuration) Validate(cmd *cobra.Command) error
Validate updates the command flags and validates the final configuration
func (*Configuration) WriteCache ¶ added in v0.2.0
func (a *Configuration) WriteCache() bool
WriteCache returns the write-cache flag
type Decoder ¶
type Decoder interface {
Decode(v interface{}) error
}
Decoder is either a YAML or JSON decoder
type DownloadConfig ¶ added in v0.2.0
type DownloadConfig struct {
Path string
}
type FileConfig ¶
FileConfig provides the path and format of a file
func (*FileConfig) AddFileFlag ¶
func (c *FileConfig) AddFileFlag(cmd *cobra.Command)
AddFileFlag adds the required file flags to the passed command
func (*FileConfig) AddMandatoryFileFlag ¶
func (c *FileConfig) AddMandatoryFileFlag(cmd *cobra.Command)
AddMandatoryFileFlag adds the required file flags to the passed command. --file becomes mandatory.
func (*FileConfig) Open ¶
func (c *FileConfig) Open() (*FileIterator, error)
Open opens the file and returns a *FileIterator
type FileIterator ¶
type FileIterator struct {
Decoder Decoder
}
FileIterator helps iterating multiple YAML documents in one file
func (*FileIterator) Load ¶
func (c *FileIterator) Load(obj interface{}) error
Load loads the next available document in the file
type OutputConf ¶
type OutputConf struct { Output string Default string Type OutputType Truncate bool Flush bool Paging bool // contains filtered or unexported fields }
OutputConf contains all options for the output
func (*OutputConf) AddOutputFlags ¶
func (o *OutputConf) AddOutputFlags(cmd *cobra.Command)
AddOutputFlags extends the passed command with flags for output
func (*OutputConf) AddOutputFlagsPaging ¶ added in v0.3.2
func (o *OutputConf) AddOutputFlagsPaging(cmd *cobra.Command)
AddOutputFlags extends the passed command with flags for output
func (*OutputConf) PrintPaged ¶ added in v0.3.0
func (o *OutputConf) PrintPaged(pager *Pager) error
func (*OutputConf) PrintResponse ¶ added in v0.3.0
func (o *OutputConf) PrintResponse(res *http.Response, err error) error
func (*OutputConf) PrintTable ¶ added in v0.2.0
func (o *OutputConf) PrintTable(pager *Pager) error
PrintTable prints out multiple JSON responses into one table
func (*OutputConf) SetTransformation ¶
func (o *OutputConf) SetTransformation(tf Transformer)
SetTransformation changes the Transformer object
func (*OutputConf) SetTransformationDesc ¶ added in v0.2.0
func (o *OutputConf) SetTransformationDesc(def string) error
SetTransformationDesc changes the Transformer object
func (*OutputConf) ValidateFlags ¶
func (o *OutputConf) ValidateFlags() error
ValidateFlags checks the passed flags
type OutputType ¶
type OutputType int
OutputType is used for the encoding of different output formats
const ( // JSONOut is used for JSON JSONOut OutputType = iota // JSONPathOut is used for JSON path JSONPathOut // YAMLOut is used for YAML YAMLOut // TableOut is used for tablized output TableOut // WideOut is used for wide tablized output WideOut // RawOut is used for raw output RawOut // PVOut is using two columns path and value PVOut // PVOut is using three columns name, value and path NVPOUT )
type Pager ¶ added in v0.3.0
type Pager struct { Func api.Func Auth *api.AuthenticationConfig Requests []*api.Request Context context.Context PageFilter []string ObjectFilter []string PagePath []string PageParams []string // contains filtered or unexported fields }
Pager executes a REST function and handles automatically the subsequent calls to get paged responses
func NewPager ¶ added in v0.3.0
NewPager creates an initialzed Pager object. It uses JSONFilter to process payload and paging data.
func (*Pager) OF ¶ added in v0.3.0
OF sets the object filter. The object is the payload of the JSON document
func (*Pager) P ¶ added in v0.3.0
P sets the page parameters. These are the URL query parameters which are necessary for the following paging requests
func (*Pager) SetObjectHandler ¶ added in v0.3.0
func (p *Pager) SetObjectHandler(f func(util.JSONResponse) error)
Add adds the handler for the payload with the passed path
type RefTransformer ¶ added in v0.3.0
type RefTransformer struct {
Path []string
}
func NewRefTransformer ¶ added in v0.3.0
func NewRefTransformer(path ...string) *RefTransformer
func (*RefTransformer) Header ¶ added in v0.3.0
func (t *RefTransformer) Header(wide bool) []string
func (*RefTransformer) Iterator ¶ added in v0.3.0
func (t *RefTransformer) Iterator(c *util.JSONCursor) (util.JSONResponse, error)
func (*RefTransformer) Preprocess ¶ added in v0.3.0
func (t *RefTransformer) Preprocess(i util.JSONResponse) error
type Transformer ¶
type Transformer interface { Header(wide bool) []string Preprocess(util.JSONResponse) error WriteRow(*util.Query, *util.RowWriter, bool) error Iterator(*util.JSONCursor) (util.JSONResponse, error) }
Transformer objects will implement transformation logic for certain OutputTypes
type TreeTransformer ¶ added in v0.3.0
type TreeTransformer struct {
Path []string
}
func NewTreeTransformer ¶ added in v0.3.0
func NewTreeTransformer(path ...string) *TreeTransformer
func (*TreeTransformer) Header ¶ added in v0.3.0
func (t *TreeTransformer) Header(wide bool) []string
func (*TreeTransformer) Iterator ¶ added in v0.3.0
func (t *TreeTransformer) Iterator(c *util.JSONCursor) (util.JSONResponse, error)
func (*TreeTransformer) Preprocess ¶ added in v0.3.0
func (t *TreeTransformer) Preprocess(i util.JSONResponse) error