github.com/Jeffail/benthos/v3@v3.65.0/public/bloblang/view.go (about)

     1  package bloblang
     2  
     3  import (
     4  	"encoding/json"
     5  
     6  	"github.com/Jeffail/benthos/v3/internal/bloblang/query"
     7  )
     8  
     9  // FunctionView describes a particular function belonging to a Bloblang
    10  // environment.
    11  type FunctionView struct {
    12  	spec query.FunctionSpec
    13  }
    14  
    15  // Description provides an overview of the function.
    16  func (v *FunctionView) Description() string {
    17  	return v.spec.Description
    18  }
    19  
    20  // FormatJSON returns a byte slice of the function configuration formatted as a
    21  // JSON object. The schema of this method is undocumented and is not intended
    22  // for general use.
    23  //
    24  // Experimental: This method is not intended for general use and could have its
    25  // signature and/or behaviour changed outside of major version bumps.
    26  func (v *FunctionView) FormatJSON() ([]byte, error) {
    27  	return json.Marshal(v.spec)
    28  }
    29  
    30  // MethodView describes a particular method belonging to a Bloblang environment.
    31  type MethodView struct {
    32  	spec query.MethodSpec
    33  }
    34  
    35  // Description provides an overview of the method.
    36  func (v *MethodView) Description() string {
    37  	return v.spec.Description
    38  }
    39  
    40  // FormatJSON returns a byte slice of the method configuration formatted as a
    41  // JSON object. The schema of this method is undocumented and is not intended
    42  // for general use.
    43  //
    44  // Experimental: This method is not intended for general use and could have its
    45  // signature and/or behaviour changed outside of major version bumps.
    46  func (v *MethodView) FormatJSON() ([]byte, error) {
    47  	return json.Marshal(v.spec)
    48  }