func (k *KeyringClient) List(ctx context.Context, orgID *identity.ID,
	ownerID *identity.ID) ([]KeyringSection, error) {

	query := &url.Values{}

	if orgID != nil {
		query.Set("org_id", orgID.String())
	}
	if ownerID != nil {
		query.Set("owner_id", ownerID.String())
	}

	req, err := k.client.NewRequest("GET", "/keyrings", query, nil)
	if err != nil {
		log.Printf("Error building http request for GET /keyrings: %s", err)
		return nil, err
	}

	resp := []struct {
		Keyring *envelope.Signed  `json:"keyring"`
		Members json.RawMessage   `json:"members"`
		Claims  []envelope.Signed `json:"claims"`
	}{}

	_, err = k.client.Do(ctx, req, &resp)
	if err != nil {
		return nil, err
	}

	converted := make([]KeyringSection, len(resp))
	for i, k := range resp {
		if k.Keyring.Version == 1 {
			s := KeyringSectionV1{
				Keyring: k.Keyring,
			}
			err := json.Unmarshal(k.Members, &s.Members)
			if err != nil {
				return nil, err
			}
			converted[i] = &s
		} else {
			s := KeyringSectionV2{
				Keyring: k.Keyring,
				Claims:  k.Claims,
			}
			err := json.Unmarshal(k.Members, &s.Members)
			if err != nil {
				return nil, err
			}
			converted[i] = &s
		}
	}

	return converted, nil
}
// List retrieves an array of KeyringSections from the registry.
List retrieves an array of KeyringSections from the registry.
// List retrieves an array of KeyringSections from the registry .
func (k *KeyringClient) List(ctx context.Context, orgID *identity.ID,
	ownerID *identity.ID) ([]KeyringSection, error) {
	query := &url.Values{}
	if orgID != nil {
		query.Set("org_id", orgID.String())
	}
	if ownerID != nil {
		query.Set("owner_id", ownerID.String())
	}
	req, err := k.client.NewRequest("GET", "/keyrings", query, nil)
	if err != nil {
		log.Printf("Error building http request for GET /keyrings: %s", err)
		return nil, err
	}
	resp := []struct {
		Keyring *envelope.Signed  `json:"keyring"`
		Members json.RawMessage   `json:"members"`
		Claims  []envelope.Signed `json:"claims"`
	}{}
	_, err = k.client.Do(ctx, req, &resp)
	if err != nil {
		return nil, err
	}
	converted := make([]KeyringSection, len(resp))
	for i, k := range resp {
		if k.Keyring.Version == 1 {
			s := KeyringSectionV1{
				Keyring: k.Keyring,
			}
			err := json.Unmarshal(k.Members, &s.Members)
			if err != nil {
				return nil, err
			}
			converted[i] = &s
		} else {
			s := KeyringSectionV2{
				Keyring: k.Keyring,
				Claims:  k.Claims,
			}
			err := json.Unmarshal(k.Members, &s.Members)
			if err != nil {
				return nil, err
			}
			converted[i] = &s
		}
	}
	return converted, nil
}
func ( k * KeyringClient ) List ( ctx context . Context , orgID * identity . ID , ownerID * identity . ID ) ( [ ] KeyringSection , error ) { query := & url . Values { } if orgID != nil { query . Set ( " " , orgID . String ( ) ) } if ownerID != nil { query . Set ( " " , ownerID . String ( ) ) } req , err := k . client . NewRequest ( " " , " " , query , nil ) if err != nil { log . Printf ( " " , err ) return nil , err } resp := [ ] struct { Keyring * envelope . Signed `json:"keyring"` Members json . RawMessage `json:"members"` Claims [ ] envelope . Signed `json:"claims"` } { } _ , err = k . client . Do ( ctx , req , & resp ) if err != nil { return nil , err } converted := make ( [ ] KeyringSection , len ( resp ) ) for i , k := range resp { if k . Keyring . Version == 1 { s := KeyringSectionV1 { Keyring : k . Keyring , } err := json . Unmarshal ( k . Members , & s . Members ) if err != nil { return nil , err } converted [ i ] = & s } else { s := KeyringSectionV2 { Keyring : k . Keyring , Claims : k . Claims , } err := json . Unmarshal ( k . Members , & s . Members ) if err != nil { return nil , err } converted [ i ] = & s } } return converted , nil }
List retrieves an array of KeyringSections from the registry.
List retrieves an array of KeyringSections from the registry .