Skip to content

Commit

Permalink
Merge pull request #2 from moira-alert/feature/move-on-go-swagger
Browse files Browse the repository at this point in the history
feature: move on go swagger
  • Loading branch information
kissken authored Aug 29, 2023
2 parents 252207d + dd4c822 commit 49dab40
Show file tree
Hide file tree
Showing 346 changed files with 37,338 additions and 16,075 deletions.
24 changes: 0 additions & 24 deletions .gitignore

This file was deleted.

23 changes: 0 additions & 23 deletions .swagger-codegen-ignore

This file was deleted.

1 change: 0 additions & 1 deletion .swagger-codegen/VERSION

This file was deleted.

252 changes: 110 additions & 142 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,151 +1,119 @@
# Go API client for swagger
# Go client for Moira

This is an API description for [Moira Alert API](https://moira.readthedocs.io/en/latest/overview.html) Check us out on [Github](https://github.com/moira-alert) or look up our [guide](https://moira.readthedocs.io) on getting started with Moira
If you're new here, better check out our main [README](https://github.com/moira-alert/moira/blob/master/README.md)

## Overview
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.

- API version: master
- Package version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.go.GoClientCodegen
This API client was generated by the [go-swagger](https://github.com/go-swagger/go-swagger) tool

Our current documentation is available on [swaggerhub](https://app.swaggerhub.com/apis/Moira/moira-alert/master) and on [our website](https://moira.skbkontur.ru/api/swagger/index.html)

## Installation
Put the package under your project folder and add the following in import:

Add the following in import:

```golang

import "github.com/moira-alert/client-go"

```

## Getting started

Initialize Moira client:

```golang
import "./swagger"
import (
httptransport "github.com/go-openapi/runtime/client"
"github.com/go-openapi/strfmt"
"github.com/moira-alert/client-go/pkg/client"
)

func main() {
config := client.DefaultTransportConfig().
WithBasePath("api").
WithHost("moira.skbkontur.ru").
WithSchemes([]string{"https"})

transport := httptransport.New(config.Host, config.BasePath, config.Schemes)
transport.Transport = newTransport() // Write a function here that creates an object that satisfies the http.RoundTripper interface

client := client.New(transport, strfmt.Default)
}
```

## Documentation for API Endpoints

All URIs are relative to */api*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*ConfigApi* | [**GetWebConfig**](docs/ConfigApi.md#getwebconfig) | **Get** /config | Get available configuration
*ContactApi* | [**CreateNewContact**](docs/ContactApi.md#createnewcontact) | **Put** /contact | Creates a new contact notification for the current user
*ContactApi* | [**GetAllContacts**](docs/ContactApi.md#getallcontacts) | **Get** /contact | Gets all Moira contacts
*ContactApi* | [**GetContactById**](docs/ContactApi.md#getcontactbyid) | **Get** /contact/{contactID} | Get contact by ID
*ContactApi* | [**GetContactEventsById**](docs/ContactApi.md#getcontacteventsbyid) | **Get** /contact/{contactID}/events | Get contact events by ID with time range
*ContactApi* | [**RemoveContact**](docs/ContactApi.md#removecontact) | **Delete** /contact/{contactID} | Deletes notification contact for the current user and remove the contact ID from all subscriptions
*ContactApi* | [**SendTestContactNotification**](docs/ContactApi.md#sendtestcontactnotification) | **Post** /contact/{contactID}/test | Push a test notification to verify that the contact is properly set up
*ContactApi* | [**UpdateContact**](docs/ContactApi.md#updatecontact) | **Put** /contact/{contactID} | Updates an existing notification contact to the values passed in the request body
*EventApi* | [**DeleteAllEvents**](docs/EventApi.md#deleteallevents) | **Delete** /event/all | Deletes all notification events
*EventApi* | [**GetEventsList**](docs/EventApi.md#geteventslist) | **Get** /event/{triggerID} | Gets all trigger events for current page and their count
*HealthApi* | [**GetNotifierState**](docs/HealthApi.md#getnotifierstate) | **Get** /health/notifier | Get notifier state
*NotificationApi* | [**DeleteNotification**](docs/NotificationApi.md#deletenotification) | **Delete** /notification | Delete a notification by id
*NotificationApi* | [**GetNotifications**](docs/NotificationApi.md#getnotifications) | **Get** /notification | Gets a paginated list of notifications, all notifications are fetched if end = -1 and start = 0
*PatternApi* | [**DeletePattern**](docs/PatternApi.md#deletepattern) | **Delete** /pattern/{pattern} | Deletes a Moira pattern
*PatternApi* | [**GetAllPatterns**](docs/PatternApi.md#getallpatterns) | **Get** /pattern | Get all patterns
*SubscriptionApi* | [**CreateSubscription**](docs/SubscriptionApi.md#createsubscription) | **Put** /subscription | Create a new subscription
*SubscriptionApi* | [**GetUserSubscriptions**](docs/SubscriptionApi.md#getusersubscriptions) | **Get** /subscription | Get all subscriptions
*SubscriptionApi* | [**RemoveSubscription**](docs/SubscriptionApi.md#removesubscription) | **Delete** /subscription/{subscriptionID} | Delete a subscription
*SubscriptionApi* | [**SendTestNotification**](docs/SubscriptionApi.md#sendtestnotification) | **Put** /subscription/{subscriptionID}/test | Send a test notification for a subscription
*SubscriptionApi* | [**UpdateSubscription**](docs/SubscriptionApi.md#updatesubscription) | **Put** /subscription/{subscriptionID} | Update a subscription
*TagApi* | [**GetAllTags**](docs/TagApi.md#getalltags) | **Get** /tag | Get all tags
*TagApi* | [**GetAllTagsAndSubscriptions**](docs/TagApi.md#getalltagsandsubscriptions) | **Get** /tag/stats | Get all tags and their subscriptions
*TagApi* | [**RemoveTag**](docs/TagApi.md#removetag) | **Delete** /tag/{tag} | Remove a tag
*TeamApi* | [**AddTeamUsers**](docs/TeamApi.md#addteamusers) | **Post** /teams/{teamID}/users | Add users to a team
*TeamApi* | [**CreateTeam**](docs/TeamApi.md#createteam) | **Post** /teams | Create a new team
*TeamApi* | [**DeleteTeam**](docs/TeamApi.md#deleteteam) | **Delete** /teams/{teamID} | Delete a team
*TeamApi* | [**DeleteTeamUser**](docs/TeamApi.md#deleteteamuser) | **Delete** /teams/{teamID}/users/{teamUserID} | Delete a user from a team
*TeamApi* | [**GetAllTeams**](docs/TeamApi.md#getallteams) | **Get** /teams | Get all teams
*TeamApi* | [**GetTeam**](docs/TeamApi.md#getteam) | **Get** /teams/{teamID} | Get a team by ID
*TeamApi* | [**GetTeamSettings**](docs/TeamApi.md#getteamsettings) | **Get** /teams/{teamID}/settings | Get team settings
*TeamApi* | [**GetTeamUsers**](docs/TeamApi.md#getteamusers) | **Get** /teams/{teamID}/users | Get users of a team
*TeamApi* | [**SetTeamUsers**](docs/TeamApi.md#setteamusers) | **Put** /teams/{teamID}/users | Set users of a team
*TeamApi* | [**UpdateTeam**](docs/TeamApi.md#updateteam) | **Patch** /teams/{teamID} | Update existing team
*TeamContactApi* | [**CreateNewTeamContact**](docs/TeamContactApi.md#createnewteamcontact) | **Post** /teams/{teamID}/contacts | Create a new team contact
*TeamSubscriptionApi* | [**CreateNewTeamSubscription**](docs/TeamSubscriptionApi.md#createnewteamsubscription) | **Post** /teams/{teamID}/subscriptions | Create a new team subscription
*TriggerApi* | [**CreateTrigger**](docs/TriggerApi.md#createtrigger) | **Put** /trigger | Create a new trigger
*TriggerApi* | [**DeleteTriggerMetric**](docs/TriggerApi.md#deletetriggermetric) | **Delete** /trigger/{triggerID}/metrics | Delete metric from last check and all trigger pattern metrics
*TriggerApi* | [**DeleteTriggerNodataMetrics**](docs/TriggerApi.md#deletetriggernodatametrics) | **Delete** /trigger/{triggerID}/metrics/nodata | Delete all metrics from last data which are in NODATA state. It also deletes all trigger patterns of those metrics
*TriggerApi* | [**DeleteTriggerThrottling**](docs/TriggerApi.md#deletetriggerthrottling) | **Delete** /trigger/{triggerID}/throttling | Deletes throttling for a trigger
*TriggerApi* | [**GetAllTriggers**](docs/TriggerApi.md#getalltriggers) | **Get** /trigger | Get all triggers
*TriggerApi* | [**GetTrigger**](docs/TriggerApi.md#gettrigger) | **Get** /trigger/{triggerID} | Get an existing trigger
*TriggerApi* | [**GetTriggerDump**](docs/TriggerApi.md#gettriggerdump) | **Get** /trigger/{triggerID}/dump | Get trigger dump
*TriggerApi* | [**GetTriggerMetrics**](docs/TriggerApi.md#gettriggermetrics) | **Get** /trigger/{triggerID}/metrics | Get metrics associated with certain trigger
*TriggerApi* | [**GetTriggerState**](docs/TriggerApi.md#gettriggerstate) | **Get** /trigger/{triggerID}/state | Get the trigger state as at last check
*TriggerApi* | [**GetTriggerThrottling**](docs/TriggerApi.md#gettriggerthrottling) | **Get** /trigger/{triggerID}/throttling | Get a trigger with its throttling i.e its next allowed message time
*TriggerApi* | [**RemoveTrigger**](docs/TriggerApi.md#removetrigger) | **Delete** /trigger/{triggerID} | Remove trigger
*TriggerApi* | [**RenderTriggerMetrics**](docs/TriggerApi.md#rendertriggermetrics) | **Get** /trigger/{triggerID}/render | Render trigger metrics plot
*TriggerApi* | [**SearchTriggers**](docs/TriggerApi.md#searchtriggers) | **Get** /trigger/search | Search triggers. Replaces the deprecated `page` path
*TriggerApi* | [**SetTriggerMaintenance**](docs/TriggerApi.md#settriggermaintenance) | **Put** /trigger/{triggerID}/setMaintenance | Set metrics and the trigger itself to maintenance mode
*TriggerApi* | [**TriggerCheck**](docs/TriggerApi.md#triggercheck) | **Put** /trigger/check | Validates trigger target
*TriggerApi* | [**TriggerPagersPagerIDDelete**](docs/TriggerApi.md#triggerpagerspageriddelete) | **Delete** /trigger/pagers/{pagerID} | Delete triggers pager
*TriggerApi* | [**UpdateTrigger**](docs/TriggerApi.md#updatetrigger) | **Put** /trigger/{triggerID} | Update existing trigger
*UserApi* | [**GetUserName**](docs/UserApi.md#getusername) | **Get** /user | Gets the username of the authenticated user if it is available
*UserApi* | [**GetUserSettings**](docs/UserApi.md#getusersettings) | **Get** /user/settings | Get the user's contacts and subscriptions

## Documentation For Models

- [AllOfdtoProblemOfTargetType_](docs/AllOfdtoProblemOfTargetType_.md)
- [AllOfdtoTriggerModelSched](docs/AllOfdtoTriggerModelSched.md)
- [AllOfdtoTriggerSched](docs/AllOfdtoTriggerSched.md)
- [ApiErrorForbiddenExample](docs/ApiErrorForbiddenExample.md)
- [ApiErrorInternalServerExample](docs/ApiErrorInternalServerExample.md)
- [ApiErrorInvalidRequestExample](docs/ApiErrorInvalidRequestExample.md)
- [ApiErrorNotFoundExample](docs/ApiErrorNotFoundExample.md)
- [ApiErrorRemoteServerUnavailableExample](docs/ApiErrorRemoteServerUnavailableExample.md)
- [ApiErrorRenderExample](docs/ApiErrorRenderExample.md)
- [DtoContact](docs/DtoContact.md)
- [DtoContactEventItem](docs/DtoContactEventItem.md)
- [DtoContactEventItemList](docs/DtoContactEventItemList.md)
- [DtoContactList](docs/DtoContactList.md)
- [DtoEventsList](docs/DtoEventsList.md)
- [DtoMessageResponse](docs/DtoMessageResponse.md)
- [DtoNotificationDeleteResponse](docs/DtoNotificationDeleteResponse.md)
- [DtoNotificationsList](docs/DtoNotificationsList.md)
- [DtoNotifierState](docs/DtoNotifierState.md)
- [DtoPatternData](docs/DtoPatternData.md)
- [DtoPatternList](docs/DtoPatternList.md)
- [DtoPatternMetrics](docs/DtoPatternMetrics.md)
- [DtoProblemOfTarget](docs/DtoProblemOfTarget.md)
- [DtoSaveTeamResponse](docs/DtoSaveTeamResponse.md)
- [DtoSaveTriggerResponse](docs/DtoSaveTriggerResponse.md)
- [DtoSubscription](docs/DtoSubscription.md)
- [DtoSubscriptionList](docs/DtoSubscriptionList.md)
- [DtoTagStatistics](docs/DtoTagStatistics.md)
- [DtoTagsData](docs/DtoTagsData.md)
- [DtoTagsStatistics](docs/DtoTagsStatistics.md)
- [DtoTeamMembers](docs/DtoTeamMembers.md)
- [DtoTeamModel](docs/DtoTeamModel.md)
- [DtoTeamSettings](docs/DtoTeamSettings.md)
- [DtoThrottlingResponse](docs/DtoThrottlingResponse.md)
- [DtoTreeOfProblems](docs/DtoTreeOfProblems.md)
- [DtoTrigger](docs/DtoTrigger.md)
- [DtoTriggerCheck](docs/DtoTriggerCheck.md)
- [DtoTriggerCheckResponse](docs/DtoTriggerCheckResponse.md)
- [DtoTriggerDump](docs/DtoTriggerDump.md)
- [DtoTriggerMaintenance](docs/DtoTriggerMaintenance.md)
- [DtoTriggerModel](docs/DtoTriggerModel.md)
- [DtoTriggersList](docs/DtoTriggersList.md)
- [DtoTriggersSearchResultDeleteResponse](docs/DtoTriggersSearchResultDeleteResponse.md)
- [DtoTypeOfProblem](docs/DtoTypeOfProblem.md)
- [DtoUser](docs/DtoUser.md)
- [DtoUserSettings](docs/DtoUserSettings.md)
- [DtoUserTeams](docs/DtoUserTeams.md)
- [HandlerConfigurationResponse](docs/HandlerConfigurationResponse.md)
- [HandlerContactExample](docs/HandlerContactExample.md)
- [MoiraCheckData](docs/MoiraCheckData.md)
- [MoiraContactData](docs/MoiraContactData.md)
- [MoiraEventInfo](docs/MoiraEventInfo.md)
- [MoiraMaintenanceInfo](docs/MoiraMaintenanceInfo.md)
- [MoiraMetricState](docs/MoiraMetricState.md)
- [MoiraMetricValue](docs/MoiraMetricValue.md)
- [MoiraNotificationEvent](docs/MoiraNotificationEvent.md)
- [MoiraPlottingData](docs/MoiraPlottingData.md)
- [MoiraScheduleData](docs/MoiraScheduleData.md)
- [MoiraScheduleDataDay](docs/MoiraScheduleDataDay.md)
- [MoiraScheduledNotification](docs/MoiraScheduledNotification.md)
- [MoiraSubscriptionData](docs/MoiraSubscriptionData.md)
- [MoiraTrigger](docs/MoiraTrigger.md)
- [MoiraTriggerCheck](docs/MoiraTriggerCheck.md)
- [MoiraTriggerData](docs/MoiraTriggerData.md)

## Documentation For Authorization
Endpoints do not require authorization.


## Author

[email protected]
## Examples

## Trigger

**Get all Triggers:**
```golang
client := client.New(transport, strfmt.Default)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

response, err := client.Trigger.GetAllTriggers(&trigger.GetAllTriggersParams{Context: ctx})

if err != nil {
log.Fatal(err)
}

for _, trigger := range response.Payload.List {
log.Println(trigger)
}
```

## Contact

**Create new contact:**
```golang
client := client.New(transport, strfmt.Default)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

contactDto := models.DtoContact{
Type: "telegram",
Value: "@moira_team",
}

response, err := client.Contact.CreateNewContact(&contact.CreateNewContactParams{
Contact: &contactDto,
Context: ctx,
})

if err != nil {
log.Fatal(err)
}

log.Println(response.Payload)
```

## Subscription

**Update existing subscription:**
```golang
client := client.New(transport, strfmt.Default)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()

subscriptionDto := &models.DtoSubscription{
Tags: []string{"test"},
Contacts: []string{"9fe937b0-721f-4b40-b849-ad1623f910a1"},
Enabled: false,
}

response, err := client.Subscription.UpdateSubscription(&subscription.UpdateSubscriptionParams{
Subscription: subscriptionDto,
SubscriptionID: "2438f803-b278-47ee-91fb-e4345208dfde",
Context: ctx,
})

if err != nil {
log.Fatal(err)
}

log.Println(response.Payload)
```
Loading

0 comments on commit 49dab40

Please sign in to comment.