व्यापारी/कंपनी/कारोबारी के डेटा सोर्स एपीआई की खास जानकारी

इस पेज पर, प्रोग्राम के हिसाब से डेटा सोर्स बनाने और उन्हें अपडेट करने का तरीका बताया गया है. इन डेटा सोर्स की मदद से, प्रॉडक्ट डाले जा सकते हैं. ऑटोमेटेड डेटा सोर्स की मदद से, Google को अपना प्रॉडक्ट डेटा आसानी से भेजा जा सकता है. ऑटोमेटेड डेटा सोर्स यह पक्का करते हैं कि आपकी वेबसाइट पर मौजूद काम के प्रॉडक्ट के बारे में सबसे अप-टू-डेट जानकारी, Google तक पहुंच जाए.

Content API for Shopping की मदद से, सिर्फ़ प्राइमरी डेटा सोर्स बनाए जा सकते हैं. Merchant Data sources API की मदद से, ये डेटा सोर्स बनाए जा सकते हैं:

Content API for Shopping की मदद से, सिर्फ़ फ़ाइल इनपुट वाले डेटा सोर्स को मैनेज किया जा सकता है. Merchant API की मदद से, फ़ाइल और एपीआई इनपुट, दोनों के साथ डेटा सोर्स मैनेज किए जा सकते हैं.

Merchant Center के डेटा सोर्स के एपीआई का इस्तेमाल करके, ये काम किए जा सकते हैं:

  • किसी खास feedLabel और contentLanguage के साथ नया प्राइमरी डेटा सोर्स बनाएं.
  • ऐसा डेटा सोर्स बनाएं जिसमें feedLabel और contentLanguage फ़ील्ड सेट न हों. इस तरह के डेटा सोर्स का इस्तेमाल करके, अपने प्रॉडक्ट के लिए कई देशों को टारगेट किया जा सकता है. ऐसा इसलिए, क्योंकि एक ही डेटा सोर्स में feedLabel और contentLanguage के अलग-अलग कॉम्बिनेशन वाले प्रॉडक्ट डाले जा सकते हैं.
  • किसी मौजूदा प्राइमरी डेटा सोर्स से लिंक करने के लिए, पूरक डेटा सोर्स बनाएं.
  • फ़ाइल डेटा सोर्स के लिए शेड्यूल सेट अप करें.
  • डेटा सोर्स अपने-आप मैनेज होने की सुविधा के लिए, अपने खाते को रजिस्टर करें.
  • एपीआई के डेटा सोर्स मैनेज करना.
  • प्राइमरी प्रॉडक्ट डेटा सोर्स का इस्तेमाल करके, डेटा सोर्स के डिफ़ॉल्ट नियम को मैनेज करें.
  • प्रमोशन जैसे अन्य डेटा सोर्स का इस्तेमाल करें.

Merchant API का इस्तेमाल करके, ऐसे डेटा सोर्स में प्रॉडक्ट नहीं डाले जा सकते जिसमें स्थानीय और ऑनलाइन, दोनों तरह के प्रॉडक्ट शामिल हों. डेटा सोर्स चैनलों के बारे में ज़्यादा जानने के लिए, चैनल देखें.

ज़रूरी शर्तें

  • आपका खाता, एक ही स्थानीय भाषा वाले फ़ीड पर माइग्रेट हो गया हो.
  • यह पुष्टि करने के लिए कि खाता पहले से ही डेटा टारगेट स्प्लिट पर माइग्रेट हो चुका है, डेटा सोर्स की सूची या 'get' तरीकों का इस्तेमाल करें. अगर आपका खाता ज़रूरी शर्तें पूरी नहीं करता है, तो आपको अपवाद के तौर पर यह मैसेज दिखेगा. इसके बाद, आपको सहायता टीम से संपर्क करना होगा.

    This account is in the data sources migration process and can't be used with
    this API yet. Contact support for more info on when this account will be able
    to use the data sources endpoint.
    

कोई नया डेटा सोर्स बनाना

प्राइमरी डेटा सोर्स, आपकी Merchant Center इन्वेंट्री के लिए डेटा के मुख्य सोर्स होते हैं. सिर्फ़ प्राइमरी डेटा सोर्स का इस्तेमाल करके, प्रॉडक्ट जोड़े या हटाए जा सकते हैं. अगर प्राइमरी डेटा सोर्स में जोड़ा गया आपका हर प्रॉडक्ट, Merchant Center के डेटा और ज़रूरी शर्तों को पूरा करता है, तो आपको और डेटा सोर्स बनाने की ज़रूरत नहीं पड़ेगी.

किसी खास feedLabel और contentLanguage के साथ नया प्राइमरी डेटा सोर्स बनाने के लिए, टाइप के हिसाब से कॉन्फ़िगरेशन में feedLabel और contentLanguage फ़ील्ड सेट करें. इन फ़ील्ड के बारे में ज़्यादा जानकारी के लिए, PrimaryProductDataSource देखें.

यहां दिए गए अनुरोध के सैंपल में, प्रॉडक्ट का प्राइमरी डेटा सोर्स बनाने का तरीका बताया गया है:

POST https://merchantapi.googleapis.com/datasources/v1beta/accounts/{ACCOUNT_ID}/dataSources

{
  "displayName": "{DISPLAY_NAME}",
  "primaryProductDataSource": {
    "contentLanguage": "{CONTENT_LANGUAGE}",
    "feedLabel": "{FEED_LABEL}",
    "countries": [
      "{COUNTRY}"
    ],
    "channel": "ONLINE_PRODUCTS"
  }
}

इनकी जगह ये डालें:

  • {ACCOUNT_ID}: आपके Merchant Center खाते का यूनीक आइडेंटिफ़ायर.
  • {DISPLAY_NAME}: डेटा सोर्स का डिसप्ले नेम.
  • {CONTENT_LANGUAGE}: डेटा सोर्स में मौजूद प्रॉडक्ट का, दो अक्षर वाला ISO 639-1 भाषा कोड.
  • {FEED_LABEL}: डेटा सोर्स का फ़ीड लेबल.
  • {COUNTRY}: डेटा सोर्स का इस्तेमाल करके अपलोड किए जाने वाले प्रॉडक्ट के टारगेट किए गए देश का CLDR इलाके का कोड.

अनुरोध पूरा होने के बाद, आपको यह जवाब दिखेगा:

{
  "name": "accounts/{ACCOUNT_ID}/dataSources/{DATASOURCE_ID}",
  "dataSourceId": "{DATASOURCE_ID}",
  "displayName": "{DISPLAY_NAME}",
  "primaryProductDataSource": {
    "channel": "ONLINE_PRODUCTS",
    "feedLabel": "{FEED_LABEL}",
    "contentLanguage": "{CONTENT_LANGUAGE}",
    "countries": [
      "{COUNTRY}"
    ],
    "defaultRule": {
      "takeFromDataSources": [
        {
          "self": true
        }
      ]
    }
  },
  "input": "API"
}

डेटा सोर्स बनाने के बारे में ज़्यादा जानने के लिए, accounts.dataSources.create तरीका देखें.

अपना नया डेटा सोर्स देखने के लिए, accounts.dataSources.get या accounts.dataSources.list का इस्तेमाल करें.

यहां दिए गए सैंपल में, GB और en feedLabel और contentLanguage कॉम्बिनेशन के लिए प्राइमरी प्रॉडक्ट डेटा सोर्स बनाने का तरीका बताया गया है.

Java

     public static String createDataSource(Config config, String displayName) throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String parent = getParent(config.getAccountId().toString());

    // The type of data that this datasource will receive.
    PrimaryProductDataSource primaryProductDataSource =
        PrimaryProductDataSource.newBuilder()
            // Channel can be "ONLINE_PRODUCTS" or "LOCAL_PRODUCTS" or "PRODUCTS" .
            // While accepted, datasources with channel "products" representing unified products
            // currently cannot be used with the Products bundle.
            .setChannel(PrimaryProductDataSource.Channel.ONLINE_PRODUCTS)
            .addCountries("GB")
            .build();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      CreateDataSourceRequest request =
          CreateDataSourceRequest.newBuilder()
              .setParent(parent)
              .setDataSource(
                  DataSource.newBuilder()
                      .setDisplayName(displayName)
                      .setPrimaryProductDataSource(primaryProductDataSource)
                      .build())
              .build();

      System.out.println("Sending Create PrimaryProduct DataSource request");
      DataSource response = dataSourcesServiceClient.createDataSource(request);
      System.out.println("Created DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      // Null is necessary to satisfy the compiler as we're not returning a String on failure.
      return null;
    }
  }

एक नया प्राइमरी डेटा सोर्स बनाना, जिससे कई देशों को टारगेट करने में मदद मिलती है

एक से ज़्यादा देशों को टारगेट करने में मदद करने वाला नया प्राइमरी फ़ीड बनाने के लिए, PrimaryProductDataSource का इस्तेमाल करके अपने डेटा सोर्स को कॉन्फ़िगर करें. साथ ही, feedLabel और contentLanguage फ़ील्ड सेट न करें.

Content API for Shopping का इस्तेमाल करने पर, आपके लिए सिर्फ़ एक एपीआई डेटा सोर्स बनाया जाता है. Merchant Center के डेटा सोर्स एपीआई का इस्तेमाल करके, आपके पास कई एपीआई डेटा सोर्स हो सकते हैं. इनमें से कुछ में feedLabel और contentLanguage फ़ील्ड सेट नहीं हो सकते.

एपीआई इनपुट वाले डेटा सोर्स के लिए ही feedLabel और contentLanguage फ़ील्ड सेट नहीं किए जा सकते. इस तरह के डेटा सोर्स, फ़ाइल के इनपुट के लिए काम नहीं करते.

पूरक डेटा सोर्स बनाना और उसे प्राइमरी डेटा सोर्स से लिंक करना

पूरक डेटा सोर्स का इस्तेमाल सिर्फ़ उस प्रॉडक्ट डेटा को अपडेट करने के लिए किया जाता है जो एक या एक से ज़्यादा प्राइमरी डेटा सोर्स में पहले से मौजूद होता है. आपके पास एक से ज़्यादा पूरक डेटा सोर्स हो सकते हैं. साथ ही, हर पूरक डेटा सोर्स, कई प्राइमरी डेटा सोर्स को डेटा उपलब्ध करा सकता है.

accounts.productInputs.insert और accounts.productInputs.delete तरीकों को कॉल करते समय, क्वेरी पैरामीटर के तौर पर डेटा सोर्स का यूनीक आइडेंटिफ़ायर जोड़कर, प्रॉडक्ट डेटा में कुछ अपडेट किए जा सकते हैं. इसके लिए, पूरक डेटा सोर्स का इस्तेमाल किया जा सकता है. मौजूदा प्रॉडक्ट को अपडेट करने के लिए ही, पूरक डेटा सोर्स का इस्तेमाल किया जा सकता है.

पूरक डेटा सोर्स बनाने के लिए, SupplementalProductDataSource का इस्तेमाल करके अपने डेटा सोर्स को कॉन्फ़िगर करें. इसके बाद, अपने प्राइमरी डेटा सोर्स पर defaultRule फ़ील्ड को अपडेट करके, उसे लिंक करें.

पूरक फ़ाइल के डेटा सोर्स में feedLabel और contentLanguage फ़ील्ड सेट होने चाहिए. अतिरिक्त API डेटा सोर्स में, feedLabel और contentLanguage फ़ील्ड हमेशा अनसेट होने चाहिए.

यहां दिए गए सैंपल में, en और GB contentLanguage और feedLabel कॉम्बिनेशन के लिए, फ़ाइल के तौर पर प्रॉडक्ट का पूरक डेटा सोर्स बनाने का तरीका बताया गया है.

Java

     private static FileInput setFileInput() {
    // If FetchSettings are not set, then this will be an `UPLOAD` file type
    // that you must manually upload via the Merchant Center UI.
    return FileInput.newBuilder()
        // FileName is required for `UPLOAD` fileInput type.
        .setFileName("British T-shirts Supplemental Data")
        .build();
  }

  public static String createDataSource(Config config, String displayName, FileInput fileInput)
      throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String parent = getParent(config.getAccountId().toString());

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      CreateDataSourceRequest request =
          CreateDataSourceRequest.newBuilder()
              .setParent(parent)
              .setDataSource(
                  DataSource.newBuilder()
                      .setDisplayName(displayName)
                      .setSupplementalProductDataSource(
                          SupplementalProductDataSource.newBuilder()
                              .setContentLanguage("en")
                              .setFeedLabel("GB")
                              .build())
                      .setFileInput(fileInput)
                      .build())
              .build();

      System.out.println("Sending create SupplementalProduct DataSource request");
      DataSource response = dataSourcesServiceClient.createDataSource(request);
      System.out.println("Created DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      // Null is necessary to satisfy the compiler as we're not returning a String on failure.
      return null;
    }
  }

सभी feedLabel और contentLanguage कॉम्बिनेशन के लिए काम करने वाला पूरक डेटा सोर्स बनाने के लिए, यह सैंपल चलाएं.

Java

     public static String createDataSource(Config config, String displayName) throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String parent = getParent(config.getAccountId().toString());

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      CreateDataSourceRequest request =
          CreateDataSourceRequest.newBuilder()
              .setParent(parent)
              .setDataSource(
                  DataSource.newBuilder()
                      .setDisplayName(displayName)
                      .setSupplementalProductDataSource(
                          SupplementalProductDataSource.newBuilder().build())
                      .build())
              .build();

      System.out.println("Sending create SupplementalProduct DataSource request");
      DataSource response = dataSourcesServiceClient.createDataSource(request);
      System.out.println("Created DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null; // Necessary to satisfy the compiler as we're not returning a
      // String on failure.
    }
  }

अपने फ़ाइल डेटा सोर्स के लिए शेड्यूल सेट अप करना

अपने फ़ाइल फ़ीड के लिए शेड्यूल सेट अप करने के लिए, FileInput फ़ील्ड का इस्तेमाल करके अपने डेटा सोर्स को फ़ाइल डेटा सोर्स के तौर पर कॉन्फ़िगर करें. इसके बाद, FileInput.FetchSettings फ़ील्ड का इस्तेमाल करके fetchsettings सेट अप करें.

कोई डेटा सोर्स मिटाना

अपने खाते से किसी मौजूदा डेटा सोर्स को मिटाने के लिए, accounts.dataSources.delete वाला तरीका अपनाएं.

यहां दिए गए सैंपल में, किसी डेटा सोर्स को मिटाने के लिए, DeleteDataSourceRequest पैकेज का इस्तेमाल करने का तरीका बताया गया है.

Java

     public static void deleteDataSource(Config config, String dataSourceId) throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    String name =
        DataSourceName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setDatasource(dataSourceId)
            .build()
            .toString();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {
      DeleteDataSourceRequest request = DeleteDataSourceRequest.newBuilder().setName(name).build();

      System.out.println("Sending deleteDataSource request");
      // Delete works for any datasource type.
      // If Type "Supplemental", delete will only work if it's not linked to any primary feed.
      // If a link exists and the Type is "Supplemental", you will need to remove the supplemental
      // feed from the default and/or custom rule(s) of any primary feed(s) that references it. Then
      // retry the delete.

      dataSourcesServiceClient.deleteDataSource(request); // No response returned on success.
      System.out.println(
          "Delete successful, note that it may take a few minutes for the delete to update in"
              + " the system.");
    } catch (Exception e) {
      System.out.println(e);
    }
  }

डेटा सोर्स फ़ेच करना

डेटा सोर्स में कॉन्फ़िगर की गई फ़ाइल को फ़ेच करने के लिए, accounts.dataSources.fetch तरीका इस्तेमाल करें. इस तरीके से, आपके खाते के डेटा सोर्स से तुरंत डेटा फ़ेच किया जाता है. यह तरीका सिर्फ़ उन डेटा सोर्स पर काम करता है जिनमें फ़ाइल इनपुट सेट होता है.

डेटा सोर्स पाना

अपने खाते के डेटा सोर्स कॉन्फ़िगरेशन को वापस पाने के लिए, accounts.dataSources.get तरीके का इस्तेमाल करें.

यहां दिए गए सैंपल में, किसी Merchant Center खाते के लिए कोई खास डेटा सोर्स पाने के लिए, GetDataSourceRequest पैकेज का इस्तेमाल करने का तरीका बताया गया है.

Java

     public static DataSource getDataSource(Config config, String dataSourceId) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates datasource name to identify datasource.
    String name =
        DataSourceName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setDatasource(dataSourceId)
            .build()
            .toString();

    // Calls the API and catches and prints any network failures/errors.
    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      // The name has the format: accounts/{account}/datasources/{datasource}
      GetDataSourceRequest request = GetDataSourceRequest.newBuilder().setName(name).build();

      System.out.println("Sending GET DataSource request:");
      DataSource response = dataSourcesServiceClient.getDataSource(request);

      System.out.println("Retrieved DataSource below");
      System.out.println(response);
      return response;
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null; // Necessary to satisfy the compiler as we're not returning a
      // DataSource on failure.
    }
  }

डेटा सोर्स की सूची

अपने खाते के डेटा सोर्स के कॉन्फ़िगरेशन की सूची बनाने के लिए, accounts.dataSources.list तरीका अपनाएं.

यहां दिए गए सैंपल में बताया गया है कि किसी Merchant Center खाते के सभी डेटा सोर्स की सूची बनाने के लिए, ListDataSourceRequest पैकेज का इस्तेमाल कैसे किया जा सकता है.

Java

     public static ArrayList<DataSource> listDataSources(Config config) throws Exception {

    // Obtains OAuth token based on the user's configuration.
    GoogleCredentials credential = new Authenticator().authenticate();

    // Creates service settings using the credentials retrieved above.
    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates parent to identify the account from which to list all the datasources.
    String parent = getParent(config.getAccountId().toString());

    // Calls the API and catches and prints any network failures/errors.
    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      // The parent has the format: accounts/{account}
      ListDataSourcesRequest request =
          ListDataSourcesRequest.newBuilder().setParent(parent).build();

      System.out.println("Sending list datasources request:");
      ListDataSourcesPagedResponse response = dataSourcesServiceClient.listDataSources(request);

      int count = 0;
      ArrayList<DataSource> dataSources = new ArrayList<DataSource>();
      ArrayList<DataSource> justPrimaryDataSources = new ArrayList<DataSource>();

      // Iterates over all rows in all pages and prints the datasource in each row.
      // Automatically uses the `nextPageToken` if returned to fetch all pages of data.
      for (DataSource element : response.iterateAll()) {
        System.out.println(element);
        count++;
        dataSources.add(element);
        // The below lines show how to filter datasources based on type.
        // `element.hasSupplementalProductDataSource()` would give you supplemental
        // datasources, etc.
        if (element.hasPrimaryProductDataSource()) {
          justPrimaryDataSources.add(element);
        }
      }
      System.out.print("The following count of elements were returned: ");
      System.out.println(count);
      return dataSources;
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null; // Necessary to satisfy the compiler as we're not returning an
      // ArrayList<DataSource> on failure.
    }
  }

डेटा सोर्स को पैच करना

किसी मौजूदा डेटा सोर्स के कॉन्फ़िगरेशन को अपडेट करने के लिए, accounts.dataSources.patch तरीका अपनाएं.

यहां दिए गए सैंपल में, डेटा सोर्स को अपडेट करने के लिए, UpdateDataSourceRequest पैकेज का इस्तेमाल करने का तरीका बताया गया है. इसमें, प्राइमरी डेटा सोर्स को अपडेट करने का तरीका भी बताया गया है, ताकि उसके डिफ़ॉल्ट नियम में पूरक डेटा सोर्स जोड़े जा सकें.

Java

     public static String updateDataSource(Config config, String displayName, String dataSourceId)
      throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Creates datasource name to identify datasource.
    String name =
        DataSourceName.newBuilder()
            .setAccount(config.getAccountId().toString())
            .setDatasource(dataSourceId)
            .build()
            .toString();

    DataSource dataSource =
        DataSource.newBuilder()
            // Update the datasource to have the new display name
            .setDisplayName(displayName)
            .setName(name)
            .build();

    FieldMask fieldMask = FieldMask.newBuilder().addPaths("display_name").build();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      UpdateDataSourceRequest request =
          UpdateDataSourceRequest.newBuilder()
              .setDataSource(dataSource)
              .setUpdateMask(fieldMask)
              .build();

      System.out.println("Sending Update DataSource request");
      DataSource response = dataSourcesServiceClient.updateDataSource(request);
      System.out.println("Updated DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null;
    }
  }

  public String updateDataSource(
      Config config,
      String primaryDataSourceName,
      String firstSupplementalDataSourceName,
      String secondSupplementalDataSourceName)
      throws Exception {
    GoogleCredentials credential = new Authenticator().authenticate();

    DataSourcesServiceSettings dataSourcesServiceSettings =
        DataSourcesServiceSettings.newBuilder()
            .setCredentialsProvider(FixedCredentialsProvider.create(credential))
            .build();

    // Setting self to 'true' refers to the primary datasource itself.
    DataSourceReference dataSourceReferenceSelf =
        DataSourceReference.newBuilder().setSelf(true).build();
    DataSourceReference firstSupplementalDataSourceReference =
        DataSourceReference.newBuilder()
            .setSupplementalDataSourceName(firstSupplementalDataSourceName)
            .build();
    DataSourceReference secondSupplementalDataSourceReference =
        DataSourceReference.newBuilder()
            .setSupplementalDataSourceName(secondSupplementalDataSourceName)
            .build();

    // The attributes will first be taken from the primary DataSource.
    // Then the first supplemental DataSource if the attribute is not in the primary DataSource
    // And finally the second supplemental DataSource if not in the first two DataSources.
    // Note that CustomRules could change the behavior of how updates are applied.
    DefaultRule defaultRule =
        DefaultRule.newBuilder()
            .addTakeFromDataSources(dataSourceReferenceSelf)
            .addTakeFromDataSources(firstSupplementalDataSourceReference)
            .addTakeFromDataSources(secondSupplementalDataSourceReference)
            .build();

    // The type of data that this datasource will receive.
    PrimaryProductDataSource primaryProductDataSource =
        PrimaryProductDataSource.newBuilder().setDefaultRule(defaultRule).build();

    DataSource dataSource =
        DataSource.newBuilder()
            // Update the primary datasource to have the default rule datasources in the correct
            // order.
            .setPrimaryProductDataSource(primaryProductDataSource)
            .setName(primaryDataSourceName)
            .build();

    // The '.' signifies a nested field.
    FieldMask fieldMask =
        FieldMask.newBuilder().addPaths("primary_product_data_source.default_rule").build();

    try (DataSourcesServiceClient dataSourcesServiceClient =
        DataSourcesServiceClient.create(dataSourcesServiceSettings)) {

      UpdateDataSourceRequest request =
          UpdateDataSourceRequest.newBuilder()
              .setDataSource(dataSource)
              .setUpdateMask(fieldMask)
              .build();

      System.out.println("Sending Update DataSource request");
      DataSource response = dataSourcesServiceClient.updateDataSource(request);
      System.out.println("Updated DataSource Name below");
      System.out.println(response.getName());
      return response.getName();
    } catch (Exception e) {
      System.out.println(e);
      System.exit(1);
      return null;
    }
  }

प्राइमरी प्रॉडक्ट डेटा सोर्स की मदद से, डेटा सोर्स के डिफ़ॉल्ट नियम को मैनेज किया जा सकता है. डिफ़ॉल्ट नियम वह नियम है जो आपके डेटा सोर्स के सभी एट्रिब्यूट पर लागू होता है. डेटा सोर्स बनाते समय या डिफ़ॉल्ट नियम वाले फ़ील्ड की मदद से किसी मौजूदा डेटा सोर्स को अपडेट करके, डिफ़ॉल्ट नियम सेट किया जा सकता है.

नियम सेट अप करने के बारे में ज़्यादा जानने के लिए, प्रॉडक्ट डेटा सोर्स के लिए नियम सेट अप करना लेख पढ़ें.

यहां दिए गए सैंपल कॉन्फ़िगरेशन से यह पक्का होता है कि सभी एट्रिब्यूट, पहले यूनीक आइडेंटिफ़ायर 1001 वाले डेटा सोर्स से लिए जाते हैं. इसके बाद, प्राइमरी डेटा सोर्स से मौजूद न होने वाले एट्रिब्यूट जोड़े जाते हैं. अगर बाकी एट्रिब्यूट किसी अन्य डेटा सोर्स में पहले से मौजूद नहीं हैं, तो उन्हें यूनीक आइडेंटिफ़ायर 1002 वाले पूरक डेटा सोर्स से लिया जाएगा. अगर एक ही एट्रिब्यूट को एक से ज़्यादा डेटा सोर्स में दिया गया है, तो सूची में सबसे ऊपर मौजूद वैल्यू को चुना जाता है.

defaultRule {
 takeFromDataSources: [
   '1001', // Supplemental product data source
   'self', //  Self reference to the primary data source
   '1002' // Supplemental product data source
 ]
}

फ़ीड अपने-आप मैनेज होना

डेटा सोर्स को अपने-आप मैनेज करने की सुविधा के लिए, अपने खाते को रजिस्टर करने के लिए, आपको ये काम करने होंगे:

रजिस्टर करने की ज़रूरी शर्तें पूरी करने के बाद, डेटा सोर्स को अपने-आप मैनेज करने की सुविधा चालू करने के लिए, accounts.autofeedSettings.updateAutofeedSettings वाला तरीका अपनाएं. डेटा सोर्स को अपने-आप मैनेज करने की सुविधा चालू करने पर, Google आपके ऑनलाइन स्टोर से प्रॉडक्ट अपने-आप जोड़ देता है. साथ ही, यह पक्का करता है कि वे Google के प्लैटफ़ॉर्म पर हमेशा अप-टू-डेट रहें.

फ़ाइल अपलोड होने की स्थिति देखना

फ़ाइल, फ़ेच या स्प्रेडशीट में से किसी भी डेटा सोर्स का स्टेटस पाने के लिए, accounts.dataSources.fileUploads सेवा के GET तरीके को कॉल किया जा सकता है. डेटा सोर्स को प्रोसेस करने के बाद, डेटा सोर्स को फिर से ऐक्सेस करने पर, डेटा सोर्स के आखिरी नतीजे का पता लगाने के लिए, नाम आइडेंटिफ़ायर latest का इस्तेमाल करें.

GET https://merchantapi.googleapis.com/accounts/v1beta/{ACCOUNT_ID}/datasources/{DATASOURCE_ID}/fileUploads/latest

फ़ाइल अपलोड करने की स्थिति में, आपके प्रॉडक्ट की पूरी जानकारी दिख सकती है. इसमें संभावित समस्याएं भी शामिल हो सकती हैं.

ध्यान दें कि अगर फ़ाइल कभी अपलोड नहीं की गई है, तो हो सकता है कि फ़ाइल अपलोड करने की स्थिति न दिखे. अगर फ़ाइल अपलोड होने के तुरंत बाद अनुरोध किया जाता है, तो फ़ाइल अपलोड होने की स्थिति 'प्रोसेस में है' हो सकती है.