mirror of
https://github.com/rancher/norman.git
synced 2025-09-03 16:25:09 +00:00
more collection action code
This commit is contained in:
@@ -64,6 +64,10 @@ func (j *JSONResponseWriter) writeMapSlice(builder *builder.Builder, apiContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if apiContext.Schema.CollectionFormatter != nil {
|
||||||
|
apiContext.Schema.CollectionFormatter(apiContext, collection)
|
||||||
|
}
|
||||||
|
|
||||||
return collection
|
return collection
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -120,5 +120,17 @@ func (s *Store) traverseAndAdd(apiContext *types.APIContext, schema *types.Schem
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, action := range schema.CollectionActions {
|
||||||
|
for _, t := range []string{action.Output, action.Input} {
|
||||||
|
if t == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
if refSchema, ok := schemaMap[t]; ok && !included[t] {
|
||||||
|
schemas = s.addSchema(apiContext, refSchema, schemaMap, schemas, included)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return schemas
|
return schemas
|
||||||
}
|
}
|
||||||
|
@@ -262,3 +262,8 @@ func parseResponseURLBase(requestURL string, r *http.Request) (string, error) {
|
|||||||
func (u *urlBuilder) Action(action string, resource *types.RawResource) string {
|
func (u *urlBuilder) Action(action string, resource *types.RawResource) string {
|
||||||
return u.constructBasicURL(resource.Schema.Version, resource.Schema.PluralName, resource.ID) + "?action=" + url.QueryEscape(action)
|
return u.constructBasicURL(resource.Schema.Version, resource.Schema.PluralName, resource.ID) + "?action=" + url.QueryEscape(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *urlBuilder) CollectionAction(schema *types.Schema, versionOverride *types.APIVersion, action string) string {
|
||||||
|
collectionURL := u.Collection(schema, versionOverride)
|
||||||
|
return collectionURL + "?action=" + url.QueryEscape(action)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user