diff --git a/dashboard/src/controllers/call.js b/dashboard/src/controllers/call.js index 929149b..81d0677 100644 --- a/dashboard/src/controllers/call.js +++ b/dashboard/src/controllers/call.js @@ -22,7 +22,7 @@ export default async function call(method, args) { updateState(this, 'RequestStarted', null); - const res = await fetch(`/api/method/${method}`, { + const res = await fetch(`/api/action/${method}`, { method: 'POST', headers, body: JSON.stringify(args) diff --git a/dashboard/src/controllers/fileUploader.js b/dashboard/src/controllers/fileUploader.js index b1e0072..3994b10 100644 --- a/dashboard/src/controllers/fileUploader.js +++ b/dashboard/src/controllers/fileUploader.js @@ -64,7 +64,7 @@ export default class FileUploader { reject(error); } }; - xhr.open('POST', '/api/method/upload_file', true); + xhr.open('POST', '/api/action/upload_file', true); xhr.setRequestHeader('Accept', 'application/json'); if (window.csrf_token && window.csrf_token !== '{{ csrf_token }}') { xhr.setRequestHeader('X-Jingrow-CSRF-Token', window.csrf_token); diff --git a/dashboard/src/controllers/s3FileUploader.js b/dashboard/src/controllers/s3FileUploader.js index 2ecdbfb..9284ad7 100644 --- a/dashboard/src/controllers/s3FileUploader.js +++ b/dashboard/src/controllers/s3FileUploader.js @@ -22,7 +22,7 @@ export default class S3FileUploader { async function getUploadLink() { try { let response = await fetch( - `/api/method/jcloud.api.site.get_upload_link?file=${file.name}` + `/api/action/jcloud.api.site.get_upload_link?file=${file.name}` ); let data = await response.json(); return data.message; diff --git a/dashboard/src/main.js b/dashboard/src/main.js index f0d6e02..0e98d9d 100644 --- a/dashboard/src/main.js +++ b/dashboard/src/main.js @@ -81,7 +81,7 @@ if (window.jcloud_frontend_posthog_host?.includes('https://')) { if (import.meta.env.DEV) { request({ - url: '/api/method/jcloud.www.dashboard.get_context_for_dev' + url: '/api/action/jcloud.www.dashboard.get_context_for_dev' }).then(values => { for (let key in values) { window[key] = values[key]; diff --git a/dashboard/src/tests/setup/msw.js b/dashboard/src/tests/setup/msw.js index 2a67a4a..a07fe06 100644 --- a/dashboard/src/tests/setup/msw.js +++ b/dashboard/src/tests/setup/msw.js @@ -12,7 +12,7 @@ const FAKE_BASE_URL = 'http://fc.tests'; const restHandlers = [ rest.post( - FAKE_BASE_URL + '/api/method/jcloud.api.site.features', + FAKE_BASE_URL + '/api/action/jcloud.api.site.features', (req, res, ctx) => { return res(ctx.status(200), ctx.json({ message: apps })); } diff --git a/dashboard/src2/components/AppTrialSubscriptionDialog.vue b/dashboard/src2/components/AppTrialSubscriptionDialog.vue index ef1cb3a..3d8cbe9 100644 --- a/dashboard/src2/components/AppTrialSubscriptionDialog.vue +++ b/dashboard/src2/components/AppTrialSubscriptionDialog.vue @@ -322,7 +322,7 @@ SitePlansCards: defineAsyncComponent(() => import('./SitePlansCards.vue')), this.isChangingPlan = true; const plan_name = this.selectedPlan?.name; let request = createResource({ - url: '/api/method/jcloud.api.client.run_pg_method', + url: '/api/action/jcloud.api.client.run_pg_method', params: { dt: 'Site', dn: this.site, diff --git a/dashboard/src2/components/billing/BillingSummary.vue b/dashboard/src2/components/billing/BillingSummary.vue index 818eb74..c1b7a4a 100644 --- a/dashboard/src2/components/billing/BillingSummary.vue +++ b/dashboard/src2/components/billing/BillingSummary.vue @@ -113,7 +113,7 @@ function payUnpaidInvoices() { let invoice = _unpaidInvoices; if (invoice.stripe_invoice_url && team.pg.payment_mode === 'Card') { window.open( - `/api/method/jcloud.api.client.run_pg_method?dt=Invoice&dn=${invoice.name}&method=stripe_payment_url` + `/api/action/jcloud.api.client.run_pg_method?dt=Invoice&dn=${invoice.name}&method=stripe_payment_url` ); } else { showAddPrepaidCreditsDialog.value = true; diff --git a/dashboard/src2/components/billing/mpesa/AddPaymentGateway.vue b/dashboard/src2/components/billing/mpesa/AddPaymentGateway.vue index 191d490..10ba36e 100644 --- a/dashboard/src2/components/billing/mpesa/AddPaymentGateway.vue +++ b/dashboard/src2/components/billing/mpesa/AddPaymentGateway.vue @@ -14,7 +14,7 @@ v-model="paymentGatewayDetails.url" name="url" type="text" - placeholder="https://xyz.com/api/method/" + placeholder="https://xyz.com/api/action/" />
{ replaysOnErrorSampleRate: 1.0, beforeSend(event, hint) { const ignoreErrors = [ - /api\/method\/jcloud.api.client/, + /api\/action\/jcloud.api.client/, /dynamically imported module/, /NetworkError when attempting to fetch resource/, /Failed to fetch/, @@ -154,7 +154,7 @@ getInitialData().then(() => { function getInitialData() { if (import.meta.env.DEV) { return jingrowRequest({ - url: '/api/method/jcloud.www.dashboard.get_context_for_dev', + url: '/api/action/jcloud.www.dashboard.get_context_for_dev', }).then((values) => Object.assign(window, values)); } else { return Promise.resolve(); diff --git a/dashboard/src2/objects/notification.js b/dashboard/src2/objects/notification.js index 5958391..14b98f7 100644 --- a/dashboard/src2/objects/notification.js +++ b/dashboard/src2/objects/notification.js @@ -66,7 +66,7 @@ export default { async onClick() { toast.promise( jingrowRequest({ - url: '/api/method/jcloud.api.notifications.mark_all_notifications_as_read', + url: '/api/action/jcloud.api.notifications.mark_all_notifications_as_read', }), { success: () => { diff --git a/dashboard/src2/pages/BillingInvoices.vue b/dashboard/src2/pages/BillingInvoices.vue index e095dec..4738b4c 100644 --- a/dashboard/src2/pages/BillingInvoices.vue +++ b/dashboard/src2/pages/BillingInvoices.vue @@ -191,7 +191,7 @@ export default { e.stopPropagation(); if (row.stripe_invoice_url && row.payment_mode == 'Card') { window.open( - `/api/method/jcloud.api.client.run_pg_method?dt=Invoice&dn=${row.name}&method=stripe_payment_url`, + `/api/action/jcloud.api.client.run_pg_method?dt=Invoice&dn=${row.name}&method=stripe_payment_url`, ); } else { this.showBuyPrepaidCreditsDialog = true; diff --git a/dashboard/src2/pages/BillingMpesaInvoices.vue b/dashboard/src2/pages/BillingMpesaInvoices.vue index 78c8f90..e1ef988 100644 --- a/dashboard/src2/pages/BillingMpesaInvoices.vue +++ b/dashboard/src2/pages/BillingMpesaInvoices.vue @@ -26,7 +26,7 @@ export default { this.loading = true; try { const response = await jingrowRequest({ - url: '/api/method/jcloud.api.regional_payments.mpesa.utils.display_invoices_by_partner', + url: '/api/action/jcloud.api.regional_payments.mpesa.utils.display_invoices_by_partner', method: 'GET', }); this.invoices = response; diff --git a/deployment/nginx.conf b/deployment/nginx.conf index a4d9c2d..6c9e6a9 100644 --- a/deployment/nginx.conf +++ b/deployment/nginx.conf @@ -350,7 +350,7 @@ server { http2_push_preload on; } - location ~ ^/api/method/jcloud.api.developer.saas.* { + location ~ ^/api/action/jcloud.api.developer.saas.* { if ($request_method = 'OPTIONS') { add_header Access-Control-Allow-Origin "*" always; add_header Access-Control-Allow-Methods "GET, POST, OPTIONS"; diff --git a/jcloud/agent.py b/jcloud/agent.py index a43eddd..df8567f 100644 --- a/jcloud/agent.py +++ b/jcloud/agent.py @@ -478,7 +478,7 @@ class Agent: "site_backup": { "name": site_backup.name, "snapshot_request_key": site_backup.snapshot_request_key, - "snapshot_trigger_url": f"{jcloud_public_base_url}/api/method/jcloud.api.site_backup.create_snapshot", + "snapshot_trigger_url": f"{jcloud_public_base_url}/api/action/jcloud.api.site_backup.create_snapshot", }, } return self.create_agent_job( diff --git a/jcloud/api/account.py b/jcloud/api/account.py index babdcc3..d4153dc 100644 --- a/jcloud/api/account.py +++ b/jcloud/api/account.py @@ -381,7 +381,7 @@ def send_login_link(email): minutes = 10 jingrow.cache().set_value(f"one_time_login_key:{key}", email, expires_in_sec=minutes * 60) - link = get_url(f"/api/method/jcloud.api.account.login_using_key?key={key}") + link = get_url(f"/api/action/jcloud.api.account.login_using_key?key={key}") if jingrow.conf.developer_mode: print() diff --git a/jcloud/api/analytics.py b/jcloud/api/analytics.py index 6901260..1efb4bb 100644 --- a/jcloud/api/analytics.py +++ b/jcloud/api/analytics.py @@ -268,7 +268,7 @@ class RequestGroupByChart(StackedGroupByChart): def setup_search_filters(self): super().setup_search_filters() self.search = self.search.filter("match_phrase", json__transaction_type="request").exclude( - "match_phrase", json__request__path="/api/method/ping" + "match_phrase", json__request__path="/api/action/ping" ) if self.resource_type == ResourceType.SITE: self.search = self.search.filter("match_phrase", json__site=self.name) @@ -411,8 +411,8 @@ def get_advanced_analytics(name, timezone, duration="7d"): def get_more_request_detail_fn_names(): return { - "/api/method/run_pg_method": get_run_pg_method_methodnames.__name__, - "/api/method/jingrow.desk.query_report.run": get_query_report_run_reports.__name__, + "/api/action/run_pg_method": get_run_pg_method_methodnames.__name__, + "/api/action/jingrow.desk.query_report.run": get_query_report_run_reports.__name__, } @@ -542,7 +542,7 @@ class RunDocMethodMethodNames(RequestGroupByChart): def setup_search_filters(self): super().setup_search_filters() - self.search = self.search.filter("match_phrase", json__request__path="/api/method/run_pg_method") + self.search = self.search.filter("match_phrase", json__request__path="/api/action/run_pg_method") def get_run_pg_method_methodnames(site, agg_type, timezone, timespan, timegrain): @@ -557,7 +557,7 @@ class QueryReportRunReports(RequestGroupByChart): def setup_search_filters(self): super().setup_search_filters() self.search = self.search.filter( - "match_phrase", json__request__path="/api/method/jingrow.desk.query_report.run" + "match_phrase", json__request__path="/api/action/jingrow.desk.query_report.run" ) @@ -761,7 +761,7 @@ def request_logs(name, timezone, date, sort=None, start=0): {"match_phrase": {"json.site": name}}, {"range": {"@timestamp": {"gt": f"{date}||-1d/d", "lte": f"{date}||/d"}}}, ], - "must_not": [{"match_phrase": {"json.request.path": "/api/method/ping"}}], + "must_not": [{"match_phrase": {"json.request.path": "/api/action/ping"}}], } }, "sort": sort_value, diff --git a/jcloud/api/billing.py b/jcloud/api/billing.py index 12b100c..1dd5c1e 100644 --- a/jcloud/api/billing.py +++ b/jcloud/api/billing.py @@ -708,7 +708,7 @@ def generate_stk_push(**kwargs): mpesa_setup = get_mpesa_setup_for_team(partner[0]) try: callback_url = ( - get_request_site_address(True) + "/api/method/jcloud.api.billing.verify_m_pesa_transaction" + get_request_site_address(True) + "/api/action/jcloud.api.billing.verify_m_pesa_transaction" ) env = "production" if not mpesa_setup.sandbox else "sandbox" # for sandbox, business shortcode is same as till number diff --git a/jcloud/api/developer/marketplace.py b/jcloud/api/developer/marketplace.py index 0459c74..0cd4659 100644 --- a/jcloud/api/developer/marketplace.py +++ b/jcloud/api/developer/marketplace.py @@ -160,7 +160,7 @@ class DeveloperApiHandler: jingrow.db.commit() return get_url( - f"/api/method/jcloud.api.marketplace.login_via_token?token={token}&team={team}&site={self.app_subscription_pg.site}" + f"/api/action/jcloud.api.marketplace.login_via_token?token={token}&team={team}&site={self.app_subscription_pg.site}" ) diff --git a/jcloud/api/developer/saas.py b/jcloud/api/developer/saas.py index a40595e..2da4ddb 100644 --- a/jcloud/api/developer/saas.py +++ b/jcloud/api/developer/saas.py @@ -73,7 +73,7 @@ class SaasApiHandler: ).insert(ignore_permissions=True) domain = jingrow.db.get_value("Saas App", self.app_subscription_pg.app, "custom_domain") - return f"https://{domain}/api/method/jcloud.api.saas.login_via_token?token={token}&team={self.app_subscription_pg.team}" + return f"https://{domain}/api/action/jcloud.api.saas.login_via_token?token={token}&team={self.app_subscription_pg.team}" def get_trial_expiry(self): return jingrow.db.get_value("Site", self.app_subscription_pg.site, "trial_end_date") diff --git a/jcloud/api/email.py b/jcloud/api/email.py index d59932d..b059f58 100644 --- a/jcloud/api/email.py +++ b/jcloud/api/email.py @@ -285,7 +285,7 @@ def event_log(): try: host_name = jingrow.db.get_value("Site", site, "host_name") or site requests.post( - f"https://{host_name}/api/method/email_delivery_service.controller.update_status", + f"https://{host_name}/api/action/email_delivery_service.controller.update_status", data=data, ) except Exception as e: diff --git a/jcloud/api/marketplace.py b/jcloud/api/marketplace.py index be81990..0745283 100644 --- a/jcloud/api/marketplace.py +++ b/jcloud/api/marketplace.py @@ -1181,7 +1181,7 @@ def get_discount_percent(plan, discount=0.0): if team.jerp_partner and jingrow.get_value("Marketplace App Plan", plan, "partner_discount"): client = get_jingrow_io_connection() response = client.session.post( - f"{client.url}/api/method/partner_relationship_management.api.get_partner_type", + f"{client.url}/api/action/partner_relationship_management.api.get_partner_type", data={"email": team.partner_email}, headers=client.headers, ) diff --git a/jcloud/api/site.py b/jcloud/api/site.py index 68a5e35..cb0fe9c 100644 --- a/jcloud/api/site.py +++ b/jcloud/api/site.py @@ -1099,7 +1099,7 @@ def get(name): site_name = jingrow.db.get_value("Site Domain", name, "site") if site_name: jingrow.local.response["type"] = "redirect" - jingrow.local.response["location"] = f"/api/method/jcloud.api.site.get?name={site_name}" + jingrow.local.response["location"] = f"/api/action/jcloud.api.site.get?name={site_name}" return None raise rg_info = jingrow.db.get_value("Release Group", site.group, ["team", "version", "public"], as_dict=True) diff --git a/jcloud/auth.py b/jcloud/auth.py index 03c14e4..b41506e 100644 --- a/jcloud/auth.py +++ b/jcloud/auth.py @@ -12,48 +12,48 @@ JCLOUD_AUTH_MAX_ENTRIES = 1000000 ALLOWED_PATHS = [ - "/api/method/create-site-migration", - "/api/method/create-version-upgrade", - "/api/method/migrate-to-private-bench", - "/api/method/find-my-sites", - "/api/method/jingrow.core.pagetype.communication.email.mark_email_as_seen", - "/api/method/jingrow.realtime.get_user_info", - "/api/method/jingrow.realtime.can_subscribe_pg", - "/api/method/jingrow.realtime.can_subscribe_pagetype", - "/api/method/jingrow.realtime.has_permission", - "/api/method/jingrow.www.login.login_via_jingrow", - "/api/method/jingrow.integrations.oauth2.authorize", - "/api/method/jingrow.integrations.oauth2.approve", - "/api/method/jingrow.integrations.oauth2.get_token", - "/api/method/jingrow.integrations.oauth2.openid_profile", - "/api/method/jingrow.integrations.oauth2_logins.login_via_jingrow", - "/api/method/jingrow.website.pagetype.web_page_view.web_page_view.make_view_log", - "/api/method/get-user-sites-list-for-new-ticket", - "/api/method/ping", - "/api/method/login", - "/api/method/logout", - "/api/method/jcloud.jcloud.pagetype.razorpay_webhook_log.razorpay_webhook_log.razorpay_webhook_handler", - "/api/method/jcloud.jcloud.pagetype.razorpay_webhook_log.razorpay_webhook_log.razorpay_authorized_payment_handler", - "/api/method/jcloud.jcloud.pagetype.stripe_webhook_log.stripe_webhook_log.stripe_webhook_handler", - "/api/method/upload_file", - "/api/method/jingrow.search.web_search", - "/api/method/jingrow.email.queue.unsubscribe", - "/api/method/jcloud.utils.telemetry.capture_read_event", - "/api/method/validate_plan_change", - "/api/method/marketplace-apps", - "/api/method/jcloud.www.dashboard.get_context_for_dev", - "/api/method/jingrow.website.pagetype.web_form.web_form.accept", - "/api/method/jingrow.core.pagetype.user.user.test_password_strength", - "/api/method/jingrow.core.pagetype.user.user.update_password", - "/api/method/get_central_migration_data", + "/api/action/create-site-migration", + "/api/action/create-version-upgrade", + "/api/action/migrate-to-private-bench", + "/api/action/find-my-sites", + "/api/action/jingrow.core.pagetype.communication.email.mark_email_as_seen", + "/api/action/jingrow.realtime.get_user_info", + "/api/action/jingrow.realtime.can_subscribe_pg", + "/api/action/jingrow.realtime.can_subscribe_pagetype", + "/api/action/jingrow.realtime.has_permission", + "/api/action/jingrow.www.login.login_via_jingrow", + "/api/action/jingrow.integrations.oauth2.authorize", + "/api/action/jingrow.integrations.oauth2.approve", + "/api/action/jingrow.integrations.oauth2.get_token", + "/api/action/jingrow.integrations.oauth2.openid_profile", + "/api/action/jingrow.integrations.oauth2_logins.login_via_jingrow", + "/api/action/jingrow.website.pagetype.web_page_view.web_page_view.make_view_log", + "/api/action/get-user-sites-list-for-new-ticket", + "/api/action/ping", + "/api/action/login", + "/api/action/logout", + "/api/action/jcloud.jcloud.pagetype.razorpay_webhook_log.razorpay_webhook_log.razorpay_webhook_handler", + "/api/action/jcloud.jcloud.pagetype.razorpay_webhook_log.razorpay_webhook_log.razorpay_authorized_payment_handler", + "/api/action/jcloud.jcloud.pagetype.stripe_webhook_log.stripe_webhook_log.stripe_webhook_handler", + "/api/action/upload_file", + "/api/action/jingrow.search.web_search", + "/api/action/jingrow.email.queue.unsubscribe", + "/api/action/jcloud.utils.telemetry.capture_read_event", + "/api/action/validate_plan_change", + "/api/action/marketplace-apps", + "/api/action/jcloud.www.dashboard.get_context_for_dev", + "/api/action/jingrow.website.pagetype.web_form.web_form.accept", + "/api/action/jingrow.core.pagetype.user.user.test_password_strength", + "/api/action/jingrow.core.pagetype.user.user.update_password", + "/api/action/get_central_migration_data", ] ALLOWED_WILDCARD_PATHS = [ - "/api/method/jcloud.api.", - "/api/method/jcloud.saas.", - "/api/method/wiki.", - "/api/method/jingrow.integrations.oauth2_logins.", - "/api/method/jcloud.www.marketplace.index.", + "/api/action/jcloud.api.", + "/api/action/jcloud.saas.", + "/api/action/wiki.", + "/api/action/jingrow.integrations.oauth2_logins.", + "/api/action/jcloud.www.marketplace.index.", ] DENIED_PATHS = [ @@ -70,7 +70,7 @@ DENIED_WILDCARD_PATHS = [ def hook(): # noqa: C901 if jingrow.form_dict.cmd: - path = f"/api/method/{jingrow.form_dict.cmd}" + path = f"/api/action/{jingrow.form_dict.cmd}" else: path = jingrow.request.path diff --git a/jcloud/commands.py b/jcloud/commands.py index 8faebe4..c19c0e5 100644 --- a/jcloud/commands.py +++ b/jcloud/commands.py @@ -30,7 +30,7 @@ def start_ngrok_and_set_webhook(context): print(f"Inspect logs at {tunnel.api_url}") stripe = get_stripe() - url = f"{public_url}/api/method/jcloud.jcloud.pagetype.stripe_webhook_log.stripe_webhook_log.stripe_webhook_handler" + url = f"{public_url}/api/action/jcloud.jcloud.pagetype.stripe_webhook_log.stripe_webhook_log.stripe_webhook_handler" stripe.WebhookEndpoint.modify( jingrow.db.get_single_value("Jcloud Settings", "stripe_webhook_endpoint_id"), url=url ) diff --git a/jcloud/hooks.py b/jcloud/hooks.py index 74166e5..f394760 100644 --- a/jcloud/hooks.py +++ b/jcloud/hooks.py @@ -72,7 +72,7 @@ website_redirects = [ {"source": "/dashboard/f-login", "target": get_jingrow_io_auth_url() or "/"}, { "source": "/suspended-site", - "target": "/api/method/jcloud.api.handle_suspended_site_redirection", + "target": "/api/action/jcloud.api.handle_suspended_site_redirection", }, {"source": "/f-login", "target": "/dashboard/f-login"}, {"source": "/signup", "target": "/jerp/signup"}, diff --git a/jcloud/jcloud/pagetype/account_request/account_request.py b/jcloud/jcloud/pagetype/account_request/account_request.py index 3cf3c38..414a35e 100644 --- a/jcloud/jcloud/pagetype/account_request/account_request.py +++ b/jcloud/jcloud/pagetype/account_request/account_request.py @@ -198,7 +198,7 @@ class AccountRequest(Document): "invited_by": self.invited_by, "link": url, "read_pixel_path": get_url( - f"/api/method/jcloud.utils.telemetry.capture_read_event?email={self.email}" + f"/api/action/jcloud.utils.telemetry.capture_read_event?email={self.email}" ), "otp": self.otp, } @@ -225,7 +225,7 @@ class AccountRequest(Document): def get_verification_url(self): if self.saas: - return get_url(f"/api/method/jcloud.api.saas.validate_account_request?key={self.request_key}") + return get_url(f"/api/action/jcloud.api.saas.validate_account_request?key={self.request_key}") if self.product_trial: return get_url( f"/dashboard/saas/{self.product_trial}/oauth?key={self.request_key}&email={self.email}" diff --git a/jcloud/jcloud/pagetype/invoice/invoice.py b/jcloud/jcloud/pagetype/invoice/invoice.py index 0a32977..bebc1cf 100644 --- a/jcloud/jcloud/pagetype/invoice/invoice.py +++ b/jcloud/jcloud/pagetype/invoice/invoice.py @@ -744,7 +744,7 @@ class Invoice(Document): def get_pdf(self): print_format = self.meta.default_print_format return jingrow.utils.get_url( - f"/api/method/jingrow.utils.print_format.download_pdf?pagetype=Invoice&name={self.name}&format={print_format}&no_letterhead=0" + f"/api/action/jingrow.utils.print_format.download_pdf?pagetype=Invoice&name={self.name}&format={print_format}&no_letterhead=0" ) @jingrow.whitelist() @@ -766,7 +766,7 @@ class Invoice(Document): return None client = self.get_jingrowio_connection() response = client.session.post( - f"{client.url}/api/method/create-fc-invoice", + f"{client.url}/api/action/create-fc-invoice", headers=client.headers, data={ "team": team.as_json(), @@ -819,7 +819,7 @@ class Invoice(Document): "no_letterhead": 0, } ) - url = client.url + "/api/method/jingrow.utils.print_format.download_pdf?" + params + url = client.url + "/api/action/jingrow.utils.print_format.download_pdf?" + params with client.session.get(url, headers=client.headers, stream=True) as r: r.raise_for_status() @@ -917,7 +917,7 @@ class Invoice(Document): "no_letterhead": 0, } ) - url = f"{client.url}/api/method/jingrow.utils.print_format.download_pdf?{params}" + url = f"{client.url}/api/action/jingrow.utils.print_format.download_pdf?{params}" with client.session.get(url, headers=client.headers, stream=True) as r: r.raise_for_status() @@ -1138,7 +1138,7 @@ def create_sales_invoice_on_external_site(transaction_response): # Post to the external site's sales invoice creation API response = client.session.post( - f"{client.url}/api/method/jingrow.client.insert", + f"{client.url}/api/action/jingrow.client.insert", headers=client.headers, json={"pg": data}, ) diff --git a/jcloud/jcloud/pagetype/jcloud_settings/jcloud_settings.py b/jcloud/jcloud/pagetype/jcloud_settings/jcloud_settings.py index 9feb583..1b6cdb7 100644 --- a/jcloud/jcloud/pagetype/jcloud_settings/jcloud_settings.py +++ b/jcloud/jcloud/pagetype/jcloud_settings/jcloud_settings.py @@ -195,7 +195,7 @@ class JcloudSettings(Document): def create_stripe_webhook(self): stripe = get_stripe() url = jingrow.utils.get_url( - "/api/method/jcloud.jcloud.pagetype.stripe_webhook_log.stripe_webhook_log.stripe_webhook_handler" + "/api/action/jcloud.jcloud.pagetype.stripe_webhook_log.stripe_webhook_log.stripe_webhook_handler" ) webhook = stripe.WebhookEndpoint.create( url=url, @@ -226,7 +226,7 @@ class JcloudSettings(Document): return { "name": app_name, "url": "https://jingrow.cloud", - "hook_attributes": {"url": get_url("api/method/jcloud.api.github.hook")}, + "hook_attributes": {"url": get_url("api/action/jcloud.api.github.hook")}, "redirect_url": get_url("github/redirect"), "description": "Managed Jingrow Hosting", "public": True, diff --git a/jcloud/jcloud/pagetype/prometheus_alert_rule/prometheus_alert_rule.py b/jcloud/jcloud/pagetype/prometheus_alert_rule/prometheus_alert_rule.py index 519e258..f762c44 100644 --- a/jcloud/jcloud/pagetype/prometheus_alert_rule/prometheus_alert_rule.py +++ b/jcloud/jcloud/pagetype/prometheus_alert_rule/prometheus_alert_rule.py @@ -101,7 +101,7 @@ class PrometheusAlertRule(Document): { "name": "web.hook", "webhook_configs": [ - {"url": jingrow.utils.get_url("api/method/jcloud.api.monitoring.alert")} + {"url": jingrow.utils.get_url("api/action/jcloud.api.monitoring.alert")} ], } ], diff --git a/jcloud/jcloud/pagetype/release_group/release_group.py b/jcloud/jcloud/pagetype/release_group/release_group.py index 95d0edd..6bf372c 100644 --- a/jcloud/jcloud/pagetype/release_group/release_group.py +++ b/jcloud/jcloud/pagetype/release_group/release_group.py @@ -453,7 +453,7 @@ class ReleaseGroup(Document, TagHelpers): with suppress(AttributeError, RuntimeError): if ( not jingrow.flags.in_test - and jingrow.request.path == "/api/method/jcloud.api.bench.change_branch" + and jingrow.request.path == "/api/action/jcloud.api.bench.change_branch" ): return # Separate validation exists in set_app_source for app in self.apps: @@ -819,7 +819,7 @@ class ReleaseGroup(Document, TagHelpers): } ).insert() - link = get_url(f"/api/method/jcloud.api.bench.confirm_bench_transfer?key={key}") + link = get_url(f"/api/action/jcloud.api.bench.confirm_bench_transfer?key={key}") if jingrow.conf.developer_mode: print(f"Bench transfer link for {team_mail_id}\n{link}\n") diff --git a/jcloud/jcloud/pagetype/site/site.py b/jcloud/jcloud/pagetype/site/site.py index e27364b..9a79c9b 100644 --- a/jcloud/jcloud/pagetype/site/site.py +++ b/jcloud/jcloud/pagetype/site/site.py @@ -1394,7 +1394,7 @@ class Site(Document, TagHelpers): } ).insert() - link = get_url(f"/api/method/jcloud.api.site.confirm_site_transfer?key={key}") + link = get_url(f"/api/action/jcloud.api.site.confirm_site_transfer?key={key}") if jingrow.conf.developer_mode: print(f"\nSite transfer link for {team_mail_id}\n{link}\n") @@ -1511,7 +1511,7 @@ class Site(Document, TagHelpers): if user == "Administrator": password = get_decrypted_password("Site", self.name, "admin_password") response = requests.post( - f"https://{self.name}/api/method/login", + f"https://{self.name}/api/action/login", data={"usr": user, "pwd": password}, ) sid = response.cookies.get("sid") @@ -1678,7 +1678,7 @@ class Site(Document, TagHelpers): "pagetype": "Webhook", "webhook_pagetype": "User", "enabled": 1, - "request_url": "https://jingrow.com/api/method/jcloud.api.site_login.sync_product_site_user", + "request_url": "https://jingrow.com/api/action/jcloud.api.site_login.sync_product_site_user", "request_method": "POST", "request_structure": "JSON", "webhook_json": """{ "user_info": { "email": "{{pg.email}}", "enabled": "{{pg.enabled}}" } }""", @@ -1796,7 +1796,7 @@ class Site(Document, TagHelpers): self.save() def ping(self): - return requests.get(f"https://{self.name}/api/method/ping") + return requests.get(f"https://{self.name}/api/action/ping") def _set_configuration(self, config: list[dict]): """Similar to _update_configuration but will replace full configuration at once diff --git a/jcloud/jcloud/pagetype/team/team.py b/jcloud/jcloud/pagetype/team/team.py index 1ecd1f0..bf90113 100644 --- a/jcloud/jcloud/pagetype/team/team.py +++ b/jcloud/jcloud/pagetype/team/team.py @@ -921,7 +921,7 @@ class Team(Document): # fetch partner level from framework.jingrow.com client = get_jingrow_io_connection() response = client.session.get( - f"{client.url}/api/method/get_partner_level", + f"{client.url}/api/action/get_partner_level", headers=client.headers, params={"email": self.partner_email}, ) diff --git a/jcloud/jcloud/pagetype/team_deletion_request/team_deletion_request.py b/jcloud/jcloud/pagetype/team_deletion_request/team_deletion_request.py index bd94499..0126e2f 100644 --- a/jcloud/jcloud/pagetype/team_deletion_request/team_deletion_request.py +++ b/jcloud/jcloud/pagetype/team_deletion_request/team_deletion_request.py @@ -133,7 +133,7 @@ class TeamDeletionRequest(PersonalDataDeletionRequest): def generate_url_for_confirmation(self): params = get_signed_params({"team": self.team}) - api = jingrow.utils.get_url("/api/method/jcloud.api.account.delete_team") + api = jingrow.utils.get_url("/api/action/jcloud.api.account.delete_team") url = f"{api}?{params}" if jingrow.conf.developer_mode: @@ -173,7 +173,7 @@ class TeamDeletionRequest(PersonalDataDeletionRequest): client = get_jingrow_io_connection() response = client.session.delete( - f"{client.url}/api/method/delete-fc-team", + f"{client.url}/api/action/delete-fc-team", data={"team": self.team}, headers=client.headers, ) diff --git a/jcloud/jcloud/pagetype/team_deletion_request/test_team_deletion_request.py b/jcloud/jcloud/pagetype/team_deletion_request/test_team_deletion_request.py index fa64ef3..00edb90 100644 --- a/jcloud/jcloud/pagetype/team_deletion_request/test_team_deletion_request.py +++ b/jcloud/jcloud/pagetype/team_deletion_request/test_team_deletion_request.py @@ -41,7 +41,7 @@ class TestTeamDeletionRequest(unittest.TestCase): deletion_url = self.team_deletion_request.generate_url_for_confirmation() self.assertTrue( deletion_url.startswith( - jingrow.utils.get_url("/api/method/jcloud.api.account.delete_team") + jingrow.utils.get_url("/api/action/jcloud.api.account.delete_team") ) ) diff --git a/jcloud/marketplace/pagetype/marketplace_app_subscription/marketplace_app_subscription.py b/jcloud/marketplace/pagetype/marketplace_app_subscription/marketplace_app_subscription.py index 95fe495..d5623d1 100644 --- a/jcloud/marketplace/pagetype/marketplace_app_subscription/marketplace_app_subscription.py +++ b/jcloud/marketplace/pagetype/marketplace_app_subscription/marketplace_app_subscription.py @@ -155,7 +155,7 @@ class MarketplaceAppSubscription(Document): try: for path in paths: requests.post( - f"https://{self.site}/api/method/{path}", + f"https://{self.site}/api/action/{path}", data={"app": self.app, "plan": self.plan}, ) except Exception: diff --git a/jcloud/partner/pagetype/partner_approval_request/partner_approval_request.py b/jcloud/partner/pagetype/partner_approval_request/partner_approval_request.py index c67f1b6..ec0b2b9 100644 --- a/jcloud/partner/pagetype/partner_approval_request/partner_approval_request.py +++ b/jcloud/partner/pagetype/partner_approval_request/partner_approval_request.py @@ -75,7 +75,7 @@ class PartnerApprovalRequest(Document): jingrow.throw("Failed to create approval request. Please contact support.") customer = jingrow.db.get_value("Team", self.requested_by, "user") - link = get_url(f"/api/method/jcloud.api.partner.approve_partner_request?key={self.key}") + link = get_url(f"/api/action/jcloud.api.partner.approve_partner_request?key={self.key}") jingrow.sendmail( subject="Partner Approval Request", diff --git a/jcloud/playbooks/roles/prometheus/templates/prometheus.yml b/jcloud/playbooks/roles/prometheus/templates/prometheus.yml index a8dbb4f..2ea6f9f 100644 --- a/jcloud/playbooks/roles/prometheus/templates/prometheus.yml +++ b/jcloud/playbooks/roles/prometheus/templates/prometheus.yml @@ -59,7 +59,7 @@ scrape_configs: target_label: __param_target - source_labels: [__param_target] target_label: instance - regex: 'https://(.*)/api/method/ping' + regex: 'https://(.*)/api/action/ping' - target_label: __address__ replacement: '{{ server }}' file_sd_configs: @@ -80,7 +80,7 @@ scrape_configs: target_label: __param_target - source_labels: [__param_target] target_label: instance - regex: 'https://(.*)/api/method/ping' + regex: 'https://(.*)/api/action/ping' - target_label: __address__ replacement: '{{ server }}' file_sd_configs: diff --git a/jcloud/playbooks/roles/sentry/templates/sentry.conf.py b/jcloud/playbooks/roles/sentry/templates/sentry.conf.py index a747386..aa1288b 100644 --- a/jcloud/playbooks/roles/sentry/templates/sentry.conf.py +++ b/jcloud/playbooks/roles/sentry/templates/sentry.conf.py @@ -5,11 +5,11 @@ OIDC_ISSUER = "Jingrow" OIDC_SCOPE = "openid email" OIDC_AUTHORIZATION_ENDPOINT = ( - "{{ sentry_oauth_server_url }}/api/method/jingrow.integrations.oauth2.authorize" + "{{ sentry_oauth_server_url }}/api/action/jingrow.integrations.oauth2.authorize" ) OIDC_TOKEN_ENDPOINT = ( - "{{ sentry_oauth_server_url }}/api/method/jingrow.integrations.oauth2.get_token" + "{{ sentry_oauth_server_url }}/api/action/jingrow.integrations.oauth2.get_token" ) OIDC_USERINFO_ENDPOINT = ( - "{{ sentry_oauth_server_url }}/api/method/jingrow.integrations.oauth2.openid_profile" + "{{ sentry_oauth_server_url }}/api/action/jingrow.integrations.oauth2.openid_profile" ) diff --git a/jcloud/public/marketplace/js/call.js b/jcloud/public/marketplace/js/call.js index 4fa65d5..6f04c98 100644 --- a/jcloud/public/marketplace/js/call.js +++ b/jcloud/public/marketplace/js/call.js @@ -18,7 +18,7 @@ export default async function call(method, args) { headers['X-Jingrow-CSRF-Token'] = window.csrf_token; } - const res = await fetch(`/api/method/${method}`, { + const res = await fetch(`/api/action/${method}`, { method: 'POST', headers, body: JSON.stringify(args), diff --git a/jcloud/public/migrate b/jcloud/public/migrate index 12829b3..8703212 100755 --- a/jcloud/public/migrate +++ b/jcloud/public/migrate @@ -10,7 +10,7 @@ from html2text import html2text def get_remote_script(remote_site): print("Retrieving Site Migrator...") - request_url = f"https://{remote_site}/api/method/jcloud.api.script" + request_url = f"https://{remote_site}/api/action/jcloud.api.script" request = requests.get(request_url) if request.status_code / 100 != 2: diff --git a/jcloud/public/migrate_2 b/jcloud/public/migrate_2 index 8f615d7..bfce842 100644 --- a/jcloud/public/migrate_2 +++ b/jcloud/public/migrate_2 @@ -14,7 +14,7 @@ import requests def jingrowcloud_migrator(): print("Retreiving Site Migrator...") remote_site = "jingrow.com" - request_url = "https://{}/api/method/jcloud.api.script_2".format(remote_site) + request_url = "https://{}/api/action/jcloud.api.script_2".format(remote_site) request = requests.get(request_url) if request.status_code / 100 != 2: diff --git a/jcloud/saas/api/readme.md b/jcloud/saas/api/readme.md index bc6b3c8..9d45f15 100644 --- a/jcloud/saas/api/readme.md +++ b/jcloud/saas/api/readme.md @@ -30,7 +30,7 @@ Sometimes, we may need to pass the secret token to frontend for some specific ta **Request** ```bash -curl --location --request POST 'http://fc.local:8000/api/method/jcloud.saas.api.auth.generate_access_token' \ +curl --location --request POST 'http://fc.local:8000/api/action/jcloud.saas.api.auth.generate_access_token' \ --header 'x-site: oka-hdz-qpj.tanmoy.fc.jingrow.dev' \ --header 'x-site-token: 004f85a3ae93927d2f0fcc668d11cb71' ``` diff --git a/jcloud/scripts/migrate.py b/jcloud/scripts/migrate.py index d75d9b9..ec124b6 100644 --- a/jcloud/scripts/migrate.py +++ b/jcloud/scripts/migrate.py @@ -471,32 +471,32 @@ def jingrowcloud_migrator(local_site, jingrow_provider): remote_site = jingrow_provider or jingrow.conf.jingrowcloud_url scheme = "https" - login_url = "{}://{}/api/method/login".format(scheme, remote_site) - upload_url = "{}://{}/api/method/jcloud.api.site.new".format(scheme, remote_site) - remote_link_url = "{}://{}/api/method/jcloud.api.site.get_upload_link".format( + login_url = "{}://{}/api/action/login".format(scheme, remote_site) + upload_url = "{}://{}/api/action/jcloud.api.site.new".format(scheme, remote_site) + remote_link_url = "{}://{}/api/action/jcloud.api.site.get_upload_link".format( scheme, remote_site ) - register_remote_url = "{}://{}/api/method/jcloud.api.site.uploaded_backup_info".format( + register_remote_url = "{}://{}/api/action/jcloud.api.site.uploaded_backup_info".format( scheme, remote_site ) - options_url = "{}://{}/api/method/jcloud.api.site.options_for_new".format( + options_url = "{}://{}/api/action/jcloud.api.site.options_for_new".format( scheme, remote_site ) - site_exists_url = "{}://{}/api/method/jcloud.api.site.exists".format( + site_exists_url = "{}://{}/api/action/jcloud.api.site.exists".format( scheme, remote_site ) - site_info_url = "{}://{}/api/method/jcloud.api.site.get".format(scheme, remote_site) - account_details_url = "{}://{}/api/method/jcloud.api.account.get".format( + site_info_url = "{}://{}/api/action/jcloud.api.site.get".format(scheme, remote_site) + account_details_url = "{}://{}/api/action/jcloud.api.account.get".format( scheme, remote_site ) - all_site_url = "{}://{}/api/method/jcloud.api.site.all".format(scheme, remote_site) - restore_site_url = "{}://{}/api/method/jcloud.api.site.restore".format( + all_site_url = "{}://{}/api/action/jcloud.api.site.all".format(scheme, remote_site) + restore_site_url = "{}://{}/api/action/jcloud.api.site.restore".format( scheme, remote_site ) - finish_multipart_url = "{}://{}/api/method/jcloud.api.site.multipart_exit".format( + finish_multipart_url = "{}://{}/api/action/jcloud.api.site.multipart_exit".format( scheme, remote_site ) - site_plans_url = "{}://{}/api/method/jcloud.api.site.get_site_plans".format( + site_plans_url = "{}://{}/api/action/jcloud.api.site.get_site_plans".format( scheme, remote_site ) diff --git a/jcloud/templates/marketplace/macros.html b/jcloud/templates/marketplace/macros.html index c97426e..ab87419 100644 --- a/jcloud/templates/marketplace/macros.html +++ b/jcloud/templates/marketplace/macros.html @@ -51,7 +51,7 @@ {% endmacro %} {% macro form(fields, action='') %} -
+
{%- for df in fields -%}

diff --git a/jcloud/utils/__init__.py b/jcloud/utils/__init__.py index dc8d764..3650d0b 100644 --- a/jcloud/utils/__init__.py +++ b/jcloud/utils/__init__.py @@ -342,7 +342,7 @@ class RemoteJingrowSite: def _validate_jingrow_site(self): """Validates if Jingrow Site and sets RemoteBackupRetrieval.site""" - res = requests.get(f"{self.user_site}/api/method/jingrow.ping", timeout=(5, 10)) + res = requests.get(f"{self.user_site}/api/action/jingrow.ping", timeout=(5, 10)) if not res.ok: jingrow.throw("Invalid Jingrow Site") @@ -354,7 +354,7 @@ class RemoteJingrowSite: def _validate_user_permissions(self): """Validates user permssions on Jingrow Site and sets RemoteBackupRetrieval.user_sid""" response = requests.post( - f"{self.site}/api/method/login", + f"{self.site}/api/action/login", data={"usr": self.user_login, "pwd": self.password_login}, timeout=(5, 10), ) @@ -393,7 +393,7 @@ class RemoteJingrowSite: headers = {"Accept": "application/json", "Content-Type": "application/json"} suffix = f"?sid={self.user_sid}" if self.user_sid else "" res = requests.get( - f"{self.site}/api/method/jingrow.utils.backups.fetch_latest_backups{suffix}", + f"{self.site}/api/action/jingrow.utils.backups.fetch_latest_backups{suffix}", headers=headers, timeout=(5, 10), ) diff --git a/jcloud/utils/billing.py b/jcloud/utils/billing.py index b25edc4..2de5590 100644 --- a/jcloud/utils/billing.py +++ b/jcloud/utils/billing.py @@ -225,7 +225,7 @@ def get_partner_external_connection(mpesa_setup): api_secret = pg.get_password("api_secret") url = pg.url - site_name = url.split("/api/method")[0] + site_name = url.split("/api/action")[0] # Establish connection jingrow.local._external_conn = JingrowClient(site_name, api_key=api_key, api_secret=api_secret) return jingrow.local._external_conn diff --git a/jcloud/www/saas/billing.js b/jcloud/www/saas/billing.js index 95f57ff..efbccac 100644 --- a/jcloud/www/saas/billing.js +++ b/jcloud/www/saas/billing.js @@ -137,7 +137,7 @@ function initiateRequestForLoginToJingrowCloud() { function requestLoginToFC(freezing_msg) { jingrow.request.call({ - url: `${jingrow_cloud_base_endpoint}/api/method/jcloud.api.developer.saas.send_verification_code`, + url: `${jingrow_cloud_base_endpoint}/api/action/jcloud.api.developer.saas.send_verification_code`, type: 'POST', args: { domain: window.location.hostname, @@ -198,7 +198,7 @@ function showFCLogchinalog(email) { return; } jingrow.request.call({ - url: `${jingrow_cloud_base_endpoint}/api/method/jcloud.api.developer.saas.verify_verification_code`, + url: `${jingrow_cloud_base_endpoint}/api/action/jcloud.api.developer.saas.verify_verification_code`, type: 'POST', args: { domain: window.location.hostname, @@ -211,14 +211,14 @@ function showFCLogchinalog(email) { if (r.login_token) { fc_login_dialog.hide(); window.open( - `${jingrow_cloud_base_endpoint}/api/method/jcloud.api.developer.saas.login_to_fc?token=${r.login_token}`, + `${jingrow_cloud_base_endpoint}/api/action/jcloud.api.developer.saas.login_to_fc?token=${r.login_token}`, '_blank', ); jingrow.msgprint({ title: __('Jingrow Login Successful'), indicator: 'green', message: __( - `

You will be redirected to Jingrow soon.

If you haven\'t been redirected, Click here to login

`, + `

You will be redirected to Jingrow soon.

If you haven\'t been redirected, Click here to login

`, ), }); } else {