• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Bynder / bynder-java-sdk / 7011534548

27 Nov 2023 10:39PM UTC coverage: 45.356%. First build
7011534548

push

github

ahongbynder
API-1822 setup sample files for java sdk api calls

0 of 76 new or added lines in 4 files covered. (0.0%)

708 of 1561 relevant lines covered (45.36%)

0.45 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/bynder/sdk/sample/MediaSample.java
1
package com.bynder.sdk.sample;
2

3
import com.bynder.sdk.configuration.Configuration;
4
import com.bynder.sdk.model.Media;
5
import com.bynder.sdk.model.MediaType;
6

7
import com.bynder.sdk.query.MediaInfoQuery;
8
import com.bynder.sdk.query.MediaModifyQuery;
9
import com.bynder.sdk.query.MediaQuery;
10
import com.bynder.sdk.query.OrderBy;
11

12
import com.bynder.sdk.service.BynderClient;
13
import com.bynder.sdk.service.asset.AssetService;
14
import com.bynder.sdk.util.Utils;
15

16
import java.io.IOException;
17
import java.net.URISyntaxException;
18
import java.net.URL;
19

20
import java.util.List;
21
import java.util.Properties;
22

23
import org.slf4j.Logger;
24
import org.slf4j.LoggerFactory;
25

NEW
26
public class MediaSample {
×
NEW
27
    private static final Logger LOG = LoggerFactory.getLogger(MediaSample.class);
×
28

29
    public static void main(final String[] args) throws URISyntaxException, IOException {
30
        /**
31
         * Loads app.properties file under src/main/resources
32
         */
NEW
33
        Properties appProperties = Utils.loadConfig("app");
×
34

35
        // Initialize BynderClient with a permanent token
NEW
36
        BynderClient client = BynderClient.Builder.create(
×
NEW
37
                new Configuration.Builder(new URL(appProperties.getProperty("BASE_URL")))
×
NEW
38
                        .setPermanentToken(appProperties.getProperty("PERMANENT_TOKEN")).build());
×
39

40
        // Initialize asset service
NEW
41
        AssetService assetService = client.getAssetService();
×
42

43
        // Call the API to request for media assets
NEW
44
        MediaQuery mediaQuery =  new MediaQuery().setType(MediaType.IMAGE).setOrderBy(OrderBy.NAME_DESC).setLimit(10).setPage(1);
×
NEW
45
        List<Media> mediaList = assetService.getMediaList(mediaQuery).blockingSingle().body();
×
NEW
46
        for (Media media : mediaList) {
×
NEW
47
            LOG.info(media.getId());
×
NEW
48
            LOG.info(media.getName());
×
NEW
49
        }
×
50

NEW
51
        if (!mediaList.isEmpty()) {
×
52
            // get media info for single asset
NEW
53
            String mediaId = mediaList.get(0).getId();
×
NEW
54
            MediaInfoQuery mediaInfoQuery = new MediaInfoQuery(mediaId);
×
NEW
55
            Media foundMedia = assetService.getMediaInfo(mediaInfoQuery).blockingSingle().body();
×
NEW
56
            LOG.info("get media info result: ");
×
NEW
57
            LOG.info(foundMedia.getId());
×
NEW
58
            LOG.info(foundMedia.getName());
×
59

60
            // modify name of asset
NEW
61
            MediaModifyQuery modifyQuery = new MediaModifyQuery(mediaId).setName("New Name");
×
NEW
62
            assetService.modifyMedia(modifyQuery).blockingSingle();
×
63

NEW
64
            Media updatedFoundMedia = assetService.getMediaInfo(mediaInfoQuery).blockingSingle().body();
×
NEW
65
            LOG.info("get updated media info result: ");
×
NEW
66
            LOG.info(updatedFoundMedia.getId());
×
NEW
67
            LOG.info(updatedFoundMedia.getName());
×
68
        }
NEW
69
    }
×
70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc