Google Workspace সাবস্ক্রিপশন আপডেট বা রিনিউ করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
এই পৃষ্ঠাটি ব্যাখ্যা করে যে কীভাবে subscriptions.update()
পদ্ধতি ব্যবহার করে Google Workspace সাবস্ক্রিপশন রিনিউ করা যায়। আপনি সাবস্ক্রিপশনের মেয়াদ শেষ হওয়ার সময় আপডেট করতে এই পদ্ধতিটি ব্যবহার করতে পারেন, যার মধ্যে সর্বোচ্চ মেয়াদ শেষ হওয়ার সম্ভাব্য সময়ের জন্য সাবস্ক্রিপশন পুনর্নবীকরণ করা বা লক্ষ্য সংস্থান সম্পর্কে প্রাপ্ত করার জন্য ইভেন্ট প্রকারের তালিকা আপডেট করা সহ।
অ্যাপস স্ক্রিপ্ট
- একটি অ্যাপস স্ক্রিপ্ট প্রকল্প:
পাইথন
- পাইথন 3.6 বা তার বেশি
- পাইপ প্যাকেজ ম্যানেজমেন্ট টুল
- পাইথনের জন্য সর্বশেষ Google ক্লায়েন্ট লাইব্রেরি। এগুলি ইনস্টল বা আপডেট করতে, আপনার কমান্ড-লাইন ইন্টারফেসে নিম্নলিখিত কমান্ডটি চালান:
pip3 install --upgrade google-api-python-client google-auth-oauthlib
Google Workspace সাবস্ক্রিপশন রিনিউ করুন
এই বিভাগে, আপনি Google Workspace Events API-এর subscriptions.update()
পদ্ধতি ব্যবহার করে সাবস্ক্রিপশনের সর্বোচ্চ মেয়াদ শেষ হওয়ার সময় রিনিউ করেন। সর্বোচ্চ মেয়াদ শেষ হওয়ার সময় নির্দিষ্ট করতে, আপনি Subscription
রিসোর্সের ttl
ক্ষেত্রটি 0
এ আপডেট করুন।
ইভেন্ট পেলোডে কোন রিসোর্স ডেটা অন্তর্ভুক্ত করা হয়েছে তার উপর সর্বোচ্চ মেয়াদ শেষ হওয়ার সময় নির্ভর করে। মেয়াদ শেষ হওয়ার সময় সম্পর্কে আরও জানতে, Google Workspace ইভেন্টের ইভেন্ট ডেটা দেখুন।
Google Workspace সাবস্ক্রিপশন রিনিউ করতে:
অ্যাপস স্ক্রিপ্ট
আপনার Apps স্ক্রিপ্ট প্রকল্পে, updateSubscription
নামে একটি নতুন স্ক্রিপ্ট ফাইল তৈরি করুন এবং নিম্নলিখিত কোড যোগ করুন:
function updateSubscription() {
// The name of the subscription to update.
const name = 'subscriptions/SUBSCRIPTION_ID';
// Call the Workspace Events API using the advanced service.
const response = WorkspaceEvents.Subscriptions.patch({
ttl: '0s',
}, name);
console.log(response);
}
নিম্নলিখিতগুলি প্রতিস্থাপন করুন:
-
SUBSCRIPTION_ID
: সদস্যতার আইডি। আইডি পেতে, আপনি নিম্নলিখিত যে কোনো একটি ব্যবহার করতে পারেন:-
uid
ক্ষেত্রের মান। -
name
ক্ষেত্রে প্রতিনিধিত্ব করা সম্পদ নামের ID। উদাহরণস্বরূপ, যদি সম্পদের নাম হয় subscriptions/subscription-123
, subscription-123
ব্যবহার করুন।
Google Workspace সাবস্ক্রিপশন আপডেট করতে, আপনার Apps Script প্রোজেক্টে ফাংশন updateSubscription
চালান।
পাইথন
আপনার কাজের ডিরেক্টরিতে, update_subscription.py
নামে একটি ফাইল তৈরি করুন এবং নিম্নলিখিত কোড যোগ করুন:
"""Update subscription."""
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
# Specify required scopes.
SCOPES = [SCOPES]
# Authenticate with Google Workspace and get user authentication.
flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)
CREDENTIALS = flow.run_local_server()
# Call the Workspace Events API using the service endpoint.
service = build(
'workspaceevents',
'v1',
credentials=CREDENTIALS,
)
BODY = {
'ttl': {'seconds': 0},
}
NAME = 'subscriptions/SUBSCRIPTION_ID'
response = (
service.subscriptions()
.patch(name=NAME, updateMask='ttl', body=BODY)
.execute()
)
print(response)
নিম্নলিখিতগুলি প্রতিস্থাপন করুন:
-
SCOPES
: এক বা একাধিক OAuth স্কোপ যা সাবস্ক্রিপশনের জন্য প্রতিটি ইভেন্টের ধরনকে সমর্থন করে। স্ট্রিংগুলির একটি অ্যারে হিসাবে ফর্ম্যাট করা হয়েছে৷ একাধিক স্কোপের তালিকা করতে, কমা দ্বারা পৃথক করুন। যেমন, 'https://www.googleapis.com/auth/chat.spaces.readonly', 'https://www.googleapis.com/auth/chat.memberships.readonly'
। -
SUBSCRIPTION_ID
: সদস্যতার আইডি। আইডি পেতে, আপনি নিম্নলিখিত যে কোনো একটি ব্যবহার করতে পারেন:-
uid
ক্ষেত্রের মান। -
name
ক্ষেত্রে প্রতিনিধিত্ব করা সম্পদ নামের ID। উদাহরণস্বরূপ, যদি সম্পদের নাম হয় subscriptions/subscription-123
, subscription-123
ব্যবহার করুন।
আপনার কাজের ডিরেক্টরিতে, নিশ্চিত করুন যে আপনি আপনার OAuth ক্লায়েন্ট আইডি শংসাপত্রগুলি সংরক্ষণ করেছেন এবং ফাইলটির নাম দিয়েছেন credentials.json
। কোড নমুনা এই JSON ফাইলটি Google Workspace-এর সাথে প্রমাণীকরণ করতে এবং ব্যবহারকারীর শংসাপত্র পেতে ব্যবহার করে। নির্দেশাবলীর জন্য, OAuth ক্লায়েন্ট আইডি শংসাপত্র তৈরি করুন দেখুন।
Google Workspace সাবস্ক্রিপশন আপডেট করতে, আপনার টার্মিনালে নিম্নলিখিতটি চালান:
python3 update_subscription.py
Google Workspace Events API একটি
দীর্ঘমেয়াদী অপারেশন প্রদান করে যাতে
Subscription
রিসোর্সের উদাহরণ থাকে।
আপডেট করা Subscription
রিসোর্স সম্পর্কে বিশদ পেতে, operations.get()
পদ্ধতি ব্যবহার করুন এবং আপনার subscriptions.update()
অনুরোধ থেকে ফিরে আসা Operation
রিসোর্স উল্লেখ করুন। অন্যথায়, আপনি সাবস্ক্রিপশনের পূর্ববর্তী সংস্করণ থেকে একটি Operation
রিসোর্স উল্লেখ করলে, প্রতিক্রিয়া খালি থাকে।
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-08-13 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-08-13 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis page provides instructions on renewing a Google Workspace subscription to its maximum expiration time using the \u003ccode\u003esubscriptions.update()\u003c/code\u003e method.\u003c/p\u003e\n"],["\u003cp\u003eYou can also use the \u003ccode\u003esubscriptions.update()\u003c/code\u003e method to update the list of event types to receive or to update the expiration time of a subscription.\u003c/p\u003e\n"],["\u003cp\u003eCode samples are provided in Apps Script and Python demonstrating how to renew a subscription.\u003c/p\u003e\n"],["\u003cp\u003eBefore renewing, you'll need an existing Google Workspace subscription, appropriate user authentication, and necessary tools like an Apps Script project or Python environment.\u003c/p\u003e\n"]]],["The core function described is renewing a Google Workspace subscription using the `subscriptions.update()` method. This involves updating the `ttl` field of the subscription resource to `0` to set the maximum expiration time. The process requires authentication with specific scopes and OAuth client ID credentials. Code examples are provided for Apps Script and Python, detailing how to execute the update, and how to retrieve the updated subscription resource via `operations.get()`. It also mentions that the update can include changes to event types.\n"],null,["# Update or renew a Google Workspace subscription\n\nThis page explains how to renew a Google Workspace subscription using the\n[`subscriptions.update()`](/workspace/events/reference/rest/v1/subscriptions/patch)\nmethod. You can use this method to update the expiration time of a subscription,\nincluding renewing the subscription for the maximum expiration time possible, or\nto update the list of event types to receive about the target resource. \n\n### Apps Script\n\n- \u003cbr /\u003e\n\n A Google Workspace subscription. To create one, see [Create a subscription](/workspace/events/guides/create-subscription).\n\n \u003cbr /\u003e\n\n- Requires user authentication with one or more\n [scopes that support all event types for\n the subscription](/workspace/events/guides/auth#scopes-event-type).\n\n | **Note:** To run the code sample in this guide, you must use the same [OAuth client\n | ID credentials](/workspace/events/guides/create-subscription#create-oauth) that you used to create the subscription.\n\n\u003c!-- --\u003e\n\n- An Apps Script project:\n - Use your Google Cloud project instead of the default one created automatically by Apps Script.\n - For all scopes that you added to configure the OAuth consent screen, you must also add the scopes to the `appsscript.json` file in your Apps Script project. For example, if you specified the `chat.messages` scope, then add the following: \n\n ```console\n \"oauthScopes\": [\n \"https://www.googleapis.com/auth/chat.messages\"\n ]\n \n ```\n - [Enable](/apps-script/guides/services/advanced#enable_advanced_services) the `Google Workspace Events` advanced service.\n\n### Python\n\n- Python 3.6 or greater\n- The [pip](https://pypi.org/project/pip/) package management tool\n- The latest Google client libraries for Python. To install or update them, run the following command in your command-line interface: \n\n ```console\n pip3 install --upgrade google-api-python-client google-auth-oauthlib\n \n ```\n\n\u003c!-- --\u003e\n\n- \u003cbr /\u003e\n\n A Google Workspace subscription. To create one, see [Create a subscription](/workspace/events/guides/create-subscription).\n\n \u003cbr /\u003e\n\n- Requires user authentication with one or more\n [scopes that support all event types for\n the subscription](/workspace/events/guides/auth#scopes-event-type).\n\n | **Note:** To run the code sample in this guide, you must use the same [OAuth client\n | ID credentials](/workspace/events/guides/create-subscription#create-oauth) that you used to create the subscription.\n\nRenew a Google Workspace subscription\n-------------------------------------\n\nIn this section, you use the Google Workspace Events API's\n`subscriptions.update()` method to renew a subscription to its maximum\nexpiration time. To specify the maximum expiration time, you update the `ttl`\nfield of the\n[`Subscription`](/workspace/events/reference/rest/v1/subscriptions) resource\nto `0`.\n\nThe maximum expiration time depends on what resource data is included in the\nevent payload. To learn more about expiration times, see [Event data for\nGoogle Workspace events](/workspace/events/guides#data).\n\nTo renew a Google Workspace subscription: \n\n### Apps Script\n\n1. In your Apps Script project, create a new script file\n named `updateSubscription` and add the following code:\n\n function updateSubscription() {\n // The name of the subscription to update.\n const name = 'subscriptions/\u003cvar translate=\"no\"\u003eSUBSCRIPTION_ID\u003c/var\u003e';\n\n // Call the Workspace Events API using the advanced service.\n const response = WorkspaceEvents.Subscriptions.patch({\n ttl: '0s',\n }, name);\n console.log(response);\n }\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSUBSCRIPTION_ID\u003c/var\u003e: The ID of the subscription. To get the ID, you can use any of the following:\n - The value of the [`uid`](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.uid) field.\n - The ID of the resource name represented in the [`name`](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.name) field. For example, if the resource name is `subscriptions/subscription-123`, use `subscription-123`.\n2. To update the Google Workspace subscription, run the function\n `updateSubscription` in your Apps Script project.\n\n### Python\n\n1. In your working directory, create a file named `update_subscription.py`\n and add the following code:\n\n \"\"\"Update subscription.\"\"\"\n\n from google_auth_oauthlib.flow import InstalledAppFlow\n from googleapiclient.discovery import build\n\n # Specify required scopes.\n SCOPES = [\u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eSCOPES\u003c/span\u003e\u003c/var\u003e]\n\n # Authenticate with Google Workspace and get user authentication.\n flow = InstalledAppFlow.from_client_secrets_file('credentials.json', SCOPES)\n CREDENTIALS = flow.run_local_server()\n\n # Call the Workspace Events API using the service endpoint.\n service = build(\n 'workspaceevents',\n 'v1',\n credentials=CREDENTIALS,\n )\n\n BODY = {\n 'ttl': {'seconds': 0},\n }\n NAME = 'subscriptions/\u003cvar translate=\"no\"\u003eSUBSCRIPTION_ID\u003c/var\u003e'\n response = (\n service.subscriptions()\n .patch(name=NAME, updateMask='ttl', body=BODY)\n .execute()\n )\n print(response)\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eSCOPES\u003c/var\u003e: One or more [OAuth scopes](/workspace/events/guides/auth) that support each event type for the subscription. Formatted as an array of strings. To list multiple scopes, separate by commas. For example, `'https://www.googleapis.com/auth/chat.spaces.readonly',\n 'https://www.googleapis.com/auth/chat.memberships.readonly'`.\n - \u003cvar translate=\"no\"\u003eSUBSCRIPTION_ID\u003c/var\u003e: The ID of the subscription. To get the ID, you can use any of the following:\n - The value of the [`uid`](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.uid) field.\n - The ID of the resource name represented in the [`name`](/workspace/events/reference/rest/v1/subscriptions#Subscription.FIELDS.name) field. For example, if the resource name is `subscriptions/subscription-123`, use `subscription-123`.\n2. In your working directory, make sure you've stored your OAuth client ID\n credentials and named the file `credentials.json`. The code sample uses this JSON\n file to authenticate with Google Workspace and get user credentials. For instructions,\n see [Create OAuth client ID\n credentials](/workspace/events/guides/create-subscription#create-oauth).\n\n3. To update the Google Workspace subscription, run the following in\n your terminal:\n\n python3 update_subscription.py\n\nThe Google Workspace Events API returns a [long-running operation](/workspace/events/reference/rest/v1/operations) that contains the instance of the `Subscription` resource.\n\nTo get details about the updated `Subscription` resource, use the\n[`operations.get()`](/workspace/events/reference/rest/v1/operations/get) method\nand specify the `Operation` resource returned from your `subscriptions.update()`\nrequest. Otherwise, if you specify a `Operation` resource from a previous\nversion of the subscription, the response is empty.\n\nRelated topics\n--------------\n\n- [Get a subscription](/workspace/events/guides/get-subscription)\n- [List subscriptions](/workspace/events/guides/list-subscriptions)\n- [Create a subscription](/workspace/events/guides/create-subscription)\n- [Resolve errors and reactivate a subscription](/workspace/events/guides/reactivate-subscription)\n- [Delete a subscription](/workspace/events/guides/delete-subscription)"]]