github.com/spinnaker/spin@v1.30.0/gateapi/api_executions_controller.go (about) 1 2 /* 3 * Spinnaker API 4 * 5 * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) 6 * 7 * API version: 1.0.0 8 * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) 9 */ 10 11 package swagger 12 13 import ( 14 "context" 15 "io/ioutil" 16 "net/http" 17 "net/url" 18 "strings" 19 "fmt" 20 "github.com/antihax/optional" 21 ) 22 23 // Linger please 24 var ( 25 _ context.Context 26 ) 27 28 type ExecutionsControllerApiService service 29 30 /* 31 ExecutionsControllerApiService Retrieves an ad-hoc collection of executions based on a number of user-supplied parameters. Either executionIds or pipelineConfigIds must be supplied in order to return any results. If both are supplied, an exception will be thrown. 32 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 33 * @param optional nil or *ExecutionsControllerApiGetLatestExecutionsByConfigIdsUsingGETOpts - Optional Parameters: 34 * @param "ExecutionIds" (optional.String) - A comma-separated list of executions to retrieve. Either this OR pipelineConfigIds must be supplied, but not both. 35 * @param "Expand" (optional.Bool) - Expands each execution object in the resulting list. If this value is missing, it is defaulted to true. 36 * @param "Limit" (optional.Int32) - The number of executions to return per pipeline configuration. Ignored if executionIds parameter is supplied. If this value is missing, it is defaulted to 1. 37 * @param "PipelineConfigIds" (optional.String) - A comma-separated list of pipeline configuration IDs to retrieve recent executions for. Either this OR pipelineConfigIds must be supplied, but not both. 38 * @param "Statuses" (optional.String) - A comma-separated list of execution statuses to filter by. Ignored if executionIds parameter is supplied. If this value is missing, it is defaulted to all statuses. 39 40 @return []interface{} 41 */ 42 43 type ExecutionsControllerApiGetLatestExecutionsByConfigIdsUsingGETOpts struct { 44 ExecutionIds optional.String 45 Expand optional.Bool 46 Limit optional.Int32 47 PipelineConfigIds optional.String 48 Statuses optional.String 49 } 50 51 func (a *ExecutionsControllerApiService) GetLatestExecutionsByConfigIdsUsingGET(ctx context.Context, localVarOptionals *ExecutionsControllerApiGetLatestExecutionsByConfigIdsUsingGETOpts) ([]interface{}, *http.Response, error) { 52 var ( 53 localVarHttpMethod = strings.ToUpper("Get") 54 localVarPostBody interface{} 55 localVarFileName string 56 localVarFileBytes []byte 57 localVarReturnValue []interface{} 58 ) 59 60 // create path and map variables 61 localVarPath := a.client.cfg.BasePath + "/executions" 62 63 localVarHeaderParams := make(map[string]string) 64 localVarQueryParams := url.Values{} 65 localVarFormParams := url.Values{} 66 67 if localVarOptionals != nil && localVarOptionals.ExecutionIds.IsSet() { 68 localVarQueryParams.Add("executionIds", parameterToString(localVarOptionals.ExecutionIds.Value(), "")) 69 } 70 if localVarOptionals != nil && localVarOptionals.Expand.IsSet() { 71 localVarQueryParams.Add("expand", parameterToString(localVarOptionals.Expand.Value(), "")) 72 } 73 if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { 74 localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) 75 } 76 if localVarOptionals != nil && localVarOptionals.PipelineConfigIds.IsSet() { 77 localVarQueryParams.Add("pipelineConfigIds", parameterToString(localVarOptionals.PipelineConfigIds.Value(), "")) 78 } 79 if localVarOptionals != nil && localVarOptionals.Statuses.IsSet() { 80 localVarQueryParams.Add("statuses", parameterToString(localVarOptionals.Statuses.Value(), "")) 81 } 82 // to determine the Content-Type header 83 localVarHttpContentTypes := []string{} 84 85 // set Content-Type header 86 localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 87 if localVarHttpContentType != "" { 88 localVarHeaderParams["Content-Type"] = localVarHttpContentType 89 } 90 91 // to determine the Accept header 92 localVarHttpHeaderAccepts := []string{"*/*"} 93 94 // set Accept header 95 localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 96 if localVarHttpHeaderAccept != "" { 97 localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 98 } 99 r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 100 if err != nil { 101 return localVarReturnValue, nil, err 102 } 103 104 localVarHttpResponse, err := a.client.callAPI(r) 105 if err != nil || localVarHttpResponse == nil { 106 return localVarReturnValue, localVarHttpResponse, err 107 } 108 109 localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 110 localVarHttpResponse.Body.Close() 111 if err != nil { 112 return localVarReturnValue, localVarHttpResponse, err 113 } 114 115 if localVarHttpResponse.StatusCode < 300 { 116 // If we succeed, return the data, otherwise pass on to decode error. 117 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 118 if err == nil { 119 return localVarReturnValue, localVarHttpResponse, err 120 } 121 } 122 123 if localVarHttpResponse.StatusCode >= 300 { 124 newErr := GenericSwaggerError{ 125 body: localVarBody, 126 error: localVarHttpResponse.Status, 127 } 128 129 if localVarHttpResponse.StatusCode == 200 { 130 var v []interface{} 131 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 132 if err != nil { 133 newErr.error = err.Error() 134 return localVarReturnValue, localVarHttpResponse, newErr 135 } 136 newErr.model = v 137 return localVarReturnValue, localVarHttpResponse, newErr 138 } 139 140 return localVarReturnValue, localVarHttpResponse, newErr 141 } 142 143 return localVarReturnValue, localVarHttpResponse, nil 144 } 145 146 /* 147 ExecutionsControllerApiService Search for pipeline executions using a combination of criteria. The returned list is sorted by buildTime (trigger time) in reverse order so that newer executions are first in the list. 148 * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). 149 * @param application Only includes executions that are part of this application. If this value is \"*\", results will include executions of all applications. 150 * @param optional nil or *ExecutionsControllerApiSearchForPipelineExecutionsByTriggerUsingGETOpts - Optional Parameters: 151 * @param "EventId" (optional.String) - Only includes executions that were triggered by a trigger with this eventId. 152 * @param "Expand" (optional.Bool) - Expands each execution object in the resulting list. If this value is missing, it is defaulted to false. 153 * @param "PipelineName" (optional.String) - Only includes executions that with this pipeline name. 154 * @param "Reverse" (optional.Bool) - Reverses the resulting list before it is paginated. If this value is missing, it is defaulted to false. 155 * @param "Size" (optional.Int32) - Sets the size of the resulting list for pagination. This value must be > 0. If this value is missing, it is defaulted to 10. 156 * @param "StartIndex" (optional.Int32) - Sets the first item of the resulting list for pagination. The list is 0-indexed. This value must be >= 0. If this value is missing, it is defaulted to 0. 157 * @param "Statuses" (optional.String) - Only includes executions with a status that is equal to a status provided in this field. The list of statuses should be given as a comma-delimited string. If this value is missing, includes executions of all statuses. Allowed statuses are: NOT_STARTED, RUNNING, PAUSED, SUSPENDED, SUCCEEDED, FAILED_CONTINUE, TERMINAL, CANCELED, REDIRECT, STOPPED, SKIPPED, BUFFERED. 158 * @param "Trigger" (optional.String) - Only includes executions that were triggered by a trigger that matches the subset of fields provided by this value. This value should be a base64-encoded string of a JSON representation of a trigger object. The comparison succeeds if the execution trigger contains all the fields of the input trigger, the fields are of the same type, and each value of the field \"matches\". The term \"matches\" is specific for each field's type: - For Strings: A String value in the execution's trigger matches the input trigger's String value if the former equals the latter (case-insensitive) OR if the former matches the latter as a regular expression. - For Maps: A Map value in the execution's trigger matches the input trigger's Map value if the former contains all keys of the latter and their values match. - For Collections: A Collection value in the execution's trigger matches the input trigger's Collection value if the former has a unique element that matches each element of the latter. - Every other value is compared using the Java \"equals\" method (Groovy \"==\" operator) 159 * @param "TriggerTimeEndBoundary" (optional.Int64) - Only includes executions that were built at or before the given time, represented as a Unix timestamp in ms (UTC). This value must be <= 9223372036854775807 (Long.MAX_VALUE) and >= the value of [triggerTimeStartBoundary], if provided. If this value is missing, it is defaulted to 9223372036854775807. 160 * @param "TriggerTimeStartBoundary" (optional.Int64) - Only includes executions that were built at or after the given time, represented as a Unix timestamp in ms (UTC). This value must be >= 0 and <= the value of [triggerTimeEndBoundary], if provided. If this value is missing, it is defaulted to 0. 161 * @param "TriggerTypes" (optional.String) - Only includes executions that were triggered by a trigger with a type that is equal to a type provided in this field. The list of trigger types should be a comma-delimited string. If this value is missing, results will includes executions of all trigger types. 162 163 @return []interface{} 164 */ 165 166 type ExecutionsControllerApiSearchForPipelineExecutionsByTriggerUsingGETOpts struct { 167 EventId optional.String 168 Expand optional.Bool 169 PipelineName optional.String 170 Reverse optional.Bool 171 Size optional.Int32 172 StartIndex optional.Int32 173 Statuses optional.String 174 Trigger optional.String 175 TriggerTimeEndBoundary optional.Int64 176 TriggerTimeStartBoundary optional.Int64 177 TriggerTypes optional.String 178 } 179 180 func (a *ExecutionsControllerApiService) SearchForPipelineExecutionsByTriggerUsingGET(ctx context.Context, application string, localVarOptionals *ExecutionsControllerApiSearchForPipelineExecutionsByTriggerUsingGETOpts) ([]interface{}, *http.Response, error) { 181 var ( 182 localVarHttpMethod = strings.ToUpper("Get") 183 localVarPostBody interface{} 184 localVarFileName string 185 localVarFileBytes []byte 186 localVarReturnValue []interface{} 187 ) 188 189 // create path and map variables 190 localVarPath := a.client.cfg.BasePath + "/applications/{application}/executions/search" 191 localVarPath = strings.Replace(localVarPath, "{"+"application"+"}", fmt.Sprintf("%v", application), -1) 192 193 localVarHeaderParams := make(map[string]string) 194 localVarQueryParams := url.Values{} 195 localVarFormParams := url.Values{} 196 197 if localVarOptionals != nil && localVarOptionals.EventId.IsSet() { 198 localVarQueryParams.Add("eventId", parameterToString(localVarOptionals.EventId.Value(), "")) 199 } 200 if localVarOptionals != nil && localVarOptionals.Expand.IsSet() { 201 localVarQueryParams.Add("expand", parameterToString(localVarOptionals.Expand.Value(), "")) 202 } 203 if localVarOptionals != nil && localVarOptionals.PipelineName.IsSet() { 204 localVarQueryParams.Add("pipelineName", parameterToString(localVarOptionals.PipelineName.Value(), "")) 205 } 206 if localVarOptionals != nil && localVarOptionals.Reverse.IsSet() { 207 localVarQueryParams.Add("reverse", parameterToString(localVarOptionals.Reverse.Value(), "")) 208 } 209 if localVarOptionals != nil && localVarOptionals.Size.IsSet() { 210 localVarQueryParams.Add("size", parameterToString(localVarOptionals.Size.Value(), "")) 211 } 212 if localVarOptionals != nil && localVarOptionals.StartIndex.IsSet() { 213 localVarQueryParams.Add("startIndex", parameterToString(localVarOptionals.StartIndex.Value(), "")) 214 } 215 if localVarOptionals != nil && localVarOptionals.Statuses.IsSet() { 216 localVarQueryParams.Add("statuses", parameterToString(localVarOptionals.Statuses.Value(), "")) 217 } 218 if localVarOptionals != nil && localVarOptionals.Trigger.IsSet() { 219 localVarQueryParams.Add("trigger", parameterToString(localVarOptionals.Trigger.Value(), "")) 220 } 221 if localVarOptionals != nil && localVarOptionals.TriggerTimeEndBoundary.IsSet() { 222 localVarQueryParams.Add("triggerTimeEndBoundary", parameterToString(localVarOptionals.TriggerTimeEndBoundary.Value(), "")) 223 } 224 if localVarOptionals != nil && localVarOptionals.TriggerTimeStartBoundary.IsSet() { 225 localVarQueryParams.Add("triggerTimeStartBoundary", parameterToString(localVarOptionals.TriggerTimeStartBoundary.Value(), "")) 226 } 227 if localVarOptionals != nil && localVarOptionals.TriggerTypes.IsSet() { 228 localVarQueryParams.Add("triggerTypes", parameterToString(localVarOptionals.TriggerTypes.Value(), "")) 229 } 230 // to determine the Content-Type header 231 localVarHttpContentTypes := []string{} 232 233 // set Content-Type header 234 localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) 235 if localVarHttpContentType != "" { 236 localVarHeaderParams["Content-Type"] = localVarHttpContentType 237 } 238 239 // to determine the Accept header 240 localVarHttpHeaderAccepts := []string{"*/*"} 241 242 // set Accept header 243 localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) 244 if localVarHttpHeaderAccept != "" { 245 localVarHeaderParams["Accept"] = localVarHttpHeaderAccept 246 } 247 r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) 248 if err != nil { 249 return localVarReturnValue, nil, err 250 } 251 252 localVarHttpResponse, err := a.client.callAPI(r) 253 if err != nil || localVarHttpResponse == nil { 254 return localVarReturnValue, localVarHttpResponse, err 255 } 256 257 localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) 258 localVarHttpResponse.Body.Close() 259 if err != nil { 260 return localVarReturnValue, localVarHttpResponse, err 261 } 262 263 if localVarHttpResponse.StatusCode < 300 { 264 // If we succeed, return the data, otherwise pass on to decode error. 265 err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 266 if err == nil { 267 return localVarReturnValue, localVarHttpResponse, err 268 } 269 } 270 271 if localVarHttpResponse.StatusCode >= 300 { 272 newErr := GenericSwaggerError{ 273 body: localVarBody, 274 error: localVarHttpResponse.Status, 275 } 276 277 if localVarHttpResponse.StatusCode == 200 { 278 var v []interface{} 279 err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")); 280 if err != nil { 281 newErr.error = err.Error() 282 return localVarReturnValue, localVarHttpResponse, newErr 283 } 284 newErr.model = v 285 return localVarReturnValue, localVarHttpResponse, newErr 286 } 287 288 return localVarReturnValue, localVarHttpResponse, newErr 289 } 290 291 return localVarReturnValue, localVarHttpResponse, nil 292 }