### Start SonarQube Server Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/development-tutorials/static-code-analysis/scan-tool.md Navigate to the `bin//` directory of your SonarQube installation and run the `sonar.sh` script to start the server. ```bash $ ./sonar.sh start ``` -------------------------------- ### Start and Wait for Futures Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/async.html Initiate asynchronous operations using `start` and retrieve their results with `wait`. This example shows starting `sum` and `squarePlusCube` functions asynchronously. ```ballerina future f1 = start sum(40, 50); int result = squarePlusCube(f1); _ = wait f1; io:println("SQ + CB = ", result); ``` -------------------------------- ### Usage Example: LoggerRegistry Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/log/spec.md Example demonstrating how to use the LoggerRegistry to get logger IDs and retrieve a logger by its ID. ```APIDOC ```ballerina log:LoggerRegistry registry = log:getLoggerRegistry(); // List all registered logger IDs string[] ids = registry.getIds(); // e.g., ["root", "myorg/payment:payment-service", "myorg/payment:init"] // Look up a logger by ID and change its level log:Logger? logger = registry.getById("myorg/payment:payment-service"); if logger is log:Logger { check logger.setLevel(log:DEBUG); } ``` ``` -------------------------------- ### Initialize MySQL Client with All Parameters Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/mysql-init-options.html This snippet demonstrates initializing the MySQL client by providing all possible parameters: host, user, password, database, port, options, and connection pool. ```ballerina mysql:Client mysqlClient8 = check new (host = "localhost", user = dbUser, password = dbPassword, database = "information_schema", port = 3306, options = mysqlOptions, connectionPool = connPool); ``` -------------------------------- ### Get Header Value Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/api-docs/ballerina/mime/objects/Entity.html Retrieves the value of a specific header by its name and position. Example shows getting the `CONTENT_LENGTH` header. ```ballerina string headerName = mimeEntity.getHeader(mime:CONTENT_LENGTH); ``` -------------------------------- ### Initialize database table with sample data Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/jdbc2-query-operation.html Execute SQL statements to drop an existing table if it exists, create a new `Customers` table, and insert sample data into it. ```ballerina sql:ExecuteResult? result = check jdbcClient->execute("DROP TABLE IF EXISTS Customers"); result = check jdbcClient->execute("CREATE TABLE IF NOT EXISTS Customers(" + "customerId INTEGER NOT NULL IDENTITY, firstName VARCHAR(300)," "lastName VARCHAR(300), registrationID INTEGER, creditLimit DOUBLE," "country VARCHAR(300), PRIMARY KEY (customerId))"); result = check jdbcClient->execute("INSERT INTO Customers (firstName," + "lastName,registrationID,creditLimit,country) VALUES ('Peter', " + "'Stuart', 1, 5000.75, 'USA')"); result = check jdbcClient->execute("INSERT INTO Customers (firstName, " + "lastName,registrationID,creditLimit,country) VALUES ('Dan', 'Brown'," + "2, 10000, 'UK')"); ``` -------------------------------- ### Running the Ballerina Parallel Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/hello-world-parallel.html This shows the command to execute the Ballerina parallel 'Hello, World!' example and its expected output. ```bash ballerina run hello_world_parallel.bal Hello, World! #m ``` -------------------------------- ### Run JDBC Initialization Sample Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/jdbc2-init-options.html Command to execute the Ballerina JDBC initialization options sample. Navigate to the directory containing the `.bal` file before running. ```bash ballerina run jdbc2_init_options.bal ``` -------------------------------- ### Ballerina Service with Response Examples Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/integration-tools/openapi-tool.md Illustrates adding response examples for a 'get store' resource in a Ballerina service. It includes an inline JSON example and a reference to an external file for the same media type. ```ballerina ... service /convert on new http:Listener(9090) { ... @openapi:ResourceInfo { operationId: "getStoreData", examples: { "response": { "200": { "examples": { "application/json": { "store01": { "value": { "materials": "Wood", "status": "InProgress", "item": "Table", "amount": 120 } }, "store02": { "filePath": "storeExamples.json" } } } } } } } resource function get store() returns Inventory? { } ... ``` -------------------------------- ### Run HTTP Redirects Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-redirects.html Command to execute the Ballerina HTTP redirects example. This command starts the listeners and runs the defined services. ```bash ballerina run http_redirects.bal ``` -------------------------------- ### Example: Client Stub Generation Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/0.990/learn/api-docs/ballerina/swagger.html This is an example command for generating a client stub from a Swagger file named `hello_service.yaml` and specifying the package name as `hello_client`. ```bash ballerina swagger client hello_service.yaml -p hello_client ``` -------------------------------- ### WebSub Notification Request Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/websubhub/spec.md Example of an HTTP GET request sent to a subscriber's callback endpoint to notify of a hub-level error. ```http GET https://subscriber.com/callback?hub.mode=hub-error&hub.topic=http://example.com/topic&hub.reason=Broker+unavailable ``` -------------------------------- ### Start Mock Server with Test Case Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/pages/learn/enterprise-integration-patterns/enterprise-integration-patterns/mock-http/README.md Use this command to start the mock server and specify the test case directory and case number. ```sh bal run -- -Cpath=../content-enricher/tests -Ccase=1 ``` -------------------------------- ### Start Ballerina Hub Service Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/0.990/learn/api-docs/ballerina/websub.html Example of starting the Ballerina WebSub Hub service. This is typically done within the main function of a Ballerina application. ```ballerina import ballerina/log; import ballerina/http; import ballerina/runtime; import ballerina/websub; public function main() { log:printInfo("Starting up the Ballerina Hub Service"); ``` -------------------------------- ### Initialize MySQL Table Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/mysql-query-operation.html Sets up the MySQL database by creating a database and a 'Customers' table, then populating it with sample data. This function ensures the database is ready for query operations. ```ballerina function initializeTable() returns sql:Error? { mysql:Client mysqlClient = check new (user = dbUser, password = dbPassword); sql:ExecuteResult? result = check mysqlClient ⁙⁙->execute("CREATE DATABASE IF NOT EXISTS MYSQL_BBE"); result = check mysqlClient ⁙⁙->execute("DROP TABLE IF EXISTS " + "MYSQL_BBE.Customers"); result = check mysqlClient ⁙⁙->execute("CREATE TABLE IF NOT EXISTS " + "MYSQL_BBE.Customers(customerId INTEGER " + "NOT NULL AUTO_INCREMENT, FirstName VARCHAR(300), LastName " + "VARCHAR(300), RegistrationID INTEGER," + "CreditLimit DOUBLE, Country VARCHAR(300), PRIMARY KEY (CustomerId))"); result = check mysqlClient ⁙⁙->execute("INSERT INTO MYSQL_BBE.Customers " + "(FirstName,LastName,RegistrationID," + "CreditLimit,Country) VALUES ('Peter', 'Stuart', 1, 5000.75, 'USA')"); result = check mysqlClient ⁙⁙->execute("INSERT INTO MYSQL_BBE.Customers " + "(FirstName,LastName,RegistrationID," + "CreditLimit,Country) VALUES ('Dan', 'Brown', 2, 10000, 'UK')"); check mysqlClient.close(); } ``` -------------------------------- ### Get Substring Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/lang/2024R1/index.html Extracts a portion of a string starting from a specified index. ```ballerina public isolated function substring(string str, int startIndex) ``` -------------------------------- ### Initialize MySQL Client with Database Options Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/mysql-init-options.html Create a MySQL client using provided database options, including SSL configuration and connection timeouts. ```ballerina mysql:Client mysqlClient5 = check new (user = dbUser, password = dbPassword, options = mysqlOptions); io:println("MySQL client with database options created."); ``` -------------------------------- ### View Specific Topic Details with /help Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/development-tutorials/build-and-run/ballerina-shell.md Get detailed information about a specific topic by using '/help '. This example shows how to get help on 'strings'. ```ballerina =$ /help strings | | # Strings | | The `string` type represents immutable sequence of zero or more Unicode characters. There is no separate character type: a character is represented by a `string` of length 1. | | Two `string` values are `==` if both sequences have the same characters. You can use `<`, `<=`, `>`, and `>=` operators on `string` values and they work by comparing code points. Unpaired surrogates are not allowed. | | For examples, visit https://ballerina.io/learn/by-example/strings ``` -------------------------------- ### Initialize Secure FTP Client with SFTP Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/ftp/spec.md Demonstrates initializing a secure FTP client using the SFTP protocol, requiring credentials and private key configuration. ```ballerina ftp:ClientConfiguration ftpConfig = { protocol: ftp:SFTP, host: "", port: , auth: { credentials: { username: "", password: "" } }, userDirIsRoot: true }; ``` -------------------------------- ### Client Request Example using curl Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-timeout.html Example of how to send a GET request to the timeout service using `curl`. This request is expected to trigger the timeout configuration. ```bash curl -v http://localhost:9090/timeout ``` -------------------------------- ### Create sample-users.toml File Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/secured-service-with-basic-auth.html This command creates the `sample-users.toml` file with predefined user credentials and scopes. Ensure this file is present and correctly formatted for the authentication to work. ```bash echo '["b7a.users"] ["b7a.users.alice"] password="password1" scopes="scope1" ["b7a.users.bob"] password="password2" scopes="scope2,scope3"' > sample-users.toml ``` -------------------------------- ### Start Apollo Server with Standalone Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/components/integration/ballerina-vs-apollo-for-graphql/code/apollo-graphql-bbe/clean-and-simple-code-apollo.md Use this snippet to initialize and start an Apollo Server for standalone applications. Ensure you have the necessary Apollo Server packages installed. ```javascript import { ApolloServer } from '@apollo/server'; import { startStandaloneServer } from '@apollo/server/standalone'; const typeDefs = `#graphql type Book { title: String author: String } type Query { books: [Book] } `; const books = [ { title: 'Harry Potter', author: 'J. K. Rowling', }, { title: 'The Lord of the Rings', author: 'J. R. R. Tolkien', }, ]; const resolvers = { Query: { books: () => books, }, }; const server = new ApolloServer({ typeDefs, resolvers, }); await startStandaloneServer(server, { listen: { port: 4000 }, }); ``` -------------------------------- ### Example: Mock Service Generation Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/0.990/learn/api-docs/ballerina/swagger.html This is an example command for generating a mock service from a Swagger file named `hello_service.yaml` and specifying the package name as `hello_service`. ```bash ballerina swagger mock hello_service.yaml -p hello_service ``` -------------------------------- ### Running the Directory Listener Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/directory-listener.html To run this example, create a file named `test1.txt` in the observed directory, then modify and delete it. Execute the Ballerina program using the `ballerina run` command. ```bash ballerina run directory_listener.bal ``` -------------------------------- ### Get Gauge Value Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/0.990/learn/api-docs/ballerina/observe.html Provides an example of retrieving the current value of a Gauge. ```ballerina map gaugeTags = { "method": "GET" }; obseve:Gauge gaugeWithTags = new ("GaugeWithTags", desc = "Some description", tags = gaugeTags); float currentValue = gaugeWithTags.getValue(); ``` -------------------------------- ### Ballerina GraphQL Resource Accessor 'get' Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/graphql/spec.md Example of a valid resource method using the 'get' accessor, which is allowed in Ballerina GraphQL services for defining query fields. ```ballerina resource function get greeting() returns string { // ... } ``` -------------------------------- ### MySQL Client Initialization Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/0.990/learn/api-docs/ballerina/mysql.html Demonstrates how to create a MySQL client endpoint with connection configurations. ```APIDOC ## MySQL Client Initialization ### Description This section shows how to initialize a `mysql:Client` object to establish a connection pool to a MySQL database. ### Method `new` ### Endpoint `mysql:Client` ### Parameters #### Request Body - **host** (string) - Required - The hostname of the MySQL server. - **port** (integer) - Required - The port number of the MySQL server. - **name** (string) - Required - The name of the database. - **username** (string) - Required - The username for database authentication. - **password** (string) - Required - The password for database authentication. - **poolOptions** (object) - Optional - Options for the connection pool. - **maximumPoolSize** (integer) - Optional - The maximum number of connections in the pool. - **dbOptions** (object) - Optional - Additional database-specific options. - **useSSL** (boolean) - Optional - Whether to use SSL for the connection. ### Request Example ```ballerina mysql:Client testDB = new({ host: "localhost", port: 3306, name: "testdb", username: "root", password: "root", poolOptions: { maximumPoolSize: 5 }, dbOptions: { "useSSL": false } }); ``` ### Response #### Success Response (200) - **mysql:Client** - A successfully initialized MySQL client object. #### Response Example ```json { "message": "Client initialized successfully" } ``` ``` -------------------------------- ### Running the HTTP 1.1 to 2.0 Protocol Switch Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-1-1-to-2-0-protocol-switch.html Command to run the Ballerina services for the HTTP 1.1 to 2.0 protocol switch example. ```bash ballerina run http_1.1_to_2.0_protocol_switch.bal ``` -------------------------------- ### Get Beginning Offsets Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.0/learn/api-docs/ballerina/kafka/clients/Consumer.html Retrieves the starting offsets for a specified set of topic partitions. ```APIDOC ## POST /getBeginningOffsets ### Description Returns start offsets for given set of partitions. ### Method POST ### Endpoint /getBeginningOffsets ### Parameters #### Path Parameters - **partitions** ([TopicPartition](../../kafka/records/TopicPartition.html)[]) - Required - Array of topic partitions to get the starting offsets. - **duration** (int) - Optional - Timeout duration for the get beginning offsets execution. ### Return Type ([PartitionOffset](../../kafka/records/PartitionOffset.html)[] | [ConsumerError](../../kafka/errors.html#ConsumerError)) ### Response Example ```json { "offsets": [ { "topic": "my-topic", "partition": 0, "offset": 0 } ], "error": null } ``` ``` -------------------------------- ### Install WSDL Tool Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/integration-tools/wsdl-tool.md Execute this command to download the WSDL tool from Ballerina Central. ```bash bal tool pull wsdl ``` -------------------------------- ### Kafka Consumer Get Beginning Offsets Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.0/learn/api-docs/ballerina/kafka/clients/Consumer.html Retrieves the starting offsets for a given set of partitions. ```APIDOC ## POST /getBeginningOffsets ### Description Returns start offsets for given set of partitions. ### Method POST ### Endpoint /getBeginningOffsets ### Parameters #### Request Body - **partitions** (TopicPartition[]) - Required - The topic partitions for which to get the beginning offsets. ### Response #### Success Response (200) - **offsets** (map) - A map of topic partitions to their beginning offsets. ``` -------------------------------- ### Initialize Window Parameters Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.0/learn/api-docs/ballerina/streams/objects/UniqueLengthWindow.html Initializes the window with provided parameters. This is a setup function for window operations. ```ballerina function initParameters(any parameters) ``` -------------------------------- ### Get Ballerina System Property Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/api-docs/ballerina/runtime/functions.html Retrieves the system property value associated with the specified property name. Returns an empty string if the property does not exist. Example: getting the user's home directory. ```ballerina string userHome = runtime:getProperty("user.home"); ``` -------------------------------- ### Create and Populate MySQL Database Tables Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/resources/featured-scenarios/build-a-change-data-capture-service-in-ballerina.md Set up the 'finance_db' database and the 'transactions' table, then insert sample data. This includes creating a table to store transaction details and populating it with initial records. ```sql CREATE DATABASE IF NOT EXISTS finance_db; USE finance_db; CREATE TABLE transactions ( tx_id INT AUTO_INCREMENT PRIMARY KEY, user_id INT, amount DECIMAL(10,2), status VARCHAR(50), created_at DATETIME ); INSERT INTO transactions (user_id, amount, status, created_at) VALUES (10, 9000.00, 'COMPLETED', '2025-04-01 08:00:00'), (11, 12000.00, 'COMPLETED', '2025-04-01 08:10:00'), -- this triggers fraud logic (12, 4500.00, 'PENDING', '2025-04-01 08:30:00'); ``` -------------------------------- ### Runtime Log Level Modification Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/log/spec.md This example shows how to get the current log level and dynamically change it at runtime using `getLevel()` and `setLevel()`. Note that `setLevel()` will return an error on child loggers. ```ballerina log:Logger logger = check log:fromConfig(id = "payment-service", level = log:INFO); // Get current level log:Level currentLevel = logger.getLevel(); // INFO // Change level at runtime check logger.setLevel(log:DEBUG); logger.getLevel(); // DEBUG ``` -------------------------------- ### Initialize MySQL Client with Host, User, Password, Database, and Port Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/mysql-init-options.html This snippet shows how to initialize the MySQL client by specifying the host, username, password, database name, and port. ```ballerina mysql:Client mysqlClient4 = check new ("localhost", dbUser, dbPassword, "information_schema", 3306); io:println("MySQL client with host, user, password, database and " + "port created."); ``` -------------------------------- ### Helper function to get an integer Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/let-expression.html A simple function that returns an integer, used in the let expression examples. ```ballerina public function getInt() returns int => 1; ``` -------------------------------- ### Generated Ballerina Mock Client Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/integration-tools/openapi-tool.md This Ballerina code represents a generated mock client. The `get store` resource is implemented to return the example data defined in the OpenAPI contract, specifically the 'store01' example for the '200' response. ```ballerina public isolated client class Client { ... resource isolated function get store(map headers = {}) returns Inventory|error? { return {"materials": "Wood", "status": "InProgress", "Item": "Table", "amount": 120}; } } ``` -------------------------------- ### Service Usage Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/ibm.ibmmq/spec.md Example demonstrating how to attach a service to an IBM MQ listener. ```APIDOC ## ibmmq:Service ### Description Represents an IBM MQ service that consumes messages from a queue. ### Attributes - **@ibmmq:ServiceConfig** - Configuration for the IBM MQ service, including `queueName`. ### Remote Functions #### onMessage - **caller** (ibmmq:Caller) - The caller object for message acknowledgment and transaction management. - **message** (ibmmq:Message) - The incoming IBM MQ message to be processed. ``` -------------------------------- ### Run HTTP Client Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-client-endpoint.html Command to execute the Ballerina HTTP client example. Ensure you are in the directory containing the `.bal` file. ```bash ballerina run http_client_endpoint.bal ``` -------------------------------- ### Define variable starting with a digit Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/quoted-identifiers.html This example demonstrates how to define a variable whose name starts with a digit using quoted identifiers. To run this sample, navigate to the directory containing the `.bal` file and execute the `ballerina run` command. ```bash ballerina run quoted_identifiers.bal ``` -------------------------------- ### HTTP Trace Log: Client Request Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-caching-client.html Example of an inbound HTTP GET request received by the Ballerina service from a client. ```http GET /cache HTTP/1.1 Host: localhost:9090 User-Agent: curl/7.58.0 Accept: */* ``` -------------------------------- ### FTP Client Initialization Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/spec/ftp/spec.md Demonstrates how to initialize the FTP client with different configurations, including insecure, secure (SFTP), and retry configurations. ```APIDOC ## FTP Client Initialization ### Description Initializes the FTP client with various configuration options. ### Insecure Client Initialization Initializes a client without secure protocols. ```ballerina ftp:ClientConfiguration ftpConfig = { protocol: ftp:FTP, host: "", port: 21 }; ftp:Client ftpClient = check new(ftpConfig); ``` ### Secure Client Initialization (SFTP) Initializes a client using SFTP with username and password authentication. ```ballerina ftp:ClientConfiguration ftpConfig = { protocol: ftp:SFTP, host: "", port: 22, // SFTP typically uses port 22 auth: { credentials: { username: "", password: "" } }, userDirIsRoot: true }; ftp:Client ftpClient = check new(ftpConfig); ``` ### Client with Retry Configuration Initializes a client with retry settings for read operations. ```ballerina ftp:ClientConfiguration ftpConfig = { protocol: ftp:FTP, host: "", port: 21, retryConfig: { count: 5, interval: 2.0, backOffFactor: 1.5, maxWaitInterval: 20.0 } }; ftp:Client ftpClient = check new(ftpConfig); // Non-streaming read operations will automatically retry on failure byte[] bytes = check ftpClient->getBytes("/path/to/file.txt"); ``` ### Client Configuration Options `ftp:ClientConfiguration` record defines the settings for the FTP client. ```ballerina public type ClientConfiguration record {| Protocol protocol = FTP; string host = "127.0.0.1"; int port = 21; AuthConfiguration auth?; boolean userDirIsRoot = false; boolean laxDataBinding = false; RetryConfig retryConfig?; CircuitBreakerConfig circuitBreaker?; |}; ``` ### Input Content Configuration `InputContent` record specifies configurations for input data in `put` and `append` operations. ```ballerina public type InputContent record{| string filePath; boolean isFile = false; stream fileContent?; string textContent?; boolean compressInput = false; |}; ``` ### Compression Options `Compression` enum defines available compression methods. ```ballerina public enum Compression { ZIP, NONE } ``` ### File Write Options `FileWriteOption` enum specifies how files are written. ```ballerina public enum FileWriteOption { OVERWRITE, APPEND } ``` ``` -------------------------------- ### View Ballerina Pull Command Help Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/using-the-cli-tools/index.html Get detailed information about the `ballerina pull` command, including its synopsis, description, and examples. ```bash ballerina help pull ``` -------------------------------- ### Running Ballerina XML Access Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/xml-access.html Provides the command to run the Ballerina XML access example. Navigate to the directory containing the `.bal` file and execute `ballerina run`. ```bash # To run this sample, navigate to the directory that contains the # `.bal` file, and execute the `ballerina run` command below. ballerina run xml-access.bal ``` -------------------------------- ### __start Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/api-docs/ballerina/kafka/clients/Consumer.html Starts the registered Kafka services. ```APIDOC ## POST /__start ### Description Starts the registered services. ### Method POST ### Endpoint /__start ### Response #### Success Response (200) - **result** (error?) - An kafka:ConsumerError if an error is encountered while starting the server or else nil #### Response Example ```json { "result": null } ``` ``` -------------------------------- ### Running the HTTP Timeout Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-timeout.html Command to execute the Ballerina program. This command starts the HTTP listeners for the services defined in the `http_timeout.bal` file. ```bash ballerina run http_timeout.bal ``` -------------------------------- ### Send Request to Ballerina Service with cURL Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-streaming.html Example cURL command to send a GET request to the Ballerina HTTP service running on localhost:9090. ```bash curl -X GET http://localhost:9090/stream/fileupload ``` -------------------------------- ### Run Development Server Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/README.md Execute this command to start the Next.js development server. Open http://localhost:3000 in your browser to view the website. ```bash npm run dev ``` -------------------------------- ### HTTP Trace Log: Proxy Request to Backend Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-caching-client.html Example of an outbound HTTP GET request made by the Ballerina proxy to the backend service. ```http GET /hello HTTP/1.1 Accept: */* host: localhost:8080 user-agent: ballerina/1.0.0 connection: keep-alive ``` -------------------------------- ### Running the Ballerina JSON to XML Conversion Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/json-to-xml-conversion.html Instructions on how to execute the Ballerina sample code. Navigate to the directory containing the `.bal` file and run the `ballerina run` command. ```bash # To run this sample, navigate to the directory that contains the # `.bal` file, and execute the `ballerina run` command below. ballerina run json_to_xml_conversion.bal ``` -------------------------------- ### Initialize Secure FTP Client Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/spec/ftp/spec.md Demonstrates initializing a secure FTP client using SFTP protocol with username and password authentication. ```ballerina ftp:ClientConfiguration ftpConfig = { protocol: ftp:SFTP, host: "", port: , auth: { credentials: { username: "", password: "" } }, userDirIsRoot: true }; ``` -------------------------------- ### Get Beginning Kafka Partition Offsets Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/api-docs/ballerina/kafka/clients/Consumer.html Retrieves the start offsets for a given set of topic partitions. This is useful for resetting consumer positions. ```ballerina kafka:PartitionOffset[]|kafka:ConsumerError result = consumer->getBeginningOffsets(partitions, duration); ``` -------------------------------- ### Initialize MySQL Client with User and Password Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/mysql-init-options.html Use this to create a MySQL client when only the username and password are provided. The default host will be used. ```ballerina mysql:Client mysqlClient3 = check new (user = dbUser, password = dbPassword); io:println("MySQL client with user and password created " + "with default host."); ``` -------------------------------- ### Configure HTTP Client with Authentication Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/swan-lake/other/security/http-client-authentication.md Use the `auth` field in `http:ClientConfiguration` to specify authentication details. This example shows a generic setup. ```ballerina import ballerina/http; import ballerina/log; http:Client securedEP = check new("https://localhost:9090", auth = { // ... }, secureSocket = { cert: "/path/to/public.crt" } ); ``` -------------------------------- ### Run the Hello World Service Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/hello-world-service.html Command to execute the Ballerina service and the output indicating the listener has started. ```bash ballerina run hello_world_service.bal [ballerina/http] started HTTP/WS listener 0.0.0.0:9090 ``` -------------------------------- ### Run Kafka SASL Plain Consumer Example Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/kafka-authentication-sasl-plain-consumer.html Navigate to the directory containing the Ballerina file and execute the `ballerina run` command to start the Kafka consumer. ```bash ballerina run kafka_authentication_sasl_plain_consumer.bal ``` -------------------------------- ### Install npm Packages Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/README.md Execute this command to install all necessary packages for the project. ```bash npm install ``` -------------------------------- ### Invoke Ballerina Service with cURL Source: https://github.com/ballerina-platform/ballerina-dev-website/blob/master/public/1.2/learn/by-example/http-filters.html Example of how to invoke the Ballerina HTTP service using cURL after it has been started. This demonstrates the request and response headers modified by the filters. ```bash curl -v http://localhost:9090/hello/sayHello ```