Skip to content

Commit

Permalink
Merge pull request #5610 from ballerina-platform/2201.10.0-stage
Browse files Browse the repository at this point in the history
Sync 2201.10.0-stage and 2201.10.x branch
  • Loading branch information
LakshanWeerasinghe committed Aug 23, 2024
2 parents 72e7d25 + d79e4d0 commit 94eee1b
Show file tree
Hide file tree
Showing 29 changed files with 1,084 additions and 264 deletions.
481 changes: 481 additions & 0 deletions .github/workflows/daily-build-2201.10.x.yml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
githubAccessToken: ${{ secrets.GITHUB_TOKEN }}
ballerinaBotWorkflow: $ {{ secrets.BALLERINA_BOT_WORKFLOW }}
run: |
./gradlew build -Pversion=${VERSION}
./gradlew build -x project-api-tests:test -Pversion=${VERSION}
./gradlew release -Prelease.useAutomaticVersion=true -x test
- name: Checkout docker repo
uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions ballerina-test-automation/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
swan-lake-latest-version=swan-lake-2201.10.0
swan-lake-latest-spec-version=2024R1
swan-lake-latest-version-display-text=2201.10.0
swan-lake-latest-tool-version=1.4.2
latest-tool-version=1.4.2
swan-lake-latest-tool-version=1.4.3
latest-tool-version=1.4.3
1-x-channel-latest-version=1.2.13
1-x-channel-latest-spec-version=2020R1
430 changes: 226 additions & 204 deletions ballerina/LICENSE

Large diffs are not rendered by default.

29 changes: 29 additions & 0 deletions examples/anydata-to-yaml-string/anydata_to_yaml_string.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import ballerina/data.yaml;
import ballerina/io;

type ServerConfig record {|
string host;
int port;
DatabaseConfig database;
|};

type DatabaseConfig record {|
string dbName;
string username;
|};

public function main() returns error? {

ServerConfig serverConfig = {
database: {
dbName: "userDB",
username: "testUser"
},
port: 3000,
host: "localhost"
};

// Serialize a Ballerina value to a string in YAML format.
string serverConfigYamlStr = check yaml:toYamlString(serverConfig);
io:println(serverConfigYamlStr);
}
9 changes: 9 additions & 0 deletions examples/anydata-to-yaml-string/anydata_to_yaml_string.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Serialize a Ballerina value to a string in YAML format

The `data.yaml` library provides the `toYamlString` function to serialize a value belonging to `anydata` to a string in YAML format.

For more information on the underlying module, see the [`data.yaml` module](https://lib.ballerina.io/ballerina/data.yaml/latest/).

::: code anydata_to_yaml_string.bal :::

::: out anydata_to_yaml_string.out :::
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: This BBE demonstrates how to serialize a value belonging to `anydata` to a string in YAML format.
keywords: ballerina, ballerina by example, BBE, yaml, yaml to string, record to yaml
6 changes: 6 additions & 0 deletions examples/anydata-to-yaml-string/anydata_to_yaml_string.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$ bal run anydata_to_yaml_string.bal
host: localhost
port: 3000
database:
dbName: userDB
username: testUser
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GraphQL service - Query Complexity

a `graphql:Service` can be secured by limiting the complexity of the operations that can be executed. This can be done by setting a maximum complexity threshold for a given service. The query complexity is calculated by assigning a complexity value to each field in the GraphQL schema. The complexity of an operation is the sum of the complexity values of the fields in the operation.
A `graphql:Service` can be secured by limiting the complexity of the operations that can be executed. This can be done by setting a maximum complexity threshold for a given service. The query complexity is calculated by assigning a complexity value to each field in the GraphQL schema. The complexity of an operation is the sum of the complexity values of the fields in the operation.

::: code graphql_service_query_complexity.bal :::

Expand Down
2 changes: 2 additions & 0 deletions examples/http-sse-service/http_sse_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Invoke the service by executing the following cURL command in a new terminal.

::: out http_sse_service.client.out :::

>**Tip:** You can invoke the above service via the [Client server-sent events](/learn/by-example/http-sse-client/) example.
## Related links
- [`http` module - API documentation](https://lib.ballerina.io/ballerina/http/latest/)
- [Resource return types - Specification](/spec/http/#235-return-types)
83 changes: 67 additions & 16 deletions examples/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3837,6 +3837,29 @@
}
]
},
{
"title": "LDAP client",
"column": 3,
"category": "Network libraries",
"samples": [
{
"name": "Add/Remove entries",
"url": "ldap-add-remove-entry",
"verifyBuild": true,
"verifyOutput": false,
"disablePlayground": true,
"isLearnByExample": false
},
{
"name": "Search for an entry",
"url": "ldap-search-entry",
"verifyBuild": true,
"verifyOutput": false,
"disablePlayground": true,
"isLearnByExample": false
}
]
},
{
"title": "JMS service",
"column": 3,
Expand Down Expand Up @@ -4458,6 +4481,21 @@
}
]
},
{
"title": "OS",
"column": 1,
"category": "Common libraries",
"samples": [
{
"name": "Environment variables",
"url": "environment-variables",
"verifyBuild": true,
"verifyOutput": false,
"disableVerificationReason": "Includes varying output",
"isLearnByExample": false
}
]
},
{
"title": "File",
"column": 2,
Expand Down Expand Up @@ -4551,7 +4589,7 @@
},
{
"title": "UUID",
"column": 3,
"column": 2,
"category": "Common libraries",
"samples": [
{
Expand Down Expand Up @@ -4585,21 +4623,6 @@
}
]
},
{
"title": "OS",
"column": 3,
"category": "Common libraries",
"samples": [
{
"name": "Environment variables",
"url": "environment-variables",
"verifyBuild": true,
"verifyOutput": false,
"disableVerificationReason": "Includes varying output",
"isLearnByExample": false
}
]
},
{
"title": "XML data",
"column": 3,
Expand Down Expand Up @@ -4635,6 +4658,34 @@
}
]
},
{
"title": "YAML data",
"column": 3,
"category": "Common libraries",
"samples": [
{
"name": "YAML to anydata",
"url": "yaml-to-anydata",
"verifyBuild": true,
"verifyOutput": true,
"isLearnByExample": true
},
{
"name": "YAML to anydata with projection",
"url": "yaml-to-anydata-with-projection",
"verifyBuild": true,
"verifyOutput": true,
"isLearnByExample": true
},
{
"name": "Serialize to YAML string",
"url": "anydata-to-yaml-string",
"verifyBuild": true,
"verifyOutput": true,
"isLearnByExample": true
}
]
},
{
"title": "Constraint",
"column": 3,
Expand Down
27 changes: 27 additions & 0 deletions examples/ldap-add-remove-entry/ldap_add_remove_entry.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import ballerina/io;
import ballerina/ldap;

public function main() returns error? {
// Initializes a new LDAP client with credentials.
ldap:Client ldapClient = check new (
hostName = "localhost",
port = 389,
domainName = "cn=admin,dc=example,dc=com",
password = "adminpassword"
);

// Creates an `ldap:Entry` record for the new entry.
ldap:Entry addEntry = {
"objectClass": ["top", "person"],
"sn": "user",
"cn": "user"
};

// Adds an entry to the directory server.
ldap:LdapResponse addResponse = check ldapClient->add("cn=user,dc=example,dc=com", addEntry);
io:println("Add Response: ", addResponse.resultCode);

// Deletes an entry from the directory server.
ldap:LdapResponse deleteResponse = check ldapClient->delete("cn=user,dc=example,dc=com");
io:println("Delete Response: ", deleteResponse.resultCode);
}
22 changes: 22 additions & 0 deletions examples/ldap-add-remove-entry/ldap_add_remove_entry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# LDAP client - Add/Remove entries

The `ldap:Client` connects to a directory server and performs various operations on directories. Currently, it supports the generic LDAP operations; `add`, `modify`, `modifyDN`, `compare`, `search`, `searchWithType`, `delete`, and `close`.

The `add` operation creates a new entry in a directory server. It requires a `DN` (Distinguished Name) for the entry and the attributes to be included. The `objectClass` attribute must be specified to define the object classes for the entry, and any attributes required by these object classes should also be included.

The `delete` operation removes an entry from a directory server. It requires a `DN` (Distinguished Name) of the entry to be deleted.

::: code ldap_add_remove_entry.bal :::

## Prerequisites
- Ensure that an LDAP server is up and running locally on port 389 while running the example.

- Run the example by executing the command below.

::: out ldap_add_remove_entry.server.out :::

## Related links
- [`ldap:Client` `add` operation - API documentation](https://central.ballerina.io/ballerina/ldap/latest#Client-add)
- [`ldap:Client` `delete` operation - API documentation](https://central.ballerina.io/ballerina/ldap/latest#Client-delete)
- [`ldap` module - API documentation](https://lib.ballerina.io/ballerina/ldap/latest/)
- [`ldap:Client` - Specification](/spec/ldap/#2-ldap-client)
2 changes: 2 additions & 0 deletions examples/ldap-add-remove-entry/ldap_add_remove_entry.metatags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: This example is on how to create/delete entries in a directory server using LDAP in Ballerina.
keywords: ballerina, ballerina by example, bbe, ldap, add
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$ bal run ldap_add_remove_entry.bal
Add Response: SUCCESS
Delete Response: SUCCESS
20 changes: 20 additions & 0 deletions examples/ldap-search-entry/ldap_search_entry.bal
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import ballerina/io;
import ballerina/ldap;

public function main() returns error? {
// Initializes a new LDAP client with credentials.
ldap:Client ldapClient = check new (
hostName = "localhost",
port = 389,
domainName = "cn=admin,dc=example,dc=com",
password = "adminpassword"
);

// Searches for an entry in the directory server.
ldap:SearchResult searchResult = check ldapClient->search(
"cn=user,dc=example,dc=com",
"(sn=user)",
ldap:SUB
);
io:println("Search Response: ", searchResult.resultCode);
}
25 changes: 25 additions & 0 deletions examples/ldap-search-entry/ldap_search_entry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# LDAP client - Seacrh for an entry

The `ldap:Client` connects to a directory server and performs various operations on directories. Currently, it supports the main LDAP operations; `add`, `modify`, `modifyDN`, `compare`, `search`, `searchWithType`, `delete`, and `close`.

The `search` operation is used to retrieve entries that match specified criteria. The components of an LDAP search request include:

- `baseDN`: Defines the base of the subtree for the search.
- `filter`: Specifies the criteria that entries must meet.
- `scope`: Determines extent of the the search coverage within the subtree.

When a directory server processes a valid search request, it finds entries within the defined scope that meet the filter criteria. The matching entries are then returned to the client in a `ldap:SearchResult` record.

::: code ldap_search_entry.bal :::

## Prerequisites
- Ensure that an LDAP server is up and running locally on port 389 while running the example.

- Run the example by executing the command below.

::: out ldap_search_entry.server.out :::

## Related links
- [`ldap:Client` `search` operation - API documentation](https://central.ballerina.io/ballerina/ldap/latest#Client-search)
- [`ldap` module - API documentation](https://lib.ballerina.io/ballerina/ldap/latest/)
- [`ldap:Client` - Specification](/spec/ldap/#2-ldap-client)
2 changes: 2 additions & 0 deletions examples/ldap-search-entry/ldap_search_entry.metatags
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: This example is on how to search for an entry in a directory server using LDAP in Ballerina.
keywords: ballerina, ballerina by example, bbe, ldap, search
2 changes: 2 additions & 0 deletions examples/ldap-search-entry/ldap_search_entry.server.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ bal run ldap_search_entry.bal
Search Response: SUCCESS
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ type Invoice record {
@xmldata:Namespace {
uri: "http://example1.com"
}

type Item record {
string itemCode;
int count;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import ballerina/data.yaml;
import ballerina/io;

type ServerConfig record {|
string host;
int port;
int[2] remotePorts;
DatabaseConfig database;
|};

type DatabaseConfig record {|
string dbName;
string username;
|};

public function main() returns error? {
// Similar to content read from a YAML file.
string yamlString = string `
host: "localhost"
port: 8080
remotePorts: [9000, 9001, 9002, 9003]
protocol: "http"
database:
dbName: "testdb"
username: "dbuser"
password: "dbpassword"`;

// Based on the expected type, this function selectively constructs the record from the YAML string.
ServerConfig serverConfig = check yaml:parseString(yamlString);
// The `password` field is excluded in the created record value.
// Only the first two elements from the source are used to create the `remotePorts` array.
io:println(serverConfig);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# YAML to anydata conversion with projection

The `data.yaml` library provides multiple APIs to selectively parse elements and attributes from a YAML source, in the form of a string, byte array, or byte block stream, into a Ballerina record. Using projection, users can selectively add fields to records and limit the sizes of arrays.

In this example, the `password` attribute is excluded when creating the `DatabaseConfig` record, and only the first two elements from the source are used to create the `remotePorts` array.

For more information on the underlying module, see the [`data.yaml` module](https://lib.ballerina.io/ballerina/data.yaml/latest/).

::: code yaml_to_anydata_with_projection.bal :::

::: out yaml_to_anydata_with_projection.out :::
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
description: This BBE demonstrates how to selectively convert fields from a YAML source, which can be provided as a string, byte array, or byte block stream, into a Ballerina record with projection.
keywords: ballerina, ballerina by example, BBE, yaml, record, data projection
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
$ bal run yaml_to_anydata_with_projection.bal
{"host":"localhost","port":8080,"remotePorts":[9000,9001],"database":{"dbName":"testdb","username":"dbuser"}}
Loading

0 comments on commit 94eee1b

Please sign in to comment.