Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into test_csv_import
Browse files Browse the repository at this point in the history
  • Loading branch information
khareyash05 committed Jun 23, 2023
2 parents 55ae1d1 + 908a0a3 commit e3a116f
Show file tree
Hide file tree
Showing 56 changed files with 2,253 additions and 1,086 deletions.
12 changes: 6 additions & 6 deletions addon/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ type Adapter struct {
// Tag API.
Tag Tag
// File API.
File File
File binding.File
// RuleSet API
RuleSet RuleSet
RuleSet binding.RuleSet
// client A REST client.
client *Client
}
Expand Down Expand Up @@ -135,11 +135,11 @@ func newAdapter() (adapter *Adapter) {
Tag: Tag{
client: client,
},
File: File{
client: client,
File: binding.File{
Client: client,
},
RuleSet: RuleSet{
client: client,
RuleSet: binding.RuleSet{
Client: client,
},
client: client,
}
Expand Down
49 changes: 28 additions & 21 deletions addon/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,57 +223,64 @@ func (h *AppFacts) Source(source string) {

//
// List facts.
func (h *AppFacts) List() (list []api.Fact, err error) {
list = []api.Fact{}
path := Path(api.ApplicationFactsRoot).Inject(Params{api.ID: h.appId})
err = h.client.Get(path, &list, Param{Key: api.Source, Value: h.source})
func (h *AppFacts) List() (facts api.FactMap, err error) {
facts = api.FactMap{}
key := api.FactKey("")
key.Qualify(h.source)
path := Path(api.ApplicationFactsRoot).Inject(Params{api.ID: h.appId, api.Key: key})
err = h.client.Get(path, &facts)
return
}

//
// Get a fact.
func (h *AppFacts) Get(key string) (fact *api.Fact, err error) {
func (h *AppFacts) Get(name string, value interface{}) (err error) {
key := api.FactKey(name)
key.Qualify(h.source)
path := Path(api.ApplicationFactRoot).Inject(
Params{
api.ID: h.appId,
api.Key: key,
api.Source: h.source,
api.ID: h.appId,
api.Key: key,
})
err = h.client.Get(path, fact)
err = h.client.Get(path, value)
return
}

//
// Set a fact (created as needed).
func (h *AppFacts) Set(key string, value interface{}) (err error) {
func (h *AppFacts) Set(name string, value interface{}) (err error) {
key := api.FactKey(name)
key.Qualify(h.source)
path := Path(api.ApplicationFactRoot).Inject(
Params{
api.ID: h.appId,
api.Key: key,
api.Source: h.source,
api.ID: h.appId,
api.Key: key,
})
err = h.client.Put(path, api.Fact{Value: value})
err = h.client.Put(path, value)
return
}

//
// Delete a fact.
func (h *AppFacts) Delete(key string) (err error) {
func (h *AppFacts) Delete(name string) (err error) {
key := api.FactKey(name)
key.Qualify(h.source)
path := Path(api.ApplicationFactRoot).Inject(
Params{
api.ID: h.appId,
api.Key: key,
api.Source: h.source,
api.ID: h.appId,
api.Key: key,
})
err = h.client.Delete(path)
return
}

//
// Replace facts.
func (h *AppFacts) Replace(facts []api.Fact) (err error) {
path := Path(api.ApplicationFactsRoot).Inject(Params{api.ID: h.appId})
err = h.client.Put(path, facts, Param{Key: api.Source, Value: h.source})
func (h *AppFacts) Replace(facts api.FactMap) (err error) {
key := api.FactKey("")
key.Qualify(h.source)
path := Path(api.ApplicationFactsRoot).Inject(Params{api.ID: h.appId, api.Key: key})
err = h.client.Put(path, facts)
return
}

Expand Down
Loading

0 comments on commit e3a116f

Please sign in to comment.