Change the resource group

Updated at:

Call ChangeResourceGroup to change the resource group of a project.

Prerequisites

Parameters

Request parameters

Parameter

Type

Required

Description

Example

resourceId

String

Yes

Project name.

ali-test-project

resourceGroupId

String

Yes

Resource group ID. Find this value in the resource group details.

rg-ae******ey

resourceType

String

No

Resource type. Only PROJECT is supported.

PROJECT

Response parameters

For information about the response parameters, see ChangeResourceGroup.

Sample code

import com.aliyun.openservices.log.Client;
import com.aliyun.openservices.log.exception.LogException;

import org.junit.Assert;


public class ChangeResourceGroup {
    // In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
    static String accessId = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_ID");
    static String accessKey = System.getenv("ALIBABA_CLOUD_ACCESS_KEY_SECRET");

    // The endpoint of Simple Log Service. In this example, the endpoint of the China (Hangzhou) region is used. Replace this parameter value with your actual endpoint.
    static String host = "cn-hangzhou.log.aliyuncs.com";
    // Initialize the Simple Log Service client.
    static Client client = new Client(host, accessId, accessKey);

    private static final String RESOURCE_ID = "ali-peoject-test1";


    public static void main(String[] args) {

        try {
            String newResourceGroupId = "rg-cn-xxxxxxxxxxxxxxxx";
            client.changeResourceGroup("PROJECT", RESOURCE_ID, newResourceGroupId);
            Assert.assertEquals(newResourceGroupId, client.GetProject(RESOURCE_ID).getResourceGroupId());
        } catch (LogException e) {
            Assert.fail("change resource group id should not fail");
        }
    }
}

References