|
| 1 | +--- |
| 2 | +title: Azure Template Two client library for Java |
| 3 | +keywords: Azure, java, SDK, API, azure-sdk-template-two, template |
| 4 | +author: hallipr |
| 5 | +ms.author: pahallis |
| 6 | +ms.date: 04/20/2022 |
| 7 | +ms.topic: reference |
| 8 | +ms.prod: azure |
| 9 | +ms.technology: azure |
| 10 | +ms.devlang: java |
| 11 | +ms.service: template |
| 12 | +--- |
| 13 | +# Azure Template Two client library for Java - Version 1.0.0-beta.1 |
| 14 | + |
| 15 | + |
| 16 | +Use the guidelines in each section of this template to ensure consistency and readability of your README. |
| 17 | +The README resides in your package's GitHub repository at the root of its directory within the repo. |
| 18 | +It's also used as the package distribution page (NuGet, PyPi, npm, etc.) and as a Quickstart on docs.microsoft.com. |
| 19 | + |
| 20 | +**Title**: The H1 of your README should be in the format: `# [Product Name] client library for [Language]` |
| 21 | + |
| 22 | +* All headings, including the H1, should use **sentence-style capitalization**. Refer to the [Microsoft Style Guide][style-guide-msft]. |
| 23 | +* Example: `# Azure Batch client library for Java - Version 1.0.0-beta.1 |
| 24 | +` |
| 25 | + |
| 26 | +**Introduction**: The introduction appears directly under the title (H1) of your README. |
| 27 | + |
| 28 | +* **DO NOT** use an "Introduction" or "Overview" heading (H2) for this section. |
| 29 | +* First sentence: **Describe the service** briefly. You can usually use the first line of the service's docs landing page |
| 30 | + for this (Example: [Cosmos DB docs landing page](https://docs.microsoft.com/azure/cosmos-db/)). |
| 31 | +* Next, add a **bulleted list** of the **most common tasks** supported by the package or library, prefaced with |
| 32 | + "Use the client library for [Product Name] to:". Then, provide code snippets for these tasks in the [Examples](#examples) |
| 33 | + section later in the document. Keep the task list short but include those tasks most developers need to perform with your package. |
| 34 | + |
| 35 | +> TIP: Your README should be as **brief** as possible but **no more brief** than necessary to get a developer new to Azure, |
| 36 | +> the service, or the package up and running quickly. Keep it brief, but include everything a developer needs to make |
| 37 | +> their first API call successfully. |
| 38 | +
|
| 39 | +## Getting started |
| 40 | + |
| 41 | +This section should include everything a developer needs to do to install and create their first client connection *very quickly*. |
| 42 | + |
| 43 | +### Install the package |
| 44 | + |
| 45 | +First, provide instruction for obtaining and installing the package or library. This section might include only a single |
| 46 | +line of code, like `pip install package-name`, but should enable a developer to successfully install the package from |
| 47 | +NuGet, pip, npm, Maven, or even cloning a GitHub repository. |
| 48 | + |
| 49 | +Include a **Prerequisites** line after the install command that details any requirements that must be satisfied before |
| 50 | +a developer can [authenticate](#authenticate-the-client) and test all the snippets in the [Examples](#examples) section. |
| 51 | +For example, for Cosmos DB: |
| 52 | + |
| 53 | +**Prerequisites**: You must have an [Azure subscription](https://azure.microsoft.com/free/), [Cosmos DB account](https://docs.microsoft.com/azure/cosmos-db/account-overview) (SQL API), and [Java Development Kit (JDK) with version 8 or above][jdk] to use this package. |
| 54 | + |
| 55 | +> TODO: Once the library has GA'ed include the instructions on how to include the BOM file directly. And the benefit of using the BOM file over adding a direct dependency to the project. |
| 56 | +
|
| 57 | +### Authenticate the client |
| 58 | + |
| 59 | +If your library requires authentication for use, such as for Azure services, include instructions and example code |
| 60 | +needed for initializing and authenticating. |
| 61 | + |
| 62 | +For example, include details on obtaining an account key and endpoint URI, setting environment variables for each, and |
| 63 | +initializing the client object. |
| 64 | + |
| 65 | +## Key concepts |
| 66 | + |
| 67 | +The *Key concepts* section should describe the functionality of the main classes. Point out the most important and |
| 68 | +useful classes in the package (with links to their reference pages) and explain how those classes work together. Feel |
| 69 | +free to use bulleted lists, tables, code blocks, or even diagrams for clarity. |
| 70 | + |
| 71 | +## Examples |
| 72 | + |
| 73 | +Include code snippets and short descriptions for each task you listed in the [Introduction](#introduction) (the bulleted list). |
| 74 | +Briefly explain each operation, but include enough clarity to explain complex or otherwise tricky operations. |
| 75 | + |
| 76 | +If possible, use the same example snippets that your in-code documentation uses. For example, use the snippets in your |
| 77 | +`ReadmeSamples.java` that `codesnippet-maven-plugin` ingests via its [README syntax](https://github.com/Azure/azure-sdk-tools/tree/main/packages/java-packages/codesnippet-maven-plugin#injecting-codesnippets-into-readmes). |
| 78 | +The `ReadmeSamples.java` file containing the snippets should reside alongside your package's code, and should be |
| 79 | +validated in an automated fashion. |
| 80 | + |
| 81 | +Each example in the *Examples* section starts with an H3 that describes the example. At the top of this section, just |
| 82 | +under the *Examples* H2, add a bulleted list linking to each example H3. Each example should deep-link to the types |
| 83 | +and/or members used in the example. |
| 84 | + |
| 85 | +* [Create the thing](#create-the-thing) |
| 86 | +* [Get the thing](#get-the-thing) |
| 87 | +* [List the things](#list-the-things) |
| 88 | + |
| 89 | +### Create the thing |
| 90 | + |
| 91 | +Use the `createThing` method to create a Thing reference; this method does not make a network call. To persist the |
| 92 | +Thing in the service, call `Thing.save`. |
| 93 | + |
| 94 | +```java |
| 95 | +Thing thing = client.createThing(id, name); |
| 96 | +thing.save(); |
| 97 | +``` |
| 98 | + |
| 99 | +### Get the thing |
| 100 | + |
| 101 | +The `getThing` method retrieves a Thing from the service. The `id` parameter is the unique ID of the Thing, not its |
| 102 | +"name" property. |
| 103 | + |
| 104 | +```java |
| 105 | +Thing thing = client.getThing(id); |
| 106 | +``` |
| 107 | + |
| 108 | +### List the things |
| 109 | + |
| 110 | +Use `listThings` to get one or more Thing objects from the service. If there are no Things available, a `404` exception |
| 111 | +is thrown (see [Troubleshooting](#troubleshooting) for details on handling exceptions). |
| 112 | + |
| 113 | +```java |
| 114 | +List<Thing> things = client.listThings(); |
| 115 | +``` |
| 116 | + |
| 117 | +## Troubleshooting |
| 118 | + |
| 119 | +Describe common errors and exceptions, how to "unpack" them if necessary, and include guidance for graceful handling and recovery. |
| 120 | + |
| 121 | +Provide information to help developers avoid throttling or other service-enforced errors they might encounter. For example, |
| 122 | +provide guidance and examples for using retry or connection policies in the API. |
| 123 | + |
| 124 | +If the package, or a related package supports it, include tips for logging or enabling instrumentation to help them debug their code. |
| 125 | + |
| 126 | +### Enabling Logging |
| 127 | + |
| 128 | +Azure SDKs for Java provide a consistent logging story to help aid in troubleshooting application errors and expedite |
| 129 | +their resolution. The logs produced will capture the flow of an application before reaching the terminal state to help |
| 130 | +locate the root issue. View the [logging][logging] wiki for guidance about enabling logging. |
| 131 | + |
| 132 | +### Default HTTP Client |
| 133 | + |
| 134 | +By default, a Netty based HTTP client will be used. The [HTTP clients wiki](https://github.com/Azure/azure-sdk-for-java/wiki/HTTP-clients) |
| 135 | +provides more information on configuring or changing the HTTP client. |
| 136 | + |
| 137 | +## Next steps |
| 138 | + |
| 139 | +* Provide a link to additional code examples, ideally to those sitting alongside the README in the package's `/samples` directory. |
| 140 | +* If appropriate, point users to other packages that might be useful. |
| 141 | +* If you think there's a good chance that developers might stumble across your package in error (because they're searching |
| 142 | + for specific functionality and mistakenly think the package provides that functionality), point them to the packages |
| 143 | + they might be looking for. |
| 144 | + |
| 145 | +* After adding the new SDK, you need to include the package in the following locations |
| 146 | +1. `version_client.txt` - include the package with the version. |
| 147 | +2. parent pom - `<enlistmentroot>\pom.xml` - Multiple places in the file. |
| 148 | + |
| 149 | +## Contributing |
| 150 | + |
| 151 | +This project welcomes contributions and suggestions. Most contributions require you to agree to a |
| 152 | +[Contributor License Agreement (CLA)][cla] declaring that you have the right to, and actually do, grant us the rights |
| 153 | +to use your contribution. |
| 154 | + |
| 155 | +When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate |
| 156 | +the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to |
| 157 | +do this once across all repos using our CLA. |
| 158 | + |
| 159 | +This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For more information see the |
| 160 | +[Code of Conduct FAQ ][coc_faq] or contact [[email protected]][coc_contact] with any additional questions or comments. |
| 161 | + |
| 162 | +<!-- LINKS --> |
| 163 | +[style-guide-msft]: https://docs.microsoft.com/style-guide/capitalization |
| 164 | +[jdk]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable |
| 165 | +[logging]: https://github.com/Azure/azure-sdk-for-java/wiki/Logging-with-Azure-SDK |
| 166 | +[cla]: https://cla.microsoft.com |
| 167 | +[coc]: https://opensource.microsoft.com/codeofconduct/ |
| 168 | +[coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ |
| 169 | +[coc_contact]: mailto:[email protected] |
| 170 | + |
| 171 | + |
| 172 | + |
0 commit comments