GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — scim/list_response.go at master · nick-behrens/scim Expand file tree/ Copy pathlist_response.goMore file actions 65 lines (56 loc) · 2.04 KB / Copy pathlist_response.goFile metadata and controls65 lines (56 loc) · 2.04 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 package scim import ( "encoding/json" ) // Page represents a paginated resource query response. type Page struct { // TotalResults is the total number of results returned by the list or query operation. TotalResults int // Resources is a multi-valued list of complex objects containing the requested resources. Resources []Resource } func (p Page) resources(resourceType ResourceType) []interface{} { // If the page.Resources is nil, then it will also be represented as a `null` in the response. // Otherwise is it is an empty slice then it will result in an empty array `[]`. if len(p.Resources) == 0 { if p.Resources != nil { return []interface{}{} } return nil } var resources []interface{} for _, v := range p.Resources { resources = append( resources, v.response(resourceType), ) } return resources } // listResponse identifies a query response. type listResponse struct { // TotalResults is the total number of results returned by the list or query operation. // The value may be larger than the number of resources returned, such as when returning // a single page of results where multiple pages are available. // REQUIRED TotalResults int // MaxResults is the number of resources returned in a list response page. // REQUIRED when partial results are returned due to pagination. ItemsPerPage int // StartIndex is a 1-based index of the first result in the current set of the list results. // REQUIRED when partial results are returned due to pagination. StartIndex int // Resources is a multi-valued list of complex objects containing the requested resources. // This may be a subset of the full set of resources if pagination is requested. // REQUIRED if TotalResults is non-zero. Resources []interface{} } func (l listResponse) MarshalJSON() ([]byte, error) { return json.Marshal(map[string]interface{}{ "schemas": []string{"urn:ietf:params:scim:api:messages:2.0:ListResponse"}, "totalResults": l.TotalResults, "itemsPerPage": l.ItemsPerPage, "startIndex": l.StartIndex, "Resources": l.Resources, }) } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |