Files
plane/monitor/lib/api/api.go

524 lines
15 KiB
Go
Raw Permalink Normal View History

feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
package prime_api
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
)
type IPrimeMonitorApi interface {
PostServiceStatus(StatusPayload) ErrorCode
GetFeatureFlags(licenseKey string) (*FlagDataResponse, *APIError)
ActivateInstance() *APIError
DeactivateInstance() *APIError
RetrievePlans(string) (*[]Product, *APIError)
RetrievePaymentLink(RetrievePaymentLinkPayload) (*RetrievePaymentLinkResponse, *APIError)
UpdateSubcription(SeatUpdatePayload) (*SeatUpdateResponse, *APIError)
SyncWorkspace(WorkspaceSyncPayload) (*WorkspaceActivationResponse, *APIError)
DeactivateLicense(LicenseDeactivatePayload) (*WorkspaceActivationResponse, *APIError)
ActivateWorkspace(WorkspaceActivationPayload) (*WorkspaceActivationResponse, *APIError)
ActivateFreeWorkspace(WorkspaceActivationPayload) (*WorkspaceActivationResponse, *APIError)
InitializeInstance(CredentialsPayload) (SetupResponse, *APIError)
GetSubscriptionDetails(WorkspaceSubscriptionPayload) (*WorkspaceSubscriptionResponse, *APIError)
GetProrationPreview(ProrationPreviewPayload) (*ProrationPreviewResponse, *APIError)
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
type LicenseDeactivatePayload struct {
WorkspaceSlug string `json:"workspace_slug"`
WorkspaceID string `json:"workspace_id"`
LicenseKey string `json:"license_key"`
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
type PrimeMonitorApi struct {
host string
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
instanceId string
appVersion string
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
client string
version string
machineSignature string
}
type CredentialsPayload struct {
ServerId string
Domain string
AppVersion string
}
type WorkspaceSubscriptionPayload struct {
WorkspaceId string `json:"workspace_id"`
LicenseKey string `json:"license_key"`
}
type WorkspaceSubscriptionResponse struct {
Product string `json:"product"`
CurrentPeriodEnd string `json:"current_period_end_date"`
SubscriptionExists bool `json:"subscription_exists"`
Url string `json:"url"`
}
type ProrationPreviewPayload struct {
WorkspaceId string `json:"workspace_id"`
Quantity int `json:"quantity"`
WorkspaceSlug string `json:"workspace_slug"`
LicenseKey string `json:"license_key"`
}
type ProrationPreviewResponse struct {
QuantityDifference int `json:"quantity_difference"`
PerSeatProrationAmount float64 `json:"per_seat_prorated_amount"`
NewQuantity int `json:"new_quantity"`
TotalProratedAmount float64 `json:"total_prorated_amount"`
CurrentQuantity int `json:"current_quantity"`
CurrentPriceAmount float64 `json:"current_price_amount"`
CurrentPriceInterval string `json:"current_price_interval"`
}
type SetupResponse struct {
Domain string `json:"domain"`
InstanceId string `json:"instance_id"`
Host string `json:"prime_host"`
Version string `json:"version"`
}
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
type FlagsPayload struct {
EncryptedData string `json:"encrypted_data"`
}
// Add this struct to handle the error response from the server
type ErrorResponse struct {
Message string `json:"message"`
Error string `json:"error"`
}
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
func NewMonitorApi(host, machineSignature, instanceId, appVersion string) IPrimeMonitorApi {
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
return &PrimeMonitorApi{
host: host,
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
instanceId: instanceId,
appVersion: appVersion,
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
client: "Prime-Monitor",
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
version: appVersion,
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
machineSignature: machineSignature,
}
}
func (api *PrimeMonitorApi) SetClient(client string) {
api.client = client
}
var (
API_PREFIX = "/api/v2"
MONITOR_ENDPOINT = API_PREFIX + "/monitor/"
FEATURE_FLAGS = API_PREFIX + "/flags/"
INSTANCE_PREFIX = API_PREFIX + "/instances"
ACTIVATE_INSTANCE = INSTANCE_PREFIX + "/activate/"
DEACTIVATE_INSTANCE = INSTANCE_PREFIX + "/deactivate/"
UPGRADE_INSTANCE = INSTANCE_PREFIX + "/upgrade/"
FREE_WORKSPACE_ACTIVATE = API_PREFIX + "/licenses/initialize/"
WORKSPACE_ACTIVATE = API_PREFIX + "/licenses/activate/"
SYNC_WORKSPACE = API_PREFIX + "/licenses/sync/"
UPDATE_SUBSCRIPTION = API_PREFIX + "/modify-subscriptions/"
SETUP_ENDPOINT = API_PREFIX + "/instances/initialize/"
SUBSCRIPTION_PORTAL = API_PREFIX + "/subscription-portal/"
RETRIEVE_PLANS = API_PREFIX + "/instances/products/"
RETRIEVE_PAYMENT_LINK = API_PREFIX + "/instances/payment-link/"
DEACTIVATE_LICENSE_ENDPOINT = API_PREFIX + "/licenses/deactivate/"
PRORATION_PREVIEW = API_PREFIX + "/subscriptions/proration-preview/"
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
)
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
/* ----------------------- Controller Methods ------------------------------ */
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
// Posts the status of the services given, to the prime server, returns error if
// hinderer, else doesn't return anything
func (api *PrimeMonitorApi) PostServiceStatus(payload StatusPayload) ErrorCode {
_, err := api.post(api.host+MONITOR_ENDPOINT, payload)
if err != nil {
return UNABLE_TO_POST_SERVICE_STATUS
}
return 0
}
func (api *PrimeMonitorApi) DeactivateLicense(payload LicenseDeactivatePayload) (*WorkspaceActivationResponse, *APIError) {
resp, apiError := api.post(api.host+DEACTIVATE_LICENSE_ENDPOINT, payload)
if apiError != nil {
return nil, apiError
}
data := WorkspaceActivationResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
return &data, nil
}
func (api *PrimeMonitorApi) ActivateFreeWorkspace(payload WorkspaceActivationPayload) (*WorkspaceActivationResponse, *APIError) {
resp, apiError := api.post(api.host+FREE_WORKSPACE_ACTIVATE, payload)
if apiError != nil {
return nil, apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
data := WorkspaceActivationResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return &data, nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
// Activating a paid licensed workspace
func (api *PrimeMonitorApi) ActivateWorkspace(payload WorkspaceActivationPayload) (*WorkspaceActivationResponse, *APIError) {
resp, apiError := api.post(api.host+WORKSPACE_ACTIVATE, payload)
if apiError != nil {
return nil, apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
data := WorkspaceActivationResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return &data, nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
func (api *PrimeMonitorApi) GetFeatureFlags(licenseKey string) (*FlagDataResponse, *APIError) {
flagData, apiError := api.post(api.host+FEATURE_FLAGS, map[string]string{
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
"license_key": licenseKey,
"version": api.version,
})
if apiError != nil {
return nil, apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
data := FlagDataResponse{}
if err := json.Unmarshal(flagData, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return &data, nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
func (api *PrimeMonitorApi) RetrievePlans(quantity string) (*[]Product, *APIError) {
resp, apiError := api.get(api.host+RETRIEVE_PLANS, map[string]string{
"quantity": quantity,
})
if apiError != nil {
return nil, apiError
}
data := []Product{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
return &data, nil
}
func (api *PrimeMonitorApi) RetrievePaymentLink(payload RetrievePaymentLinkPayload) (*RetrievePaymentLinkResponse, *APIError) {
resp, apiError := api.post(api.host+RETRIEVE_PAYMENT_LINK, payload)
if apiError != nil {
return nil, apiError
}
data := RetrievePaymentLinkResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
return &data, nil
}
func (api *PrimeMonitorApi) SyncWorkspace(payload WorkspaceSyncPayload) (*WorkspaceActivationResponse, *APIError) {
resp, apiError := api.post(api.host+SYNC_WORKSPACE, payload)
if apiError != nil {
return nil, apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
data := WorkspaceActivationResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return &data, nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
func (api *PrimeMonitorApi) ActivateInstance() *APIError {
_, apiError := api.post(api.host+ACTIVATE_INSTANCE, nil)
if apiError != nil {
return apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
func (api *PrimeMonitorApi) DeactivateInstance() *APIError {
_, apiError := api.post(api.host+DEACTIVATE_INSTANCE, nil)
if apiError != nil {
return apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
func (api *PrimeMonitorApi) UpgradeInstance() *APIError {
_, apiError := api.post(api.host+UPGRADE_INSTANCE, nil)
if apiError != nil {
return apiError
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
return nil
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
}
func (api *PrimeMonitorApi) UpdateSubcription(payload SeatUpdatePayload) (*SeatUpdateResponse, *APIError) {
resp, apiError := api.post(api.host+UPDATE_SUBSCRIPTION, payload)
if apiError != nil {
return nil, apiError
}
data := SeatUpdateResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
return &data, nil
}
func (api *PrimeMonitorApi) InitializeInstance(payload CredentialsPayload) (SetupResponse, *APIError) {
resp, apiError := api.post(api.host+SETUP_ENDPOINT, map[string]string{
"machine_signature": payload.ServerId,
"domain": payload.Domain,
"app_version": payload.AppVersion,
2024-09-06 16:09:44 +05:30
"deploy_platform": "KUBERNETES",
})
if apiError != nil {
return SetupResponse{}, apiError
}
setupResponse := SetupResponse{}
if err := json.Unmarshal(resp, &setupResponse); err != nil {
return SetupResponse{}, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
return setupResponse, nil
}
func (api *PrimeMonitorApi) GetSubscriptionDetails(payload WorkspaceSubscriptionPayload) (*WorkspaceSubscriptionResponse, *APIError) {
resp, apiError := api.post(api.host+SUBSCRIPTION_PORTAL, payload)
if apiError != nil {
return nil, apiError
}
data := WorkspaceSubscriptionResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
return &data, nil
}
func (api *PrimeMonitorApi) GetProrationPreview(payload ProrationPreviewPayload) (*ProrationPreviewResponse, *APIError) {
// Make the request
resp, apiError := api.post(api.host+PRORATION_PREVIEW, payload)
if apiError != nil {
return nil, apiError
}
// Unmarshal the response
data := ProrationPreviewResponse{}
if err := json.Unmarshal(resp, &data); err != nil {
return nil, &APIError{
Error: fmt.Sprintf("Error unmarshaling response: %v", err),
Success: false,
}
}
// Return the response
return &data, nil
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
// ------------------------ Helper Methods ----------------------------------
/*
prepareRequest prepares an HTTP request with the necessary headers and parameters.
Parameters:
- method: string specifying the HTTP method (e.g., "GET", "POST").
- urlStr: string specifying the URL for the request.
- body: io.Reader containing the request body.
- params: map[string]string containing the query parameters.
Returns:
- *http.Request: The prepared HTTP request.
- error: An error if any occurs during the preparation.
*/
func (api *PrimeMonitorApi) prepareRequest(method, urlStr string, body io.Reader, params map[string]string) (*http.Request, error) {
if method == "GET" && params != nil {
parsedURL, err := url.Parse(urlStr)
if err != nil {
return nil, fmt.Errorf("error parsing URL: %v", err)
}
query := parsedURL.Query()
for key, value := range params {
query.Set(key, value)
}
parsedURL.RawQuery = query.Encode()
urlStr = parsedURL.String()
}
req, err := http.NewRequest(method, urlStr, body)
if err != nil {
return nil, fmt.Errorf("error creating request: %v", err)
}
headers := map[string]string{
dev: new license activation workflow for one and pro users (#739) * feat: added feature flag package for decrypting and refreshing the feature flags value * feat: added feature flagging route for route handlers * feat: added feature flag worker for managing and distributing feature flags * feat: implemented feature flag api implementation inside ff handler * feat: added exponential retry interval inside feature flagging * fix: route pattern of feature flag endpoint from monitor * feat: created endpoint to activate workspace from monitor * feat: made changes to accomodate db and activate endpoint * dev: update multi tenant environment settings * dev: workspace license activation flow * dev: update license activate endpoint * dev: update workspace license activate endpoint * feat: added feature flag user sync logic * feat: added constants and sync logic with private key inside * feat: added port as env variable * feat: added modification for removing license key in healthcheck * feat: example env pushed * fix: update monitor endpoints and license activation function * dev: initiate free workspace only for self hosted instances * dev: self hosting license endpoint updates * dev: remove monitor db * dev: update handlers * dev: self hosted license subscription web * dev: removed computed in self hosted subscription * fix: prime server url and delete old license while creating new license in sqlite * chore: subscription activation alert after successfull activation. * dev: update feature flag endpoints * fix: handled several cases of feature flags * fix: linting errors * dev: update monitor to handle workspace activation * dev: update decryption algorithm * feat: separated activation payload with the sync payload * dev: update feature flags endpoint * dev: change type for workspace sync * feat: added isActive flag for user activation * feat: removed creation of free users in monitor * feat: added method for workspace product * dev: add user email in types * feat: added method for workspace product * fix: uer license feature flag fetch * fix: handler fixed for feature key * chore: self managed license activation * chore: update validation license flow. * chore: license activation success. * dev: resync workspace license on activation * chore: plane one success modal. * feat: added constructs to inject private key build time * feat: updated the docker file with private key build argument * feat: added consumption od DEFAULT_PRIVATE_KEY when building monitor * dev: update private key --------- Co-authored-by: Henit Chobisa <chobisa.henit@gmail.com> Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com>
2024-08-22 17:39:19 +05:30
"X-Instance-Id": api.instanceId,
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
"X-Machine-Signature": api.machineSignature,
"X-Client": api.client,
"X-License-Version": api.version,
"Content-Type": "application/json",
}
for key, value := range headers {
req.Header.Add(key, value)
}
return req, nil
}
/*
doRequest executes the HTTP request and handles common response scenarios.
Parameters:
- req: *http.Request specifying the HTTP request to execute.
Returns:
- []byte: The response body.
- error: An error if any occurs during the request execution.
*/
func (api *PrimeMonitorApi) doRequest(req *http.Request) ([]byte, *APIError) {
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error making request: %v", err),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
defer resp.Body.Close()
switch {
case resp.StatusCode >= 200 && resp.StatusCode <= 227:
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error reading response body: %v", err),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
return body, nil
case resp.StatusCode >= 300 && resp.StatusCode <= 308:
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error reading response body: %v", err),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
return body, nil
case resp.StatusCode >= 400 && resp.StatusCode <= 451:
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error reading response body: %v", err),
Success: false,
}
}
// Try to parse the error response
var errorResp ErrorResponse
if err := json.Unmarshal(body, &errorResp); err != nil {
// If we can't parse the error, return the status code
return nil, &APIError{
Error: fmt.Sprintf("unexpected status code %d", resp.StatusCode),
Success: false,
}
}
return nil, &APIError{
Error: errorResp.Error,
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
default:
return nil, &APIError{
Error: fmt.Sprintf("unexpected status code: %v", resp.StatusCode),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
}
/*
get performs a GET request.
Parameters:
- baseURL: string specifying the base URL for the request.
- params: map[string]string containing the query parameters.
Returns:
- []byte: The response body.
- error: An error if any occurs during the request.
*/
func (api *PrimeMonitorApi) get(baseURL string, params map[string]string) ([]byte, *APIError) {
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
req, err := api.prepareRequest("GET", baseURL, nil, params)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error preparing request: %v", err),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
return api.doRequest(req)
}
/*
post performs a POST request with JSON body.
Parameters:
- baseURL: string specifying the base URL for the request.
- data: interface{} containing the data to be sent in the request body.
Returns:
- []byte: The response body.
- error: An error if any occurs during the request.
*/
func (api *PrimeMonitorApi) post(baseURL string, data interface{}) ([]byte, *APIError) {
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
jsonData, err := json.Marshal(data)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error marshaling data: %v", err),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
req, err := api.prepareRequest("POST", baseURL, bytes.NewBuffer(jsonData), nil)
if err != nil {
return nil, &APIError{
Error: fmt.Sprintf("error preparing request: %v", err),
Success: false,
}
feat: Added Prime Monitor Go Service for monitoring, health check and feature flagging (#411) * feat: added build meta data to monitor * feat: added versioning to prime-monitor * feat: added logger package for prime-monitor * feat: implemented logging in cmd * feat: implemented moduled monorepo architecture * feat: added cron package for healthcheck * feat: added constants and modules for healthcheck * feat: added environment service getter method * feat: added environment service parser for parsing the recieved keys * feat: added environment service provider method * feat: added retry based executer for the test methods * feat: added http health check method and placeholders for redis & pg * feat: added tests for healthcheck methods * feat: added PerformHealthCheck Controller Method for execution of healthcheck controller * feat: added healthcheck test file for testing the healthcheck * feat: added healthcheck to work file * feat: added readme for healthcheck package * feat: created healthcheck register for prime scheduler * feat: added cron command for running cron subpart of monitor * feat: added prime schedule handler for cron * feat: added start command for starting up prime scheduler * feat: added build utility files for monitor * fix: goreleaser builds * feat: removed Redis method from healthcheck methods * feat: added docker file for building prime-monitor * feat: added flag for adding healthcheck duration for cron start * chore: removed redis as a healthcheck method * chore: modified actions to build monitor on branch build and docker images * feat: added monitor service in docker compose caddy * feat: added description for HealthCheckJob * fix: status code issue for reachable and non reachable * feat: added api package for connecting with prime api * feat: modified cmd package to report healthcheck status to prime * feat: added api types inside prime-monitor * feat: added message field for meta while status reporting * fix: modified constants for environment variables * feat: added monitor readme * fix: build-branch monitor content shift to build-branch-ee * chore: added build args on release * feat: remove version meta data from cli * fix: docker file changed to fix the build to default * fix: removed build flags from github branch build * fix: moved cron start to root level start cmd * fix: passed the recieved machine signature to api headers * feat: optimised docker build for monitor
2024-06-20 12:14:46 +05:30
}
return api.doRequest(req)
}