github.com/kaleido-io/firefly@v0.0.0-20210622132723-8b4b6aacb971/test/e2e/restclient.go (about)

     1  // Copyright © 2021 Kaleido, Inc.
     2  //
     3  // SPDX-License-Identifier: Apache-2.0
     4  //
     5  // Licensed under the Apache License, Version 2.0 (the "License");
     6  // you may not use this file except in compliance with the License.
     7  // You may obtain a copy of the License at
     8  //
     9  //     http://www.apache.org/licenses/LICENSE-2.0
    10  //
    11  // Unless required by applicable law or agreed to in writing, software
    12  // distributed under the License is distributed on an "AS IS" BASIS,
    13  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  // See the License for the specific language governing permissions and
    15  // limitations under the License.
    16  
    17  package e2e
    18  
    19  import (
    20  	"github.com/go-resty/resty/v2"
    21  	"github.com/kaleido-io/firefly/pkg/fftypes"
    22  )
    23  
    24  var (
    25  	urlGetNamespaces     = "/namespaces"
    26  	urlBroadcastDatatype = "/namespaces/default/broadcast/datatype"
    27  	urlGetData           = "/namespaces/default/data"
    28  )
    29  
    30  func GetNamespaces(client *resty.Client) (*resty.Response, error) {
    31  	return client.R().
    32  		SetResult(&[]fftypes.Namespace{}).
    33  		Get(urlGetNamespaces)
    34  }
    35  
    36  func BroadcastDatatype(client *resty.Client, name string) (*resty.Response, error) {
    37  	return client.R().
    38  		SetBody(fftypes.Datatype{
    39  			Name:    name,
    40  			Version: "1",
    41  			Value: fftypes.Byteable(`
    42  			{
    43  				"type": "object",
    44  				"properties": {
    45  					"property1": {
    46  						"type": "string"
    47  					}
    48  				}// Copyright © 2021 Kaleido, Inc.
    49  				//
    50  				// SPDX-License-Identifier: Apache-2.0
    51  				//
    52  				// Licensed under the Apache License, Version 2.0 (the "License");
    53  				// you may not use this file except in compliance with the License.
    54  				// You may obtain a copy of the License at
    55  				//
    56  				//     http://www.apache.org/licenses/LICENSE-2.0
    57  				//
    58  				// Unless required by applicable law or agreed to in writing, software
    59  				// distributed under the License is distributed on an "AS IS" BASIS,
    60  				// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    61  				// See the License for the specific language governing permissions and
    62  				// limitations under the License.
    63  				
    64  				
    65  			}`),
    66  		}).Post(urlBroadcastDatatype)
    67  }
    68  
    69  func GetData(client *resty.Client) (*resty.Response, error) {
    70  	return client.R().
    71  		SetResult(&[]fftypes.Data{}).
    72  		Get(urlGetData)
    73  }