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.
Index ¶
- Variables
- func CheckErr(err error)
- func CheckErrEOF(err error)
- func CheckErrs(err ...error)
- 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) Print(paged api.Paged) error
- func (o *OutputConf) PrintTable(paged api.Paged) error
- func (o *OutputConf) SetTableTransformation(td *util.TableDescriptor)
- func (o *OutputConf) SetTransformation(tf Transformer)
- func (o *OutputConf) SetTransformationDesc(yaml string) error
- func (o *OutputConf) SetTransformationFile(path string) error
- func (o *OutputConf) StreamResult(i util.JSONResponse, err error)
- func (o *OutputConf) StreamResultRaw(res *http.Response, err error)
- func (o *OutputConf) ValidateFlags() error
- type OutputType
- type Transformer
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 CheckErrEOF ¶
func CheckErrEOF(err error)
CheckErrEOF prints a user friendly error message to stderr but ignores EOF
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
Type OutputType
// contains filtered or unexported fields
}
OutputConf contains all options for the output
func NewOutputConf ¶
func NewOutputConf(tf Transformer) *OutputConf
NewOutputConf creates an initialized OutputConf object
func (*OutputConf) AddOutputFlags ¶
func (o *OutputConf) AddOutputFlags(cmd *cobra.Command)
AddOutputFlags extends the passed command with flags for output
func (*OutputConf) PrintTable ¶ added in v0.2.0
func (o *OutputConf) PrintTable(paged api.Paged) error
func (*OutputConf) SetTableTransformation ¶ added in v0.2.0
func (o *OutputConf) SetTableTransformation(td *util.TableDescriptor)
SetTableTransformation changes the Transformer object
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(yaml string) error
SetTransformationDesc changes the Transformer object
func (*OutputConf) SetTransformationFile ¶ added in v0.2.0
func (o *OutputConf) SetTransformationFile(path string) error
SetTransformationFile changes the Transformer object
func (*OutputConf) StreamResult ¶ added in v0.2.0
func (o *OutputConf) StreamResult(i util.JSONResponse, err error)
StreamResult prints the object in the desired output format
func (*OutputConf) StreamResultRaw ¶ added in v0.2.0
func (o *OutputConf) StreamResultRaw(res *http.Response, err error)
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 // Wide is used for wide tablized output Wide // RawOut is used for raw output RawOut )
type Transformer ¶
type Transformer interface {
Header(wide bool) []string
Preprocess(util.JSONResponse) error
WriteRow(*util.Query, *util.RowWriter, bool) error
Iterator(io.ReadCloser) (util.JSONResponse, error)
}
Transformer objects will implement transformation logic for certain OutputTypes