Deliverable for D3.2

data_api.go 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. *
  3. *
  4. * Generated by: https://github.com/swagger-api/swagger-codegen.git
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. package swagger
  19. import (
  20. "net/url"
  21. "encoding/json"
  22. )
  23. type DataApi struct {
  24. Configuration Configuration
  25. }
  26. func NewDataApi() *DataApi {
  27. configuration := NewConfiguration()
  28. return &DataApi{
  29. Configuration: *configuration,
  30. }
  31. }
  32. func NewDataApiWithBasePath(basePath string) *DataApi {
  33. configuration := NewConfiguration()
  34. configuration.BasePath = basePath
  35. return &DataApi{
  36. Configuration: *configuration,
  37. }
  38. }
  39. /**
  40. * append data to a bucket, will create the bucket if it does not exist.
  41. * append data to a bucket, will create the bucket if it does not exist.
  42. *
  43. * @param body
  44. * @return void
  45. */
  46. func (a DataApi) Append(body ApiData) (*APIResponse, error) {
  47. var httpMethod = "Put"
  48. // create path and map variables
  49. path := a.Configuration.BasePath + "/data/"
  50. headerParams := make(map[string]string)
  51. queryParams := url.Values{}
  52. formParams := make(map[string]string)
  53. var postBody interface{}
  54. var fileName string
  55. var fileBytes []byte
  56. // add default headers if any
  57. for key := range a.Configuration.DefaultHeader {
  58. headerParams[key] = a.Configuration.DefaultHeader[key]
  59. }
  60. // to determine the Content-Type header
  61. localVarHttpContentTypes := []string{ "application/json", }
  62. // set Content-Type header
  63. localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
  64. if localVarHttpContentType != "" {
  65. headerParams["Content-Type"] = localVarHttpContentType
  66. }
  67. // to determine the Accept header
  68. localVarHttpHeaderAccepts := []string{
  69. "application/json",
  70. }
  71. // set Accept header
  72. localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
  73. if localVarHttpHeaderAccept != "" {
  74. headerParams["Accept"] = localVarHttpHeaderAccept
  75. }
  76. // body params
  77. postBody = &body
  78. httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
  79. if err != nil {
  80. return NewAPIResponse(httpResponse.RawResponse), err
  81. }
  82. return NewAPIResponse(httpResponse.RawResponse), err
  83. }
  84. /**
  85. * returns all of the data stored in a logical 'bucket' in the last 24 hours.
  86. * returns all of the data stored in a logical 'bucket' in the last 24 hours.
  87. *
  88. * @param bucketUid name of the 'bucket' of data
  89. * @return []ApiDataResponse
  90. */
  91. func (a DataApi) GetAll(bucketUid string) ([]ApiDataResponse, *APIResponse, error) {
  92. var httpMethod = "Get"
  93. // create path and map variables
  94. path := a.Configuration.BasePath + "/data/"
  95. headerParams := make(map[string]string)
  96. queryParams := url.Values{}
  97. formParams := make(map[string]string)
  98. var postBody interface{}
  99. var fileName string
  100. var fileBytes []byte
  101. // add default headers if any
  102. for key := range a.Configuration.DefaultHeader {
  103. headerParams[key] = a.Configuration.DefaultHeader[key]
  104. }
  105. queryParams.Add("bucket-uid", a.Configuration.APIClient.ParameterToString(bucketUid, ""))
  106. // to determine the Content-Type header
  107. localVarHttpContentTypes := []string{ "application/json", }
  108. // set Content-Type header
  109. localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes)
  110. if localVarHttpContentType != "" {
  111. headerParams["Content-Type"] = localVarHttpContentType
  112. }
  113. // to determine the Accept header
  114. localVarHttpHeaderAccepts := []string{
  115. "application/json",
  116. }
  117. // set Accept header
  118. localVarHttpHeaderAccept := a.Configuration.APIClient.SelectHeaderAccept(localVarHttpHeaderAccepts)
  119. if localVarHttpHeaderAccept != "" {
  120. headerParams["Accept"] = localVarHttpHeaderAccept
  121. }
  122. var successPayload = new([]ApiDataResponse)
  123. httpResponse, err := a.Configuration.APIClient.CallAPI(path, httpMethod, postBody, headerParams, queryParams, formParams, fileName, fileBytes)
  124. if err != nil {
  125. return *successPayload, NewAPIResponse(httpResponse.RawResponse), err
  126. }
  127. err = json.Unmarshal(httpResponse.Body(), &successPayload)
  128. return *successPayload, NewAPIResponse(httpResponse.RawResponse), err
  129. }