diff --git a/harness/nextgen/api_git_x_webhooks.go b/harness/nextgen/api_git_x_webhooks.go new file mode 100644 index 00000000..ab378ca8 --- /dev/null +++ b/harness/nextgen/api_git_x_webhooks.go @@ -0,0 +1,581 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +import ( + "context" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strings" + + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type GitXWebhooksApiService service + +/* +GitXWebhooksApiService Create a GitX webhook at Account level +Create GitXWebhook at account level + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *GitXWebhooksApiCreateGitxWebhookOpts - Optional Parameters: + * @param "Body" (optional.Interface of CreateGitXWebhookRequest) - Create GitX webhook request + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return CreateGitXWebhookResponse +*/ + +type GitXWebhooksApiCreateGitxWebhookOpts struct { + Body optional.Interface + HarnessAccount optional.String +} + +func (a *GitXWebhooksApiService) CreateGitxWebhook(ctx context.Context, localVarOptionals *GitXWebhooksApiCreateGitxWebhookOpts) (CreateGitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CreateGitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/gitx-webhooks" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + // body params + if localVarOptionals != nil && localVarOptionals.Body.IsSet() { + + localVarOptionalBody := localVarOptionals.Body.Value() + localVarPostBody = &localVarOptionalBody + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 201 { + var v CreateGitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +GitXWebhooksApiService Deletes a GitX Webhook at Account level +Deletes a gitx webhooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *GitXWebhooksApiDeleteGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. + +*/ + +type GitXWebhooksApiDeleteGitxWebhookOpts struct { + HarnessAccount optional.String +} + +func (a *GitXWebhooksApiService) DeleteGitxWebhook(ctx context.Context, gitxWebhook string, localVarOptionals *GitXWebhooksApiDeleteGitxWebhookOpts) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil +} + +/* +GitXWebhooksApiService Fetch GitX Webhook at Account level +Fetch a gitx webhook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *GitXWebhooksApiGetGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return GitXWebhookResponse +*/ + +type GitXWebhooksApiGetGitxWebhookOpts struct { + HarnessAccount optional.String +} + +func (a *GitXWebhooksApiService) GetGitxWebhook(ctx context.Context, gitxWebhook string, localVarOptionals *GitXWebhooksApiGetGitxWebhookOpts) (GitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue GitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v GitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +GitXWebhooksApiService Lists all the GitX Webhooks at Account level +List GitX webhooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param optional nil or *GitXWebhooksApiListGitxWebhooksOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. + * @param "Page" (optional.Int32) - Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page + * @param "Limit" (optional.Int32) - Number of items to return per page. + * @param "WebhookIdentifier" (optional.String) - +@return []GitXWebhookResponse +*/ + +type GitXWebhooksApiListGitxWebhooksOpts struct { + HarnessAccount optional.String + Page optional.Int32 + Limit optional.Int32 + WebhookIdentifier optional.String +} + +func (a *GitXWebhooksApiService) ListGitxWebhooks(ctx context.Context, localVarOptionals *GitXWebhooksApiListGitxWebhooksOpts) ([]GitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []GitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/gitx-webhooks" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Page.IsSet() { + localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { + localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.WebhookIdentifier.IsSet() { + localVarQueryParams.Add("webhook_identifier", parameterToString(localVarOptionals.WebhookIdentifier.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v []GitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +GitXWebhooksApiService Updates a GitX Webhook at Account level +Update a Gitx webhook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *GitXWebhooksApiUpdateGitxWebhookOpts - Optional Parameters: + * @param "Body" (optional.Interface of UpdateGitXWebhookRequest) - Update GitX webhook request + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return UpdateGitXWebhookResponse +*/ + +type GitXWebhooksApiUpdateGitxWebhookOpts struct { + Body optional.Interface + HarnessAccount optional.String +} + +func (a *GitXWebhooksApiService) UpdateGitxWebhook(ctx context.Context, gitxWebhook string, localVarOptionals *GitXWebhooksApiUpdateGitxWebhookOpts) (UpdateGitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue UpdateGitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + // body params + if localVarOptionals != nil && localVarOptionals.Body.IsSet() { + + localVarOptionalBody := localVarOptionals.Body.Value() + localVarPostBody = &localVarOptionalBody + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v UpdateGitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/harness/nextgen/api_org_gitx_webhooks.go b/harness/nextgen/api_org_gitx_webhooks.go new file mode 100644 index 00000000..d5a512ad --- /dev/null +++ b/harness/nextgen/api_org_gitx_webhooks.go @@ -0,0 +1,591 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +import ( + "context" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strings" + + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type OrgGitxWebhooksApiService service + +/* +OrgGitxWebhooksApiService Create Org Level GitX webhook +Create GitXWebhook at org level + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param optional nil or *OrgGitxWebhooksApiCreateOrgGitxWebhookOpts - Optional Parameters: + * @param "Body" (optional.Interface of CreateGitXWebhookRequest) - Create GitX webhook request + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return CreateGitXWebhookResponse +*/ + +type OrgGitxWebhooksApiCreateOrgGitxWebhookOpts struct { + Body optional.Interface + HarnessAccount optional.String +} + +func (a *OrgGitxWebhooksApiService) CreateOrgGitxWebhook(ctx context.Context, org string, localVarOptionals *OrgGitxWebhooksApiCreateOrgGitxWebhookOpts) (CreateGitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CreateGitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/gitx-webhooks" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + // body params + if localVarOptionals != nil && localVarOptionals.Body.IsSet() { + + localVarOptionalBody := localVarOptionals.Body.Value() + localVarPostBody = &localVarOptionalBody + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v CreateGitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrgGitxWebhooksApiService Deletes a GitX Webhook at org level +Deletes a org level gitx webhooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *OrgGitxWebhooksApiDeleteOrgGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. + +*/ + +type OrgGitxWebhooksApiDeleteOrgGitxWebhookOpts struct { + HarnessAccount optional.String +} + +func (a *OrgGitxWebhooksApiService) DeleteOrgGitxWebhook(ctx context.Context, org string, gitxWebhook string, localVarOptionals *OrgGitxWebhooksApiDeleteOrgGitxWebhookOpts) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil +} + +/* +OrgGitxWebhooksApiService Fetch GitX Webhook at org level +Fetch a org level gitx webhook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *OrgGitxWebhooksApiGetOrgGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return GitXWebhookResponse +*/ + +type OrgGitxWebhooksApiGetOrgGitxWebhookOpts struct { + HarnessAccount optional.String +} + +func (a *OrgGitxWebhooksApiService) GetOrgGitxWebhook(ctx context.Context, org string, gitxWebhook string, localVarOptionals *OrgGitxWebhooksApiGetOrgGitxWebhookOpts) (GitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue GitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v GitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrgGitxWebhooksApiService Lists all the GitX Webhooks at Org level +List org level GitX webhooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param optional nil or *OrgGitxWebhooksApiListOrgGitxWebhooksOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. + * @param "Page" (optional.Int32) - Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page + * @param "Limit" (optional.Int32) - Number of items to return per page. + * @param "WebhookIdentifier" (optional.String) - +@return []GitXWebhookResponse +*/ + +type OrgGitxWebhooksApiListOrgGitxWebhooksOpts struct { + HarnessAccount optional.String + Page optional.Int32 + Limit optional.Int32 + WebhookIdentifier optional.String +} + +func (a *OrgGitxWebhooksApiService) ListOrgGitxWebhooks(ctx context.Context, org string, localVarOptionals *OrgGitxWebhooksApiListOrgGitxWebhooksOpts) ([]GitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []GitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/gitx-webhooks" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Page.IsSet() { + localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { + localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.WebhookIdentifier.IsSet() { + localVarQueryParams.Add("webhook_identifier", parameterToString(localVarOptionals.WebhookIdentifier.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v []GitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +OrgGitxWebhooksApiService Updates a GitX Webhook at org level +Update a org level Gitx webhook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *OrgGitxWebhooksApiUpdateOrgGitxWebhookOpts - Optional Parameters: + * @param "Body" (optional.Interface of UpdateGitXWebhookRequest) - Update GitX webhook request + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return UpdateGitXWebhookResponse +*/ + +type OrgGitxWebhooksApiUpdateOrgGitxWebhookOpts struct { + Body optional.Interface + HarnessAccount optional.String +} + +func (a *OrgGitxWebhooksApiService) UpdateOrgGitxWebhook(ctx context.Context, org string, gitxWebhook string, localVarOptionals *OrgGitxWebhooksApiUpdateOrgGitxWebhookOpts) (UpdateGitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue UpdateGitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + // body params + if localVarOptionals != nil && localVarOptionals.Body.IsSet() { + + localVarOptionalBody := localVarOptionals.Body.Value() + localVarPostBody = &localVarOptionalBody + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v UpdateGitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/harness/nextgen/api_project_gitx_webhooks.go b/harness/nextgen/api_project_gitx_webhooks.go new file mode 100644 index 00000000..ff254fb7 --- /dev/null +++ b/harness/nextgen/api_project_gitx_webhooks.go @@ -0,0 +1,601 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +import ( + "context" + "fmt" + "io/ioutil" + "net/http" + "net/url" + "strings" + + "github.com/antihax/optional" +) + +// Linger please +var ( + _ context.Context +) + +type ProjectGitxWebhooksApiService service + +/* +ProjectGitxWebhooksApiService Create Project level GitX webhook +Create GitXWebhook at project level + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param project Identifier field of the project the resource is scoped to + * @param optional nil or *ProjectGitxWebhooksApiCreateProjectGitxWebhookOpts - Optional Parameters: + * @param "Body" (optional.Interface of CreateGitXWebhookRequest) - Create GitX webhook request + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return CreateGitXWebhookResponse +*/ + +type ProjectGitxWebhooksApiCreateProjectGitxWebhookOpts struct { + Body optional.Interface + HarnessAccount optional.String +} + +func (a *ProjectGitxWebhooksApiService) CreateProjectGitxWebhook(ctx context.Context, org string, project string, localVarOptionals *ProjectGitxWebhooksApiCreateProjectGitxWebhookOpts) (CreateGitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Post") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue CreateGitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/projects/{project}/gitx-webhooks" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"project"+"}", fmt.Sprintf("%v", project), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + // body params + if localVarOptionals != nil && localVarOptionals.Body.IsSet() { + + localVarOptionalBody := localVarOptionals.Body.Value() + localVarPostBody = &localVarOptionalBody + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v CreateGitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ProjectGitxWebhooksApiService Deletes a GitX Webhook at project level +Deletes a project level gitx webhooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param project Identifier field of the project the resource is scoped to + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *ProjectGitxWebhooksApiDeleteProjectGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. + +*/ + +type ProjectGitxWebhooksApiDeleteProjectGitxWebhookOpts struct { + HarnessAccount optional.String +} + +func (a *ProjectGitxWebhooksApiService) DeleteProjectGitxWebhook(ctx context.Context, org string, project string, gitxWebhook string, localVarOptionals *ProjectGitxWebhooksApiDeleteProjectGitxWebhookOpts) (*http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Delete") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/projects/{project}/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"project"+"}", fmt.Sprintf("%v", project), -1) + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + return localVarHttpResponse, newErr + } + + return localVarHttpResponse, nil +} + +/* +ProjectGitxWebhooksApiService Fetch GitX Webhook at project level +Fetch a project level gitx webhook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param project Identifier field of the project the resource is scoped to + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *ProjectGitxWebhooksApiGetProjectGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return GitXWebhookResponse +*/ + +type ProjectGitxWebhooksApiGetProjectGitxWebhookOpts struct { + HarnessAccount optional.String +} + +func (a *ProjectGitxWebhooksApiService) GetProjectGitxWebhook(ctx context.Context, org string, project string, gitxWebhook string, localVarOptionals *ProjectGitxWebhooksApiGetProjectGitxWebhookOpts) (GitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue GitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/projects/{project}/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"project"+"}", fmt.Sprintf("%v", project), -1) + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v GitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ProjectGitxWebhooksApiService Lists all the GitX Webhooks at project level +List project level GitX webhooks + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param project Identifier field of the project the resource is scoped to + * @param optional nil or *ProjectGitxWebhooksApiListProjectGitxWebhookOpts - Optional Parameters: + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. + * @param "Page" (optional.Int32) - Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page + * @param "Limit" (optional.Int32) - Number of items to return per page. + * @param "WebhookIdentifier" (optional.String) - +@return []GitXWebhookResponse +*/ + +type ProjectGitxWebhooksApiListProjectGitxWebhookOpts struct { + HarnessAccount optional.String + Page optional.Int32 + Limit optional.Int32 + WebhookIdentifier optional.String +} + +func (a *ProjectGitxWebhooksApiService) ListProjectGitxWebhook(ctx context.Context, org string, project string, localVarOptionals *ProjectGitxWebhooksApiListProjectGitxWebhookOpts) ([]GitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Get") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue []GitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/projects/{project}/gitx-webhooks" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"project"+"}", fmt.Sprintf("%v", project), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + if localVarOptionals != nil && localVarOptionals.Page.IsSet() { + localVarQueryParams.Add("page", parameterToString(localVarOptionals.Page.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.Limit.IsSet() { + localVarQueryParams.Add("limit", parameterToString(localVarOptionals.Limit.Value(), "")) + } + if localVarOptionals != nil && localVarOptionals.WebhookIdentifier.IsSet() { + localVarQueryParams.Add("webhook_identifier", parameterToString(localVarOptionals.WebhookIdentifier.Value(), "")) + } + // to determine the Content-Type header + localVarHttpContentTypes := []string{} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v []GitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} + +/* +ProjectGitxWebhooksApiService Updates a GitX Webhook at project level +Update a project level Gitx webhook + * @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). + * @param org Identifier field of the organization the resource is scoped to + * @param project Identifier field of the project the resource is scoped to + * @param gitxWebhook GitX webhook identifier + * @param optional nil or *ProjectGitxWebhooksApiUpdateProjectGitxWebhookOpts - Optional Parameters: + * @param "Body" (optional.Interface of UpdateGitXWebhookRequest) - Update GitX webhook request + * @param "HarnessAccount" (optional.String) - Identifier field of the account the resource is scoped to. This is required for Authorization methods other than the x-api-key header. If you are using the x-api-key header, this can be skipped. +@return UpdateGitXWebhookResponse +*/ + +type ProjectGitxWebhooksApiUpdateProjectGitxWebhookOpts struct { + Body optional.Interface + HarnessAccount optional.String +} + +func (a *ProjectGitxWebhooksApiService) UpdateProjectGitxWebhook(ctx context.Context, org string, project string, gitxWebhook string, localVarOptionals *ProjectGitxWebhooksApiUpdateProjectGitxWebhookOpts) (UpdateGitXWebhookResponse, *http.Response, error) { + var ( + localVarHttpMethod = strings.ToUpper("Put") + localVarPostBody interface{} + localVarFileName string + localVarFileBytes []byte + localVarReturnValue UpdateGitXWebhookResponse + ) + + // create path and map variables + localVarPath := a.client.cfg.BasePath + "/v1/orgs/{org}/projects/{project}/gitx-webhooks/{gitx-webhook}" + localVarPath = strings.Replace(localVarPath, "{"+"org"+"}", fmt.Sprintf("%v", org), -1) + localVarPath = strings.Replace(localVarPath, "{"+"project"+"}", fmt.Sprintf("%v", project), -1) + localVarPath = strings.Replace(localVarPath, "{"+"gitx-webhook"+"}", fmt.Sprintf("%v", gitxWebhook), -1) + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := url.Values{} + localVarFormParams := url.Values{} + + // to determine the Content-Type header + localVarHttpContentTypes := []string{"application/json"} + + // set Content-Type header + localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes) + if localVarHttpContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHttpContentType + } + + // to determine the Accept header + localVarHttpHeaderAccepts := []string{"application/json"} + + // set Accept header + localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts) + if localVarHttpHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHttpHeaderAccept + } + if localVarOptionals != nil && localVarOptionals.HarnessAccount.IsSet() { + localVarHeaderParams["Harness-Account"] = parameterToString(localVarOptionals.HarnessAccount.Value(), "") + } + // body params + if localVarOptionals != nil && localVarOptionals.Body.IsSet() { + + localVarOptionalBody := localVarOptionals.Body.Value() + localVarPostBody = &localVarOptionalBody + } + if ctx != nil { + // API Key Authentication + if auth, ok := ctx.Value(ContextAPIKey).(APIKey); ok { + var key string + if auth.Prefix != "" { + key = auth.Prefix + " " + auth.Key + } else { + key = auth.Key + } + localVarHeaderParams["x-api-key"] = key + + } + } + r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHttpResponse, err := a.client.callAPI(r) + if err != nil || localVarHttpResponse == nil { + return localVarReturnValue, localVarHttpResponse, err + } + + localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body) + localVarHttpResponse.Body.Close() + if err != nil { + return localVarReturnValue, localVarHttpResponse, err + } + + if localVarHttpResponse.StatusCode < 300 { + // If we succeed, return the data, otherwise pass on to decode error. + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err == nil { + return localVarReturnValue, localVarHttpResponse, err + } + } + + if localVarHttpResponse.StatusCode >= 300 { + newErr := GenericSwaggerError{ + body: localVarBody, + error: localVarHttpResponse.Status, + } + if localVarHttpResponse.StatusCode == 200 { + var v UpdateGitXWebhookResponse + err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHttpResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHttpResponse, newErr + } + return localVarReturnValue, localVarHttpResponse, newErr + } + + return localVarReturnValue, localVarHttpResponse, nil +} diff --git a/harness/nextgen/client.go b/harness/nextgen/client.go index 62838ef5..94f32f30 100644 --- a/harness/nextgen/client.go +++ b/harness/nextgen/client.go @@ -214,7 +214,10 @@ type APIClient struct { WebhookTriggersApi *WebhookTriggersApiService - WorkspaceApi *WorkspacesApiService + WorkspaceApi *WorkspacesApiService + GitXWebhooksApiService *GitXWebhooksApiService + ProjectGitxWebhooksApiService *ProjectGitxWebhooksApiService + OrgGitxWebhooksApiService *OrgGitxWebhooksApiService } type service struct { @@ -317,6 +320,9 @@ func NewAPIClient(cfg *Configuration) *APIClient { c.WebhookEventHandlerApi = (*WebhookEventHandlerApiService)(&c.common) c.WebhookTriggersApi = (*WebhookTriggersApiService)(&c.common) c.WorkspaceApi = (*WorkspacesApiService)(&c.common) + c.GitXWebhooksApiService = (*GitXWebhooksApiService)(&c.common) + c.ProjectGitxWebhooksApiService = (*ProjectGitxWebhooksApiService)(&c.common) + c.OrgGitxWebhooksApiService = (*OrgGitxWebhooksApiService)(&c.common) return c } diff --git a/harness/nextgen/model_create_git_x_webhook_request.go b/harness/nextgen/model_create_git_x_webhook_request.go new file mode 100644 index 00000000..e3c64b98 --- /dev/null +++ b/harness/nextgen/model_create_git_x_webhook_request.go @@ -0,0 +1,19 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Contains information about the GitX webhook creation request +type CreateGitXWebhookRequest struct { + WebhookIdentifier string `json:"webhook_identifier,omitempty"` + RepoName string `json:"repo_name,omitempty"` + ConnectorRef string `json:"connector_ref,omitempty"` + FolderPaths []string `json:"folder_paths,omitempty"` + WebhookName string `json:"webhook_name,omitempty"` +} diff --git a/harness/nextgen/model_create_git_x_webhook_response.go b/harness/nextgen/model_create_git_x_webhook_response.go new file mode 100644 index 00000000..e7375c4e --- /dev/null +++ b/harness/nextgen/model_create_git_x_webhook_response.go @@ -0,0 +1,15 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Contains information about the GitX webhook creation +type CreateGitXWebhookResponse struct { + WebhookIdentifier string `json:"webhook_identifier,omitempty"` +} diff --git a/harness/nextgen/model_git_x_webhook_event_response.go b/harness/nextgen/model_git_x_webhook_event_response.go new file mode 100644 index 00000000..ea280a90 --- /dev/null +++ b/harness/nextgen/model_git_x_webhook_event_response.go @@ -0,0 +1,26 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Contains information about the GitX webhook Events +type GitXWebhookEventResponse struct { + AuthorName string `json:"author_name,omitempty"` + EventIdentifier string `json:"event_identifier,omitempty"` + WebhookIdentifier string `json:"webhook_identifier,omitempty"` + Payload string `json:"payload,omitempty"` + EventTriggerTime int64 `json:"event_trigger_time,omitempty"` + RepoName string `json:"repo_name,omitempty"` + EventStatus string `json:"event_status,omitempty"` + CommitMessage string `json:"commit_message,omitempty"` + CommitId string `json:"commit_id,omitempty"` + CommitUrl string `json:"commit_url,omitempty"` + FileCount int32 `json:"file_count,omitempty"` + FailureFileCount int32 `json:"failure_file_count,omitempty"` +} diff --git a/harness/nextgen/model_git_x_webhook_response.go b/harness/nextgen/model_git_x_webhook_response.go new file mode 100644 index 00000000..1c3f0f94 --- /dev/null +++ b/harness/nextgen/model_git_x_webhook_response.go @@ -0,0 +1,21 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Contains information about the GitX webhooks +type GitXWebhookResponse struct { + WebhookIdentifier string `json:"webhook_identifier,omitempty"` + WebhookName string `json:"webhook_name,omitempty"` + ConnectorRef string `json:"connector_ref,omitempty"` + RepoName string `json:"repo_name,omitempty"` + FolderPaths []string `json:"folder_paths,omitempty"` + IsEnabled bool `json:"is_enabled,omitempty"` + EventTriggerTime int64 `json:"event_trigger_time,omitempty"` +} diff --git a/harness/nextgen/model_update_git_x_webhook_event_request.go b/harness/nextgen/model_update_git_x_webhook_event_request.go new file mode 100644 index 00000000..7d878f7d --- /dev/null +++ b/harness/nextgen/model_update_git_x_webhook_event_request.go @@ -0,0 +1,15 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Update GitX Webhook Event Request +type UpdateGitXWebhookEventRequest struct { + EventStatus string `json:"event_status,omitempty"` +} diff --git a/harness/nextgen/model_update_git_x_webhook_request.go b/harness/nextgen/model_update_git_x_webhook_request.go new file mode 100644 index 00000000..a8d876f5 --- /dev/null +++ b/harness/nextgen/model_update_git_x_webhook_request.go @@ -0,0 +1,19 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Contains information about the GitX webhook updation +type UpdateGitXWebhookRequest struct { + RepoName string `json:"repo_name,omitempty"` + WebhookName string `json:"webhook_name,omitempty"` + FolderPaths []string `json:"folder_paths,omitempty"` + IsEnabled bool `json:"is_enabled,omitempty"` + ConnectorRef string `json:"connector_ref,omitempty"` +} diff --git a/harness/nextgen/model_update_git_x_webhook_response.go b/harness/nextgen/model_update_git_x_webhook_response.go new file mode 100644 index 00000000..67e363a2 --- /dev/null +++ b/harness/nextgen/model_update_git_x_webhook_response.go @@ -0,0 +1,15 @@ +/* + * Harness NextGen Software Delivery Platform API Reference + * + * The Harness Software Delivery Platform uses OpenAPI Specification v3.0. Harness constantly improves these APIs. Please be aware that some improvements could cause breaking changes. # Introduction The Harness API allows you to integrate and use all the services and modules we provide on the Harness Platform. If you use client-side SDKs, Harness functionality can be integrated with your client-side automation, helping you reduce manual efforts and deploy code faster. For more information about how Harness works, read our [documentation](https://developer.harness.io/docs/getting-started) or visit the [Harness Developer Hub](https://developer.harness.io/). ## How it works The Harness API is a RESTful API that uses standard HTTP verbs. You can send requests in JSON, YAML, or form-data format. The format of the response matches the format of your request. You must send a single request at a time and ensure that you include your authentication key. For more information about this, go to [Authentication](#section/Introduction/Authentication). ## Get started Before you start integrating, get to know our API better by reading the following topics: * [Harness key concepts](https://developer.harness.io/docs/getting-started/learn-harness-key-concepts/) * [Authentication](#section/Introduction/Authentication) * [Requests and responses](#section/Introduction/Requests-and-Responses) * [Common Parameters](#section/Introduction/Common-Parameters-Beta) * [Status Codes](#section/Introduction/Status-Codes) * [Errors](#tag/Error-Response) * [Versioning](#section/Introduction/Versioning-Beta) * [Pagination](/#section/Introduction/Pagination-Beta) The methods you need to integrate with depend on the functionality you want to use. Work with your Harness Solutions Engineer to determine which methods you need. ## Authentication To authenticate with the Harness API, you need to: 1. Generate an API token on the Harness Platform. 2. Send the API token you generate in the `x-api-key` header in each request. ### Generate an API token To generate an API token, complete the following steps: 1. Go to the [Harness Platform](https://app.harness.io/). 2. On the left-hand navigation, click **My Profile**. 3. Click **+API Key**, enter a name for your key and then click **Save**. 4. Within the API Key tile, click **+Token**. 5. Enter a name for your token and click **Generate Token**. **Important**: Make sure to save your token securely. Harness does not store the API token for future reference, so make sure to save your token securely before you leave the page. ### Send the API token in your requests Send the token you created in the Harness Platform in the x-api-key header. For example: `x-api-key: YOUR_API_KEY_HERE` ## Requests and Responses The structure for each request and response is outlined in the API documentation. We have examples in JSON and YAML for every request and response. You can use our online editor to test the examples. ## Common Parameters [Beta] | Field Name | Type | Default | Description | |------------|---------|---------|----------------| | identifier | string | none | URL-friendly version of the name, used to identify a resource within it's scope and so needs to be unique within the scope. | | name | string | none | Human-friendly name for the resource. | | org | string | none | Limit to provided org identifiers. | | project | string | none | Limit to provided project identifiers. | | description| string | none | More information about the specific resource. | | tags | map[string]string | none | List of labels applied to the resource. | | order | string | desc | Order to use when sorting the specified fields. Type: enum(asc,desc). | | sort | string | none | Fields on which to sort. Note: Specify the fields that you want to use for sorting. When doing so, consider the operational overhead of sorting fields. | | limit | int | 30 | Pagination: Number of items to return. | | page | int | 1 | Pagination page number strategy: Specify the page number within the paginated collection related to the number of items in each page. | | created | int64 | none | Unix timestamp that shows when the resource was created (in milliseconds). | | updated | int64 | none | Unix timestamp that shows when the resource was last edited (in milliseconds). | ## Status Codes Harness uses conventional HTTP status codes to indicate the status of an API request. Generally, 2xx responses are reserved for success and 4xx status codes are reserved for failures. A 5xx response code indicates an error on the Harness server. | Error Code | Description | |-------------|-------------| | 200 | OK | | 201 | Created | | 202 | Accepted | | 204 | No Content | | 400 | Bad Request | | 401 | Unauthorized | | 403 | Forbidden | | 412 | Precondition Failed | | 415 | Unsupported Media Type | | 500 | Server Error | To view our error response structures, go [here](#tag/Error-Response). ## Versioning [Beta] ### Harness Version The current version of our Beta APIs is yet to be announced. The version number will use the date-header format and will be valid only for our Beta APIs. ### Generation All our beta APIs are versioned as a Generation, and this version is included in the path to every API resource. For example, v1 beta APIs begin with `app.harness.io/v1/`, where v1 is the API Generation. The version number represents the core API and does not change frequently. The version number changes only if there is a significant departure from the basic underpinnings of the existing API. For example, when Harness performs a system-wide refactoring of core concepts or resources. ## Pagination [Beta] We use pagination to place limits on the number of responses associated with list endpoints. Pagination is achieved by the use of limit query parameters. The limit defaults to 30. Its maximum value is 100. Following are the pagination headers supported in the response bodies of paginated APIs: 1. X-Total-Elements : Indicates the total number of entries in a paginated response. 2. X-Page-Number : Indicates the page number currently returned for a paginated response. 3. X-Page-Size : Indicates the number of entries per page for a paginated response. For example: ``` X-Total-Elements : 30 X-Page-Number : 0 X-Page-Size : 10 ``` + * + * API version: 1.0 + * Contact: contact@harness.io + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package nextgen + +// Contains information about the GitX webhook updation +type UpdateGitXWebhookResponse struct { + WebhookIdentifier string `json:"webhook_identifier,omitempty"` +}