Files
doc-exports/docs/as/dev/en-us_topic_0110252703.html
guoyanyan 6db57a0298 AS DEV 20221025 v2
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: guoyanyan <guoyanyan3@huawei.com>
Co-committed-by: guoyanyan <guoyanyan3@huawei.com>
2022-10-25 11:36:59 +00:00

38 lines
4.0 KiB
HTML

<a name="EN-US_TOPIC_0110252703"></a><a name="EN-US_TOPIC_0110252703"></a>
<h1 class="topictitle1">Creating an AS Policy</h1>
<div id="body43408526"><div class="section" id="EN-US_TOPIC_0110252703__section7653740"><h4 class="sectiontitle">Scenario</h4><p id="EN-US_TOPIC_0110252703__p13658134117306">An AS policy specifies a condition for triggering a scaling action. When the trigger condition is met, a scaling action occurs.</p>
</div>
<div class="section" id="EN-US_TOPIC_0110252703__section1774803"><h4 class="sectiontitle">Precautions</h4><ul id="EN-US_TOPIC_0110252703__ul7006171"><li id="EN-US_TOPIC_0110252703__li63055544">If you use a token for authentication, you must call the IAM API to obtain the user's token and add <strong id="EN-US_TOPIC_0110252703__b14154111058">X-Auth-Token</strong> to the request message header of ECS API you call.</li><li id="EN-US_TOPIC_0110252703__li30628985">The validity period of the token obtained from the IAM service is 24 hours. If you want to use a token for authentication, you can cache it to avoid frequently calling the IAM API.</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0110252703__section15973227"><h4 class="sectiontitle">Involved APIs</h4><ul id="EN-US_TOPIC_0110252703__ul65028760"><li id="EN-US_TOPIC_0110252703__li48387936">IAM API used to obtain the token</li><li id="EN-US_TOPIC_0110252703__li32838240">API used to query AS groups</li><li id="EN-US_TOPIC_0110252703__li27108706">API used to create an AS policy</li></ul>
</div>
<div class="section" id="EN-US_TOPIC_0110252703__section9541318"><h4 class="sectiontitle">Procedure</h4><ol id="EN-US_TOPIC_0110252703__ol1241962524014"><li id="EN-US_TOPIC_0110252703__li16418192513408">For details about token authentication, see <a href="https://docs.otc.t-systems.com/en-us/api/apiug/apig-en-api-180328003.html" target="_blank" rel="noopener noreferrer">Token Authentication</a>.</li><li id="EN-US_TOPIC_0110252703__li94188256404">Send <strong id="EN-US_TOPIC_0110252703__b1858514508518">GET https://</strong><em id="EN-US_TOPIC_0110252703__i1958611505512">AS endpoint</em><strong id="EN-US_TOPIC_0110252703__b7586550750">/autoscaling-api/v1/{tenant_id}/scaling_group</strong> to obtain AS groups. Use the ID of one of the AS groups as parameter <strong id="EN-US_TOPIC_0110252703__b7587250253">scaling_group_id</strong> for creating an AS policy. For the response parameters of the API used to query AS groups, see section <a href="en-us_topic_0110252693.html">Response Parameters for Querying AS Groups</a>.</li><li id="EN-US_TOPIC_0110252703__li1841802594017">Send <strong id="EN-US_TOPIC_0110252703__b620210301776">POST https://</strong><em id="EN-US_TOPIC_0110252703__i2094173210711">AS endpoint</em><strong id="EN-US_TOPIC_0110252703__b165365366714">/autoscaling-api/v1/{tenant_id}/scaling_policy</strong> to create an AS policy, such as a periodic policy which is executed on Sunday, Tuesday, and Thursday. For detailed parameters, see section "Creating an AS Policy" in the <em id="EN-US_TOPIC_0110252703__i19514135816811">Auto Scaling API Reference</em>.<div class="p" id="EN-US_TOPIC_0110252703__p20165064617">Specify the following parameters in the request body:<pre class="screen" id="EN-US_TOPIC_0110252703__screen1941911258406">{
"scaling_policy_name": "as-policy-test",
"scaling_policy_action": {
"operation": "ADD",
"instance_number": 1
},
"cool_down_time": 900,
"scheduled_policy": {
"launch_time": "16:00",
"recurrence_type": "Weekly",
"recurrence_value": "1,3,5",
"start_time": "2018-05-04T03:34Z",
"end_time": "2018-12-27T03:34Z"
},
"scaling_policy_type": "RECURRENCE",
"scaling_group_id": "5bc3aa02-b83e-454c-aba1-4d2095c68f8b"
}</pre>
</div>
<p id="EN-US_TOPIC_0110252703__p1144545564718"><strong id="EN-US_TOPIC_0110252703__b7810927595">scaling_policy_id</strong> is returned if the request is successful.</p>
</li></ol>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="en-us_topic_0110252699.html">Common Operations</a></div>
</div>
</div>