BassemE/mulesoft-documentation-embeddings huggingface dataset:
Connected Application Authentication | MuleSoft Documentation
# Connected Application Authentication
Connected application authentication enables access to Exchange using the client application credentials of client ID and client secret, so you can execute Exchange requests without sending a token.
To create a new connected application:
  1. Log in to the Anypoint Platform.
  2. Navigate to **Access Management** > **Connected Apps** > **Create App**.
  3. Choose **App acts on its own behalf (client credentials)**.
  4. To provide read and write access, ensure the application has either the scope **Exchange Administrator** or the scope **Exchange Contributor**.
To provide read-only access, ensure the application has the scope **Exchange Viewer**.
  5. Click **Save** and copy the client ID and client secret of the connected application.


To use connected application authentication, provide basic authentication and define the username as `~~~Client~~~` and the password as `clientID~?~clientSecret`. Replace `clientID` with the client ID. Replace `clientSecret` with the client secret.
To Trigger a Flow When a New File is Created or Modified | MuleSoft Documentation
# To Trigger a Flow When a New File is Created or Modified
Anypoint Connectors for File, FTP, and SFTP provide an **On New or Updated File** operation that polls a directory for files that have been created or updated. A message is generated for each file that is found.
The following strategies determine that a file is new:
  * Set the **Auto delete** field to **True** to delete each file after it is processed, which causes all files obtained in the next poll to be considered new.
  * Set the **Move to directory** field to move each file to a different directory after it is processed, which achieves the same effect as **Auto delete** but without erasing the file.
  * Set the **Watermark** field to pick only files that have been created or updated after the last poll was executed.


You can also use a matcher for additional filtering of files.
Example: File Listener (On New File Trigger)
```
<flow name="onNewFile">
  <file:listener config-ref="file" directory="test-data/in" autoDelete="true">
   <scheduling-strategy>
    <fixed-frequency frequency="1000"/>
   </scheduling-strategy>
  </file:listener>
  <flow-ref name="processFile" />
</flow>
```

## Watermarking
For the File connector, the watermarking strategy can be used in two different modes: `CREATION_TIMESTAMP` or `MODIFIED_TIMESTAMP`. The strategy depends on whether you want to filter files based on their creation or modification time.
Example: Watermarking with the File Listener
```
<file:listener doc:name="On New File"
 config-ref="File_Config1"
 watermarkMode="CREATED_TIMESTAMP">
  <scheduling-strategy >
   <fixed-frequency />
  </scheduling-strategy>
</file:listener>
```

## Repeatable Streams
The **List** operation makes use of the repeatable streams functionality introduced in Mule 4. The operation returns a list of messages, where each message represents a file in the list and holds a stream to the file. A stream is repeatable by default.
For more information, refer to Streaming in Mule 4.
MQTT Connector XML and Maven Support | MuleSoft Documentation
# MQTT Connector XML and Maven Support
Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio:
If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can access the connector from your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file.
If you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location and it also adds a dependency to the `pom.xml` file.
## Add a Namespace for the Connector
Paste the following code inside the `<mule>` tag of the header of your configuration XML:
```
http://www.mulesoft.org/schema/mule/mqtt3
http://www.mulesoft.org/schema/mule/mqtt3/current/mule-mqtt3.xsd
```

This example shows how the namespace statements are placed in the `<mule>` XML block:
```
<mule xmlns:mqtt3="http://www.mulesoft.org/schema/mule/mqtt3"
	xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
	xmlns:http="http://www.mulesoft.org/schema/mule/http"
	xmlns:file="http://www.mulesoft.org/schema/mule/file"
	xmlns="http://www.mulesoft.org/schema/mule/core"
	xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core
	http://www.mulesoft.org/schema/mule/core/current/mule.xsd
	http://www.mulesoft.org/schema/mule/file
	http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
	http://www.mulesoft.org/schema/mule/http
	http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
	http://www.mulesoft.org/schema/mule/ee/core
	http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
	http://www.mulesoft.org/schema/mule/mqtt3
	http://www.mulesoft.org/schema/mule/mqtt3/current/mule-mqtt3.xsd">
```

## Add a POM File Dependency
The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector:
```
<dependency>
 <groupId>com.mulesoft.connectors</groupId>
 <artifactId>mule4-mqtt3-connector</artifactId>
 <version>x.x.x</version>
 <classifier>mule-plugin</classifier>
</dependency>
```

Replace `x.x.x` with the version that corresponds to the connector you are using.
To obtain the most up-to-date `pom.xml` file information:
  1. Go to Anypoint Exchange.
  2. In Exchange, click **Login** and supply your Anypoint Platform username and password.
  3. In Exchange, search for `mqtt3 connector`.
  4. Select the connector.
  5. Click **Dependency Snippets** near the upper right of the screen.


## Next Step
After completing your namespace and `pom.xml` file, you can try the examples.
## See Also
  * Introduction to Anypoint Connectors
  * MuleSoft Help Center
Read Clipboard | MuleSoft Documentation
# Read Clipboard
This action step simply copies the current clipboard content into a variable (see Section Using Variables) for further usage within the _Workflow_.
## Properties
**Clear Clipboard after reading** If activated, the clipboard will be cleared after it was read and saved into a variable
**Copy to clipboard before reading** (Default: Disabled) If this property is enabled, the text currently selected will be copied to the clipboard before reading the contents of the buffer. The _CTRL+C_ command is used to copy the text.
Please note that some text must be selected when this is executed.
The content of the buffer is deleted before copying the selected text. If no text is selected, then the buffer will be empty, i.e. it will not contain any data that might otherwise have been stored there from a previous action.
The _CTRL+C_ command takes a variable amount of time to perform the copy, depending on system load, so this action step includes a _Timeout_. The buffer is checked every 250 ms to see if it contains any data.
If it does, then the contents of the buffer are returned.
If the buffer is empty, then the system will check for content after a further 250 ms. This process is repeated until the _Timeout_ has expired.
Therefore, do not enter a value of 0 for the _Timeout_. This would result in the buffer being empty.
## Inbound Variables
**Clear Clipboard after reading** Contains the information if the clipboard should be cleared after reading or not.
## Outbound Variables
**ClipboardContent** The content of the clipboard.
Note that this action step will throw an error if the clipboard contains anything other than text (such as images, files, etc.).
Use Case 4: Non-Organization-Owned API Exposed to a Non-Organization-Owned API Consumer | MuleSoft Documentation
# Use Case 4: Non-Organization-Owned API Exposed to a Non-Organization-Owned API Consumer
Use case four has one pattern that supports the scenario in which a non-organization API is exposed to a non-organization API consumer.
## Pattern 9: Non-Organization External API exposed to a Non-Organization External Consumer
In pattern nine, Flex Gateway acts as an intermediary between two external entities; for example, when an external customer consumes a travel information service offered by an external airline.
The following diagram shows the physical implementation of a scenario in which a non-organization external API is exposed to a non-organization external consumer on Kubernetes. The diagram assumes that the firewall terminates the incoming external mTLS connection.
## See Also
  * Use Case 1: Organization-Owned API Exposed to an Organization-Owned API Consumer
  * Use Case 2: Organization-Owned API Exposed to a Non-Organization-Owned API Consumer
  * Use Case 3: Non-Organization-Owned API Exposed to an Organization-Owned API Consumer
HMACWith | MuleSoft Documentation
# HMACWith
## HMACWith(secret: Binary, content: Binary, @Since(version = "2.2.0") algorithm: String = "HmacSHA1"): String
Computes an HMAC hash (with a secret cryptographic key) on input content, then transforms the result into a lowercase, hexadecimal string.
See also, `HMACBinary`.
### Parameters
Name | Description  
---|---  
The secret cryptographic key (a binary value) used when encrypting the `content`.  
The binary input value.  
`algorithm` | (_Introduced in DataWeave 2.2.0. Supported by Mule 4.2 and later._) The hashing algorithm. By default, `HmacSHA1` is used. Other valid values are `HmacSHA256` and `HmacSHA512`.  
### Example
This example uses HMAC with a secret value to encrypt the input content using the `HmacSHA256` algorithm.
#### Source
```
%dw 2.0
import dw::Crypto
output application/json
---
{ "HMACWith" : Crypto::HMACWith("secret_key" as Binary, "Some value to hash" as Binary, "HmacSHA256") }
```

#### Output
```
{ "HMACWith": "b51b4fe8c4e37304605753272b5b4321f9644a9b09cb1179d7016c25041d1747" }
```
fromBinary | MuleSoft Documentation
# fromBinary
## fromBinary(binaryText: String): Number
Transforms from a binary number into a decimal number.
_Introduced in DataWeave version 2.2.0._
### Parameters
Name | Description  
---|---  
`binaryText` | The binary number represented in a `String`.  
### Example
This example shows how the `toBinary` behaves with different inputs.
#### Source
```
%dw 2.0
import fromBinary from dw::core::Numbers
output application/json
---
{
  a: fromBinary("-10"),
  b: fromBinary("11111000111010111010110100101011100001001110000011010101100010111101001011100000100010011000011101100101101001111101111010110010010100110010100100000000000000000000000000000000000000000000000000000000000000"),
  c: fromBinary(0),
  d: fromBinary(null),
  e: fromBinary("100"),
}
```

#### Output
```
{
 "a": -2,
 "b": 100000000000000000000000000000000000000000000000000000000000000,
 "c": 0,
 "d": null,
 "e": 4
}
```

## fromBinary(binaryText: Null): Null
Helper function that enables `fromBinary` to work with null value.
_Introduced in DataWeave version 2.2.0._
Outbound Policies Directory | MuleSoft Documentation
# Outbound Policies Directory
## Outbound Policies Included in Flex Gateway
Policy | Category | Summary  
---|---|---  
Transformation | Triggers an AWS Lambda function from a standard HTTP request  
| Quality of Service | Prevents an upstream from receiving too many requests or connections  
Credential Injection Basic Authentication | Security | Allows access based on the basic authorization mechanism, with a single user-password  
Credential Injection OAuth 2.0 | Security | Adds headers to a request or a response  
| Quality of Service | Sets the maximum idle duration for a stream between Flex Gateway and an upstream service  
## See Also
  * Policy Availability by Gateway
splitAt | MuleSoft Documentation
# splitAt
## splitAt<T>(array: Array<T>, n: Number): Pair<Array<T>, Array<T>>
Splits an array into two at a given position.
_Introduced in DataWeave version 2.2.0._
### Parameters
Name | Description  
---|---  
The array of elements.  
The index at which to split the array.  
### Example
#### Source
```
%dw 2.0
import * from dw::core::Arrays
output application/json
var users = ["Mariano", "Leandro", "Julian"]
---
users splitAt 1
```

#### Output
```
{
 "l": [
  "Mariano"
 ],
 "r": [
  "Leandro",
  "Julian"
 ]
}
```

## splitAt(array: Null, n: Any): Null
Helper function that enables `splitAt` to work with a `null` value.
_Introduced in DataWeave version 2.4.0._
countMatches | MuleSoft Documentation
# countMatches
## countMatches(text: String, pattern: String): Number
Counts the number of matches in a string.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
The string to search for matches.  
A substring to find in the text.  
### Example
This example counts matches in a string.
#### Source
```
%dw 2.0
import countMatches from dw::core::Strings
output application/json
---
"hello worlo!" countMatches "lo"
```

## countMatches(text: String, pattern: Regex): Number
Counts the number of times a regular expression matches text in a string.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
The string to search for matches.  
The regex pattern to use in the search.  
### Example
This example counts the vowels in a string.
#### Source
```
%dw 2.0
import countMatches from dw::core::Strings
output application/json
---
"hello, ciao!" countMatches /[aeiou]/
```

## countMatches(text: Null, pattern: Any): Null
Helper function that enables `countMatches` to work with a `null` value.
_Introduced in DataWeave version 2.4.0._
Overview | MuleSoft Documentation
# Overview
MUnit is a Mule application testing framework that allows you to easily build automated tests for your integrations and APIs. It provides a full suite of integration and unit test capabilities, and is fully integrated with Maven and Surefire for integration with your continuous deployment environment.
MUnit version 2.3, works with all Mule versions since 4.0
With MUnit you can:
  * Create your test by writing Mule code
  * Mock processors
  * Spy any processor
  * Verify processor calls
  * Enable or ignore particular tests
  * Tag tests
  * Check visual coverage in Studio
  * Generate coverage reports


MUnit is fully integrated with Anypoint Studio, allowing you to create, design and run MUnit tests just like you would Mule applications.
MUnit is divided in two main sub modules:
  * MUnit
  * MUnit Tools


Each module has its own dependency:
MUnit Dependencies
```
<dependency>
	<groupId>com.mulesoft.munit</groupId>
	<artifactId>munit-runner</artifactId>
	<version>2.3.0</version>
	<classifier>mule-plugin</classifier>
	<scope>test</scope>
</dependency>
```

MUnit Tools dependencies
```
<dependency>
	<groupId>com.mulesoft.munit</groupId>
	<artifactId>munit-tools</artifactId>
	<version>2.3.0</version>
	<classifier>mule-plugin</classifier>
	<scope>test</scope>
</dependency>
```

## See Also
  * MUnit Event Processors
Publishing Local Mode APIs | MuleSoft Documentation
# Publishing Local Mode APIs
For Flex Gateway running in Local Mode, you publish APIs using local declarative configuration files. You specify the location of these configuration files when you first run Flex Gateway.
For more information about how to run the gateway, see Registering and Running Flex Gateway in Local Mode.
Refer to the following tutorials for examples on publishing APIs in Local Mode:
  * Publishing a Simple API in Local Mode
  * Publishing an API with Multiple Upstream Services in Local Mode
Delete Server Groups | MuleSoft Documentation
# Delete Server Groups
When you delete a server group, the following actions occur:
  * Alert definitions and history for the server group are deleted.
  * Applications deployed to each server in the server group are cloned on each server.


The servers assigned to the deleted server group are not deleted, restarted, or shut down. Servers that belong to the deleted group appear on the **Servers** page. You can deploy applications to them individually or add them to other server groups or clusters.
## Delete a Server Group
  1. From Anypoint Platform, select **Runtime Manager**.
  2. Select **Servers** in the left menu.
  3. Click **Group** in the **Type** column to display the details pane.
  4. Click the group status and select **Delete** from the menu:
Figure 1. The arrow shows the **Delete** option in the details pane.
  5. In the **Delete** confirmation window, select the checkbox to verify that you want to delete the server group, and then click the **Delete Server Group** button.


## See Also
  *   * Remove Servers from a Server Group
Null Safe | MuleSoft Documentation
# Null Safe
In some cases, you might want to instantiate a `@Parameter` even though the end user has not provided a value, for example:
```
@Parameter
@Optional
private List<Integer> numbers;
```

While interacting with `numbers` in your code, you will need to check if `numbers == null` at some point to avoid a `NullPointerException`.
The SDK supports the use of annotations like `@NullSafe`, which can provide an empty list instead of `null`. When you use it, the SDK can automatically create a value for you if the value was not configured.
There are many "flavors" of `@NullSafe` annotations. When used with `List` and `Map` interfaces, `@NullSafe` will provide a default implementation for those collections.
This example shows a POJO as a null safe type:
```
@Parameter
@Optional
@NullSafe
private Foo foo;
```

As you might expect, the SDK will instantiate `Foo` and assign it to your `foo` parameter so that you do not have to manually check for null.
Note that if you use `@NullSafe` with a POJO, all the parameters declared inside the POJO must all be _optional_. If a parameter is required, there is no default value for the SDK to use. So, using `@NullSafe` to automatically instantiate required parameters makes no sense.
`@NullSafe` can be configured to instantiate a certain class instead of using the parameter’s type. This can be helpful in the cases where the parameter’s type cannot be instantiated (like an abstract class or an interface).
You specify the class to be instantiated by setting the `defaultImplementingType` attribute in the annotation, for example:
```
@Parameter
@Optional
@NullSafe(defaultImplementingType = Foo.class)
private AbstractFoo foo;
```
Editing an API Instance | MuleSoft Documentation
# Editing an API Instance
After you create an API instance in API Manager, you can edit the instance’s configuration settings.
For more information about the API endpoint configuration settings, see:
  * Adding a Flex Gateway API Instance
  * Adding a Mule Gateway API Instance


To edit an API instance’s endpoint:
  1. Navigate to **Anypoint Platform** > **API Manager**.
  2. In **API Administration** , click the name of the API instance whose endpoint you want to edit.
  3. Click **Settings**.
  4. Edit the desired configuration settings fields.
  5. Click **Save**.
Moderate Forums | MuleSoft Documentation
# Moderate Forums
Consumer developers can use the Anypoint API Community Manager forums to ask questions and collaborate with other members of the community.
When a developer posts a question or answer that’s not visible automatically, a community operator must approve it.
To approve or delete pending forum posts, open the API Community Manager control panel and select **Manage Forums**.
Select **Pending Discussions**.
The list of posts shows their authors and the options to **View Author Details** , **View Discussion** , **Approve** , and **Delete**.
If the community operator chooses **Approve** , the post becomes visible to the public.
If the community operator chooses **Delete** , the post is removed and not visible to anyone.
A community operator can also reply to new discussions and questions, review audit trails, and create and manage forum rules. These rules can filter posts, other content, and members based on criteria defined by the operator. Members matching the criteria can be frozen, and posts and other content matching the criteria can be flagged, blocked, automatically edited to remove banned terms, or held for the operator to review them.
For more information about the Salesforce Experience Cloud forums and their moderation options, see the Salesforce documentation.
## Nicknames
To set the API forums to display each user’s name and not their nickname, open the API Community Manager control panel, open **Shortcuts to applications** > **Site Administration** > **Preferences** , and disable **Show nicknames**.
## See Also
  * Salesforce documentation: Experience Cloud Site Moderation Strategies and Tools
Deploying Apps to CloudHub 2.0 | MuleSoft Documentation
# Deploying Apps to CloudHub 2.0
You can deploy Mule apps to either a shared or private space in CloudHub 2.0.
  * Deploying Apps to Shared Spaces
  * Deploying Apps to Private Spaces
  * Downloading Test Apps from Exchange


CloudHub 2.0 supports Mule runtime engine versions 4.3.x and later. Mule 3.x is not supported.   
---  
## Application Deployment
After triggering a deployment, the application status eventually changes to `RUNNING`. If the application status never changes to `RUNNING`, the replicas contain a `state` and `reason` to indicate why the application status is not `RUNNING`.
When an application is deployed, the following events occur:
  1. The expected state of your application is stored, including application bundle and number of replicas.
  2. The application replica status is `PENDING`.
  3. When adequate compute and memory resources are available, each replica is attached to a node.
  4. The replica status is `STARTING`.
  5. The replica finishes loading the application.
  6. The replica status is `STARTED` and the replica can now perform work.


## Application Deployment Failure
If an application fails, for example, due to running of out memory, the following events occur:
  1. The replica status is `TERMINATED`.
  2. CloudHub 2.0 immediately attempts to restart the replica.
  3. The replica status is `RECOVERING`.


If the replica is able to restart:
  1. The replica finishes loading the application.
  2. The replica status is `STARTED` and the replica can now perform work.


If the replica can’t restart, for example, it relies on a network resource which temporarily unavailable, the following events occur:
  1. The replica status is `PENDING`, with a message indicating "CrashLoopBackoff".
CloudHub 2.0 attempts to restart the replica, using exponential backoff to avoid an excessive number of restart attempts.
  2. The replica status alternates between `RECOVERING` and `PENDING` until the issue preventing a successful restart is resolved.
  3. The replica loads the application.


After a successful restart, the replica status is `STARTED` and the replica can now perform work.
## Grace Period
When you stop, restart, update, redeploy, or terminate an application, CloudHub 2.0 tries to delete it from Mule. To make sure inflight messages are delivered, there’s a five-minute timeout period. After that period, CloudHub 2.0 shuts down the whole instance. This grace period applies to the application instance, not to the runtime. The runtime uses its own configuration for shutdown. By default, the runtime grace period is five seconds.
## See Also
  *   *
months | MuleSoft Documentation
# months
## months(nMonths: Number): Period
Creates a Period value from the provided number of months.
The function applies the `period` function to the input value.
_Introduced in DataWeave version 2.4.0._
### Parameters
Name | Description  
---|---  
The number of months as a whole number. A positive or negative number is valid.  
### Example
This example shows how `months` behaves with different inputs. It adds a month to a DateTime value, and it converts the whole number `4` to a number of months in the Period format (`P4M`).
#### Source
```
%dw 2.0
import * from dw::core::Periods
output application/json
---
{
 nextMonth: |2020-10-05T20:22:34.385Z| + months(1),
 fourMonthPeriod : months(4),
 addNegativeValue: months(-1) + months(2)
}
```

#### Output
```
{
 "nextMonth": "2020-11-05T20:22:34.385Z",
 "fourMonthPeriod": "P4M",
 "addNegativeValue": 1
}
```
Spy Event Processor | MuleSoft Documentation
# Spy Event Processor
Anypoint Code Builder 
Anypoint Studio 
The **Spy Processor** enables you to spy on what happens before and after an event processor is called. This enables you to validate, for example that a selected Mule Event reaches a specific event processor containing a specific payload or variable.
Setting a spy processor tells MUnit to run a set of instructions (usually assertions or verifications) before and/or after the execution of the spied event processor.
Assume that you have this configuration:
```
<flow name="testFlow">
 <http:request path="/my/api" />
</flow>
```

You can configure the spy processor to spy on any Http Request and assert that the payload is null before reaching the component, and not null after it’s been processed:
```
<munit:test name="suiteTest" >
 <munit:behavior >
  <munit-tools:spy processor="http:request">
   <munit-tools:before-call >
    <munit-tools:assert-that expression="#[payload]" is="#[MunitTools::nullValue()]"/>
   </munit-tools:before-call>
   <munit-tools:after-call >
    <munit-tools:assert-that expression="#[payload]" is="#[MunitTools::notNullValue()]"/>
   </munit-tools:after-call>
  </munit-tools:spy>
 </munit:behavior>
</munit:test>
```

Or even to spy on any Http Request, whose path is '/my/api'.
```
<munit:test name="suiteTest" >
 <munit:enable-flow-sources >
  <munit:enable-flow-source value="testFlow" />
 </munit:enable-flow-sources>
 <munit:behavior >
  <munit-tools:spy processor="http:request">
   <munit-tools:with-attributes >
    <munit-tools:with-attribute attributeName="path" whereValue="#['/my/api']" />
   </munit-tools:with-attributes>
   <munit-tools:before-call >
    <munit-tools:assert-that expression="#[payload]" is="#[MunitTools::nullValue()]"/>
   </munit-tools:before-call>
   <munit-tools:after-call >
    <munit-tools:assert-that expression="#[payload]" is="#[MunitTools::notNullValue()]"/>
   </munit-tools:after-call>
  </munit-tools:spy>
 </munit:behavior>
</munit:test>
```

As shown above, this processor enables you to define actions for before and after calling the spied processor. However, keep in mind that the spy processor does not modify the original Mule Event. If you set variables, attributes, or modify the payload inside a Spy, these changes won’t persist outside the processor. Overall, you should use the Spy processor to verify or assert.
## See Also
  * MUnit Event Processors
isEven | MuleSoft Documentation
# isEven
## isEven(number: Number): Boolean
Returns `true` if the number or numeric result of a mathematical operation is even, `false` if not.
### Parameters
Name | Description  
---|---  
The number to evaluate.  
### Example
This example indicates whether the numbers and result of an operation are even.
#### Source
```
%dw 2.0
output application/json
---
{ "isEven" : [ isEven(0), isEven(1), isEven(1+1) ] }
```

#### Output
```
{ "isEven" : [ true, false, true ] }
```
Diff Types (dw::util::Diff) | MuleSoft Documentation
# Diff Types (dw::util::Diff)
Type | Definition | Description  
---|---|---  
`type Diff = { matches: Boolean, diffs: Array<Difference> }` |  Describes the entire difference between two values.
  * _Example with no differences:_ `{ "matches": true, "diffs": [ ] }`
  * _Example with differences:_ `{ "matches": true, "diffs": [ "expected": "4", "actual": "2", "path": "(root).a.@.d" ] }`

See the `diff` function for another example.  
Difference |  `type Difference = { expected: String, actual: String, path: String }` |  Describes a single difference between two values at a given structure.
Viewing API Status in Runtime Manager for Flex Gateway in Connected Mode | MuleSoft Documentation
# Viewing API Status in Runtime Manager for Flex Gateway in Connected Mode
To view basic information about APIs associated with Flex Gateway instances:
  1. From Anypoint Platform, select **Runtime Manager**.
  2. Select **Flex Gateways** in the navigation menu.
  3. Click the name of the gateway whose APIs you want to check.
  4. Click **APIs**.
For each API, Runtime Manager shows the name, version, instance ID, label, and date on which it was added.


To see more detailed information and perform actions on your APIs, click **View details** to be redirected to API Manager.
Set up Your Government Cloud Account | MuleSoft Documentation
# Set up Your Government Cloud Account
After you set up your account, Government Cloud works with your identity provider (IdP) to enable single sign-on (SSO) for users in your agency. Instead of using the Anypoint Platform sign-in page, your users sign in to the SSO system to access Anypoint Platform.
When you purchase Government Cloud, your Customer Success Manager sends you onboarding instructions and access to the MuleSoft Help Center.
To configure your IdP to work with Government Cloud:
  1. Verify that you have access to the Support Portal.
If not, contact your Customer Success Manager for credentials.
  2. In the Support Portal, click **Create New Case**.
  3. Enter your Support Center credentials and click **Log in**.
  4. Request to configure the connection to your external identity provider for your organization to enable SSO.
  5. Provide the required information about your IdP and any additional information, if applicable.
For the required information, see the documentation that applies to the SSO standard you use:
     * 

Using the information you provide, MuleSoft Support configures the connection to your IdP to enable SSO for your organization.
Government Cloud does not support the configuration of local users, for which usernames and encrypted passwords are stored outside of Government Cloud.   
---
concatWith | MuleSoft Documentation
# concatWith
## concatWith(source: Binary, with: Binary): Binary
Concatenates the content of two binaries.
_Introduced in DataWeave version 2.5.0._
### Parameters
Name | Type | Description  
---|---|---  
The source binary content.  
The binary to append.  
### Example
This example concatenates two base-16 values into one binary value.
#### Source
```
%dw 2.0
import * from dw::core::Binaries
output application/dw
---
"CAFE" as Binary {base: "16"} concatWith "ABCD" as Binary {base: "16"}
```

#### Output
```
"yv6rzQ==" as Binary {base: "64"}
```

## concatWith(source: Binary, with: Null): Binary
Helper function that enables `concatWith` to work with a `null` value.
## concatWith(source: Null, with: Binary): Binary
Helper function that enables `concatWith` to work with a `null` value.
orElse | MuleSoft Documentation
# orElse
## orElse<T, E, R>(previous: Result<T, E>, orElse: () -> R): T | R
Returns the result of the `orElse` argument if the `previous` argument to `try` fails. Otherwise, the function returns the value of the `previous` argument.
_Introduced in DataWeave version 2.2.0._
### Parameters
Name | Description  
---|---  
Result from a previous call to `try`.  
Argument to return if the `previous` argument fails.  
### Example
This example waits shows how to chain different try
#### Source
```
%dw 2.0
import * from dw::Runtime
var user = {}
var otherUser = {name: "DW"}
output application/json
---
{
  a: try(() -> user.name!) orElse "No User Name",
  b: try(() -> otherUser.name) orElse "No User Name"
}
```

#### Output
```
{
 "a": "No User Name",
 "b": "DW"
}
```
Create, Update, and Delete a Tokenization Format | MuleSoft Documentation
# Create, Update, and Delete a Tokenization Format
The tokenization format defines the way incoming data is converted. Ensure that the token matches the format of the original data when you define the tokenization format. For example, if you use a credit card format, the number of digits defined for the format should match the number of digits for the original credit card.
For more information about the supported tokenization formats see Tokenization Formats.
## Create a Tokenization Format
  1. Sign into Anypoint Platform.
  2. Under **Management Center** , click **Anypoint Security**.
  3. In the menu on the left, click **Tokenization Format**.
  4. Click **Create Format**.
  5. In the **Create Format** dialog box, enter the following information:
     * **Name** : Name for the tokenization format.
     * **Description** : Optionally, enter a short description for the tokenization format.
     * **Data Domain** : When you select the data domain, configuration options appear. The options vary depending on the type of data domain you selected. For information about the supported data domains and configuration options, see Tokenization Formats
  6. Click **Save**.


## Update a Tokenization Format
You can update a format anytime.
  1. In Anypoint Security, click **Tokenization Formats** in the menu on the left.
  2. From the list, click the tokenization format to update.
  3. Make your changes, and click **Save**.


## Delete a Tokenization Format
Before you delete a tokenization format, verify it is not in use.
  1. In Anypoint Security, click **Tokenization Formats** in the menu on the left.
  2. From the list, click the tokenization format to delete.
  3. Click **Delete** in the upper right corner.
  4. In the **Confirm Delete** confirmation dialog, click **Delete**.
Trigger a Flow When a New File Is Created or Modified Example | MuleSoft Documentation
# Trigger a Flow When a New File Is Created or Modified Example
Anypoint Connectors for File, FTP, and SFTP provide an **On New or Updated File** operation that polls a directory for files that have been created or updated. A message is generated for each file that is found.
The following strategies determine that a file is new:
  * Set the **Auto delete** field to **True** to delete each file after it is processed, which causes all files obtained in the next poll to be considered new.
  * Set the **Move to directory** field to move each file to a different directory after it is processed, which achieves the same effect as **Auto delete** but without erasing the file.
  * Set the **Watermark** field to pick only files that have been created or updated after the last poll was executed.


You can also use a matcher for additional filtering of files.
To add and configure the **On New or Updated File** operation in Studio, follow these steps:
  1. In the **Mule Palette** view, search for `ftp` and select the **On New or Updated File** operation.
  2. Drag the **On New or Updated File** operation onto the Studio canvas.
  3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields.
  4. Specify the connection information and click **OK**.
  5. Set **Directory** to the directory path on which pooled files are contained, for example, `test-data/in`.
  6. Set **Auto delete** to **True**.
  7. Select the **Watermark** field to enable watermarking.


In the **Configuration XML** editor, the `<ftp:listener>` configuration looks like this:
```
<flow name="onNewFile">
  <ftp:listener config-ref="file" directory="test-data/in" autoDelete="true">
   <scheduling-strategy>
    <fixed-frequency frequency="1000"/>
   </scheduling-strategy>
  </ftp:listener>
  <flow-ref name="processFile" />
</flow>
```

## See Also
  * FTP Connector Examples
  * MuleSoft Help Center
Google Calendar Connector Reference | MuleSoft Documentation
# Google Calendar Connector Reference
Google Calendar is a calendar and task planning application by Google that focuses on enhancing personal and team productivity. Using Google Calendar, individuals can easily schedule tasks and meetings. They can also share events with colleagues through an easy-to-use calendar interface.
## Connections
To connect to a system, whether it is a source of data or the target where you are sending data, you must create a connection with that system’s required credentials. You typically connect to different systems within a flow and can reuse each connection every time you need to connect.
This system requires the following credential information for its connections: 

Connection Name
    
Enter a connection name that will help you remember the details of this connection. You can reuse connections multiple times in a single flow, and in more than one flow, and the credentials are hidden after you create the connection. Therefore, it’s helpful to provide a name that easily identifies this connection from others.
Only you can see the connection. Other users in your Composer app must create their own connections. 

Username
    
The OAuth username that you use to log in to Google. 

Password
    
The OAuth password that you use to log in to Google.
## Actions
After you connect to a system and define the trigger or configure a scheduler, you define the actions that the flow performs. For example, you can copy a record between different systems, such as Workday and Salesforce. The actions you can perform depend on which system you are connected to.
This system provides the following actions: 

Create a new event
    
Creates an event. The following fields are required:
  * Calendar ID
  * Start Time
  * End Time



Update an event
    
Updates an event. The following fields are required:
  * Calendar ID
  * Event ID
  * Start Time
  * End Time


If entering a custom dateTime data pill, ensure the time entered uses the UTC +0 ("Zulu") timezone. For example, January 1, 2022, at 9:00 AM Pacific Time (UTC-7) is entered as **2022-01-01, 04:00pm**
Google Calendar Connector’s use and transfer to any other application of information received from Google APIs is subject to the Google API Services User Data Policy, including the Limited Use requirements.
**Google Calendar™ is a trademark of Google LLC.**
## See Also
  * Mulesoft Composer: Overview
  * MuleSoft Composer: Getting Started
  * Composer Connector Reference
  * Knowledge Articles
Configuring Authorized Namespaces in Runtime Fabric | MuleSoft Documentation
# Configuring Authorized Namespaces in Runtime Fabric
Authorized namespaces enable you to deploy Runtime Fabric alongside other services in a Kubernetes cluster. By limiting permissions in your cluster, you can allow Runtime Fabric to access resources only within namespaces assigned to Runtime Fabric.
With authorized namespaces, you have control of the creation of the following Runtime Fabric resources:
  * Namespaces
  * RoleBindings
  * ServiceAccounts


## How Authorized Namespaces Work
At install time, you provide a configuration file that consists of your namespaces, ServiceAccounts, ClusterRoles/Roles, and RoleBindings.
Runtime Fabric installs the Runtime Fabric agent (rtf-agent) in the Runtime Fabric namespace, and it has access to any additional namespaces that you provide in the authorized namespace list.
### Example
The following is an example of a Runtime Fabric agent ClusterRole that allows the agent to control all cron jobs across all namespaces in a cluster.
```
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
 name: rtf:agent
rules:
- apiGroups:
 - batch
 resources:
 - cronjobs
 verbs:
 - create
 - delete
 - deletecollection
 - get
 - list
 - patch
 - update
 - watch
```

Runtime Fabric creates the required RoleBinding objects which use the ClusterRole rtf:agent to allow corresponding ServiceAccount to perform various actions (verbs) on cron jobs in two namespaces.
```
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
 name: rtf:agent-1
 namespace: namespace1
roleRef:
 apiGroup: rbac.authorization.k8s.io
 kind: ClusterRole
 name: rtf:agent
subjects:
- kind: ServiceAccount
 name: rtf-agent-sa
 namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
 name: rtf:agent-2
 namespace: namespace2
roleRef:
 apiGroup: rbac.authorization.k8s.io
 kind: ClusterRole
 name: rtf:agent
subjects:
- kind: ServiceAccount
 name: rtf-agent-sa
 namespace: default
```

To use clustered apps in authorized namespaces mode, the following RoleBinding must be created:
```
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
 name: rtf-mule-clusterip-service
 namespace: <app_namespace>
subjects:
- kind: ServiceAccount
 name: mule-clusterip-service
 namespace: <rtf_namespace>
roleRef:
 kind: ClusterRole
 name: rtf:mule-clusterip-service
 apiGroup: rbac.authorization.k8s.io
```

## Configure Authorized Namespaces
You configure authorized namespaces when you install Runtime Fabric. Refer to the appropriate installation instructions:
  * Installing Runtime Fabric on EKS, AKS, and GKE Using Helm
  * Install Runtime Fabric on Red Hat OpenShift


## Add New Namespaces
If you update the authorized-namespaces ConfigMap with a new namespace, you must restart the Runtime Fabric agent deployment using the following command:
`kubectl rollout restart deployment/agent`
Remove Specified XML Attributes | MuleSoft Documentation
# Remove Specified XML Attributes
You might want to remove specific attributes from within an XML tag that are known to contain sensitive data. The DataWeave example defines a function in the DataWeave header that removes a specific XML attribute from the passed element and its children.
This example uses:
  * `mapObject` to go through each element.
  * `@` to refer to the attributes in an XML element.
  * `if` and `else` to conditionally only list XML attributes when they are present, and also to only recursively call the function when a child element is an object.
  * `is` to check if each child is of type `Object` .
  * `-` to remove an element from the list of XML attributes.
  * `inlineCloseOn="empty"` on the output directive, so that the output XML displays self-closing tags when there are no values.


If the parent `users` object or child `user` objects within the input contain an attribute with the key `password`, `removeAttributes` removes that attribute from the object.
DataWeave Script:
```
%dw 2.0
output application/xml inlineCloseOn="empty"
var removeAttribute = (element,attrName) ->
 element mapObject (value, key) -> {
  // Pass the name of the key of the input object,
  // for example, whether the key is "users" or "user",
  // and use @() to remap the XML attributes.
  (key) @(
    (
     // If the element contains attributes (key.@?),
     // remove any attribute that has the provided key,
     // "password".
     if (key.@?)
      (key.@ - attrName)
     // Otherwise, do nothing.
     else {}
    )
  ) :
  // If the value of the input object contains one or
  // more objects, apply removeAttribute to remove any
  // attribute with the key "password" from those objects.
  if (value is Object)
   removeAttribute(value, attrName)
  // Otherwise, return the value of the input object.
  else value
 }
---
removeAttribute(payload, "password")
```

Input XML Payload:
```
<users>
 <user username="Julian" password="1234"/>
 <user username="Mariano" password="4321"/>
</users>
```

Output XML:
```
<?xml version='1.0' encoding='US-ASCII'?>
<users>
 <user username="Julian"/>
 <user username="Mariano"/>
</users>
```

## Related Examples
  * Output Self-closing XML tags
  * Insert an Attribute into an XML Tag
  * Include XML Namespaces
  * Exclude Fields from the Output
  * Output a Field When Present
  * Conditionally Reduce a List through a Function


## See Also
  * DataWeave Selectors
  *
Incorrect or Missing Data for One API Version | MuleSoft Documentation
# Incorrect or Missing Data for One API Version
If a single API version has documentation or console components with incorrect or missing data:
  1. Open the API Community Manager control panel.
  2. Edit the API version.
  3. Click **View asset in Exchange**.
  4. Ensure that the API version in API Community Manager points to the correct API version in Exchange.
  5. Ensure that the API version in Exchange is published and not in draft mode.
B2C Shop Connector 1.0 | MuleSoft Documentation
# B2C Shop Connector 1.0
Anypoint Connector for Salesforce Commerce Cloud B2C Shop APIs (B2C Shop Connector) enables a client to interact with the Commerce Cloud B2C API system as either a shop customer or as an agent shopping on behalf of a customer.
For information about compatibility and fixed issues, see Commerce Cloud B2C Shop Connector Release Notes.
Salesforce Commerce Cloud B2C Data Connector and Salesforce Commerce Cloud B2C Shop Connector cannot be run in the same application.   
---  
## Before You Begin
To use this connector, you must be familiar with:
  * The Salesforce Commerce Cloud Shop API
  * Anypoint Connectors
  * Mule runtime engine (Mule)
  * Elements and global elements in a Mule flow
  * How to create a Mule app using Anypoint Studio


Before creating an app, you must have access to:
  * The Commerce Cloud B2C Shop Connector target resource
  * Anypoint Platform
  * Anypoint Studio version 7.1 or later
  * Salesforce-provided Commerce Cloud credentials (such as Client Id, Client Secret, and Scopes) necessary to access Shop API.


## Common Uses for the Connector
These are some common use cases for B2C Shop Connector:
  * Create a basket
  * Add items to a basket
  * Add shipping details
  * Place an order


Check the Examples for a simple use case.
## Audience
  * New user
To create your Mule app, see:
  * Using Anypoint Studio to Configure Commerce Cloud B2C Connector
  * Advanced user
  * Read the following:
  * XML and Maven Support


## Connection Types
B2C Shop Connector connections use the following authentication types:
  * Customers Auth Uses a Bearer Token, which is generated using the **Authorize Customer** operation
  * OAuth 2.0 Delegates user authentication to the service hosting the user account


For information about configuring authentication types, see Using Anypoint Studio to Configure Commerce Cloud B2C Shop Connector.
## Next Step
After you complete the prerequisites and try the templates and examples, you are ready to create an app and configure the connector using Anypoint Studio.
## See Also
  * Introduction to Anypoint Connectors
  * Use Exchange to Discover Connectors, Templates, and Examples
  * MuleSoft Help Center
envVars | MuleSoft Documentation
# envVars
## envVars(): Dictionary<String>
Returns all the environment variables defined in the host system as an array of strings.
### Example
This example returns a Mac command console (`SHELL`) path. `SHELL` is one of the standard Mac environment variables. To return all the environment variables, you can use `dw::System::envVars()`.
#### Source
```
%dw 2.0
import dw::System
output application/json
---
{ "envVars" : dw::System::envVars().SHELL }
```

#### Output
```
{ "envVars": "/bin/bash" }
```
Compression Module | MuleSoft Documentation
# Compression Module
Compression module v2.2
Compression module supports and provides access to the most-used file archiver and compression formats through a Mule app.
A file archiver is a computer program that combines a number of files together into one archive file for easier transportation or storage, and most archivers employ data compression in their archive formats to reduce the size of the final archive. However, not all compression algorithms can archive multiple files. Some are limited to single-file data compression.
This module compresses and decompresses files for each of the available formats without losing any of the features that the format associated algorithm provides.
To achieve this capability, the module provides the **Compress** and **Decompress** operations, which enable you to compress and decompress a single file. Additionally, the module provides the **Archive** and **Extract** operations to archive and extract files. You can configure these operations with the compression or archiving strategies of your choice.
## Before You Begin
To use this connector, you must be familiar with:
  * Anypoint Connectors
  * Mule runtime engine (Mule)
  * Elements and global elements in a Mule flow
  * How to create a Mule app using Anypoint Studio


Before creating an app, you must have access to Anypoint Platform and Anypoint Studio.
## Common Use Cases For the Connector
Common use cases for Compression module include:
  * Compress and decompress a file’s payload from a remote service.
  * Archive and extrat files from a file folder.


For examples of these use cases, refer to Compression Module Examples.
## Next Step
After you complete the prerequisites, you are ready to create an app and configure the connector using Anypoint Studio.
## See Also
  * Archiving and Extracting Files
  * Compressing and Decompressing a Single File
  * Compression Module Reference
  * MuleSoft Help Center