অ্যাকাউন্ট লেবেল আপডেট করুন, অ্যাকাউন্ট লেবেল আপডেট করুন
সেভ করা পৃষ্ঠা গুছিয়ে রাখতে 'সংগ্রহ' ব্যবহার করুন
আপনার পছন্দ অনুযায়ী কন্টেন্ট সেভ করুন ও সঠিক বিভাগে রাখুন।
একটি অ্যাকাউন্ট লেবেল আপডেট করতে এই নমুনা ব্যবহার করুন.
জাভা
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package shopping.css.samples.v1.accountlabels;
import com.google.api.gax.core.FixedCredentialsProvider;
import com.google.auth.oauth2.GoogleCredentials;
import com.google.shopping.css.v1.AccountLabel;
import com.google.shopping.css.v1.AccountLabelsServiceClient;
import com.google.shopping.css.v1.AccountLabelsServiceSettings;
import com.google.shopping.css.v1.UpdateAccountLabelRequest;
import shopping.css.samples.utils.Authenticator;
import shopping.css.samples.utils.Config;
/** This class demonstrates how to update an AccountLabel for a given parent account */
public class UpdateAccountLabel {
private static String getName(String accountId, String labelId) {
return String.format("accounts/%s/labels/%s", accountId, labelId);
}
public static void updateAccountLabel(Config config, String labelId) throws Exception {
GoogleCredentials credential = new Authenticator().authenticate();
AccountLabelsServiceSettings accountLabelsServiceSettings =
AccountLabelsServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(credential))
.build();
String name = getName(config.getDomainId().toString(), labelId);
try (AccountLabelsServiceClient accountLabelsServiceClient =
AccountLabelsServiceClient.create(accountLabelsServiceSettings)) {
UpdateAccountLabelRequest request =
UpdateAccountLabelRequest.newBuilder()
.setAccountLabel(
AccountLabel.newBuilder()
.setName(name)
.setDisplayName("Updated Display Name")
.setDescription("Updated Description")
.build())
.build();
System.out.println("Sending UpdateAccountLabel request");
AccountLabel response = accountLabelsServiceClient.updateAccountLabel(request);
System.out.println("Updated AccountLabel below");
System.out.println(response);
} catch (Exception e) {
System.out.println(e);
}
}
public static void main(String[] args) throws Exception {
final Config config = Config.load();
// The ID of the AccountLabel to be updated
final String labelId = "10000123456";
updateAccountLabel(config, labelId);
}
}
অন্য কিছু উল্লেখ না করা থাকলে, এই পৃষ্ঠার কন্টেন্ট Creative Commons Attribution 4.0 License-এর অধীনে এবং কোডের নমুনাগুলি Apache 2.0 License-এর অধীনে লাইসেন্স প্রাপ্ত। আরও জানতে, Google Developers সাইট নীতি দেখুন। Java হল Oracle এবং/অথবা তার অ্যাফিলিয়েট সংস্থার রেজিস্টার্ড ট্রেডমার্ক।
2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।
[null,null,["2025-07-24 UTC-তে শেষবার আপডেট করা হয়েছে।"],[[["\u003cp\u003eThis Java sample code demonstrates how to update an existing Account Label within the Comparison Shopping Service (CSS) API.\u003c/p\u003e\n"],["\u003cp\u003eIt utilizes the \u003ccode\u003eAccountLabelsServiceClient\u003c/code\u003e to send an \u003ccode\u003eUpdateAccountLabelRequest\u003c/code\u003e with modifications to an Account Label's display name and description.\u003c/p\u003e\n"],["\u003cp\u003eThe sample requires a Google Cloud project with CSS API enabled and authentication set up, alongside specifying the Account ID and Label ID.\u003c/p\u003e\n"],["\u003cp\u003eUpon successful execution, the updated Account Label details will be printed to the console.\u003c/p\u003e\n"]]],[],null,["# Update Account Label\n\nUse this sample to update an Account Label. \n\n### Java\n\n // Copyright 2023 Google LLC\n //\n // Licensed under the Apache License, Version 2.0 (the \"License\");\n // you may not use this file except in compliance with the License.\n // You may obtain a copy of the License at\n //\n // https://www.apache.org/licenses/LICENSE-2.0\n //\n // Unless required by applicable law or agreed to in writing, software\n // distributed under the License is distributed on an \"AS IS\" BASIS,\n // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n // See the License for the specific language governing permissions and\n // limitations under the License.\n\n package shopping.css.samples.v1.accountlabels;\n\n import com.google.api.gax.core.FixedCredentialsProvider;\n import com.google.auth.oauth2.GoogleCredentials;\n import com.google.shopping.css.v1.AccountLabel;\n import com.google.shopping.css.v1.AccountLabelsServiceClient;\n import com.google.shopping.css.v1.AccountLabelsServiceSettings;\n import com.google.shopping.css.v1.UpdateAccountLabelRequest;\n import shopping.css.samples.utils.Authenticator;\n import shopping.css.samples.utils.Config;\n\n /** This class demonstrates how to update an AccountLabel for a given parent account */\n public class UpdateAccountLabel {\n\n private static String getName(String accountId, String labelId) {\n return String.format(\"accounts/%s/labels/%s\", accountId, labelId);\n }\n\n public static void updateAccountLabel(Config config, String labelId) throws Exception {\n GoogleCredentials credential = new Authenticator().authenticate();\n\n AccountLabelsServiceSettings accountLabelsServiceSettings =\n AccountLabelsServiceSettings.newBuilder()\n .setCredentialsProvider(FixedCredentialsProvider.create(credential))\n .build();\n\n String name = getName(config.getDomainId().toString(), labelId);\n\n try (AccountLabelsServiceClient accountLabelsServiceClient =\n AccountLabelsServiceClient.create(accountLabelsServiceSettings)) {\n\n UpdateAccountLabelRequest request =\n UpdateAccountLabelRequest.newBuilder()\n .setAccountLabel(\n AccountLabel.newBuilder()\n .setName(name)\n .setDisplayName(\"Updated Display Name\")\n .setDescription(\"Updated Description\")\n .build())\n .build();\n\n System.out.println(\"Sending UpdateAccountLabel request\");\n AccountLabel response = accountLabelsServiceClient.updateAccountLabel(request);\n System.out.println(\"Updated AccountLabel below\");\n System.out.println(response);\n } catch (Exception e) {\n System.out.println(e);\n }\n }\n\n public static void main(String[] args) throws Exception {\n final Config config = Config.load();\n // The ID of the AccountLabel to be updated\n final String labelId = \"10000123456\";\n\n updateAccountLabel(config, labelId);\n }\n } \n https://github.com/googleads/comparison-shopping-service-api-samples/blob/2f511c3ca413bdbd497f89ae7468b3191dafaa6d/java/src/main/java/shopping/css/samples/v1/accountlabels/UpdateAccountLabel.java"]]