// This is an automatically generated code sample.
// To make this code sample work in your Oracle Cloud tenancy,
// please replace the values for any parameters whose current values do not fit
// your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
// boolean, number, and enum parameters with values not fitting your use case).

import * as identitydomains from "oci-identitydomains";
import common = require("oci-common");

// Create a default authentication provider that uses the DEFAULT
// profile in the configuration file.
// Refer to <see href="https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File>the public documentation</see> on how to prepare a configuration file.

const provider: common.ConfigFileAuthenticationDetailsProvider = new common.ConfigFileAuthenticationDetailsProvider();

(async () => {
  try {
    // Create a service client
    const client = new identitydomains.IdentityDomainsClient({
      authenticationDetailsProvider: provider
    });

    // Create a request and dependent object(s).
    const app = {
      id: "ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value",
      ocid: "EXAMPLE-ocid-Value",
      schemas: ["EXAMPLE--Value"],
      meta: {
        resourceType: "EXAMPLE-resourceType-Value",
        created: "EXAMPLE-created-Value",
        lastModified: "EXAMPLE-lastModified-Value",
        location: "EXAMPLE-location-Value",
        version: "EXAMPLE-version-Value"
      },
      idcsCreatedBy: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value",
        type: identitydomains.models.IdcsCreatedBy.Type.App,
        display: "EXAMPLE-display-Value",
        ocid: "EXAMPLE-ocid-Value"
      },
      idcsLastModifiedBy: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value",
        type: identitydomains.models.IdcsLastModifiedBy.Type.App,
        display: "EXAMPLE-display-Value",
        ocid: "EXAMPLE-ocid-Value"
      },
      idcsPreventedOperations: [identitydomains.models.IdcsPreventedOperations.Replace],
      tags: [
        {
          key: "EXAMPLE-key-Value",
          value: "EXAMPLE-value-Value"
        }
      ],
      deleteInProgress: true,
      idcsLastUpgradedInRelease: "EXAMPLE-idcsLastUpgradedInRelease-Value",
      domainOcid: "EXAMPLE-domainOcid-Value",
      compartmentOcid: "EXAMPLE-compartmentOcid-Value",
      tenancyOcid: "EXAMPLE-tenancyOcid-Value",
      meterAsOPCService: false,
      name: "EXAMPLE-name-Value",
      clientSecret: "EXAMPLE-clientSecret-Value",
      hashedClientSecret: "EXAMPLE-hashedClientSecret-Value",
      displayName: "EXAMPLE-displayName-Value",
      description: "EXAMPLE-description-Value",
      idTokenEncAlgo: "EXAMPLE-idTokenEncAlgo-Value",
      delegatedServiceNames: ["EXAMPLE--Value"],
      active: false,
      appIcon: "EXAMPLE-appIcon-Value",
      appThumbnail: "EXAMPLE-appThumbnail-Value",
      migrated: false,
      infrastructure: true,
      isLoginTarget: false,
      showInMyApps: false,
      loginMechanism: identitydomains.models.App.LoginMechanism.Formfill,
      landingPageUrl: "EXAMPLE-landingPageUrl-Value",
      productLogoUrl: "EXAMPLE-productLogoUrl-Value",
      privacyPolicyUrl: "EXAMPLE-privacyPolicyUrl-Value",
      termsOfServiceUrl: "EXAMPLE-termsOfServiceUrl-Value",
      contactEmailAddress: "EXAMPLE-contactEmailAddress-Value",
      productName: "EXAMPLE-productName-Value",
      homePageUrl: "EXAMPLE-homePageUrl-Value",
      isFormFill: true,
      isOAuthClient: false,
      isRadiusApp: false,
      clientType: identitydomains.models.App.ClientType.Confidential,
      redirectUris: ["EXAMPLE--Value"],
      allUrlSchemesAllowed: true,
      logoutUri: "EXAMPLE-logoutUri-Value",
      postLogoutRedirectUris: ["EXAMPLE--Value"],
      allowedGrants: ["EXAMPLE--Value"],
      allowedOperations: [identitydomains.models.App.AllowedOperations.Introspect],
      clientIPChecking: identitydomains.models.App.ClientIPChecking.Anywhere,
      isOPCService: true,
      isUnmanagedApp: true,
      allowAccessControl: false,
      isOAuthResource: false,
      accessTokenExpiry: 674,
      refreshTokenExpiry: 124,
      allowOffline: false,
      callbackServiceUrl: "EXAMPLE-callbackServiceUrl-Value",
      audience: "EXAMPLE-audience-Value",
      isMobileTarget: false,
      loginPageUrl: "EXAMPLE-loginPageUrl-Value",
      linkingCallbackUrl: "EXAMPLE-linkingCallbackUrl-Value",
      logoutPageUrl: "EXAMPLE-logoutPageUrl-Value",
      errorPageUrl: "EXAMPLE-errorPageUrl-Value",
      isSamlServiceProvider: false,
      isWebTierPolicy: false,
      isKerberosRealm: false,
      icon: "EXAMPLE-icon-Value",
      isAliasApp: false,
      isManagedApp: false,
      serviceTypeURN: "EXAMPLE-serviceTypeURN-Value",
      serviceTypeVersion: "EXAMPLE-serviceTypeVersion-Value",
      isObligationCapable: true,
      readyToUpgrade: false,
      trustScope: identitydomains.models.App.TrustScope.Explicit,
      isDatabaseService: false,
      secondaryAudiences: ["EXAMPLE--Value"],
      isEnterpriseApp: true,
      bypassConsent: true,
      disableKmsiTokenAuthentication: true,
      isMulticloudServiceApp: true,
      radiusPolicy: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value"
      },
      appsNetworkPerimeters: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value"
        }
      ],
      cloudControlProperties: [
        {
          name: "EXAMPLE-name-Value",
          values: ["EXAMPLE--Value"]
        }
      ],
      editableAttributes: [
        {
          name: "EXAMPLE-name-Value"
        }
      ],
      termsOfUse: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value",
        name: "EXAMPLE-name-Value"
      },
      protectableSecondaryAudiences: [
        {
          value: "EXAMPLE-value-Value",
          readOnly: false
        }
      ],
      idpPolicy: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value"
      },
      allowedTags: [
        {
          key: "EXAMPLE-key-Value",
          value: "EXAMPLE-value-Value",
          readOnly: true
        }
      ],
      appSignonPolicy: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value"
      },
      trustPolicies: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value"
        }
      ],
      signonPolicy: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value"
      },
      identityProviders: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          display: "EXAMPLE-display-Value"
        }
      ],
      accounts: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          ownerId: "ocid1.test.oc1..<unique_ID>EXAMPLE-ownerId-Value",
          name: "EXAMPLE-name-Value",
          active: false
        }
      ],
      grants: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          granteeId: "ocid1.test.oc1..<unique_ID>EXAMPLE-granteeId-Value",
          granteeType: identitydomains.models.AppGrants.GranteeType.Group,
          grantMechanism: identitydomains.models.AppGrants.GrantMechanism.ImportApproleMembers
        }
      ],
      serviceParams: [
        {
          name: "EXAMPLE-name-Value",
          value: "EXAMPLE-value-Value"
        }
      ],
      attrRenderingMetadata: [
        {
          name: "EXAMPLE-name-Value",
          label: "EXAMPLE-label-Value",
          helptext: "EXAMPLE-helptext-Value",
          widget: identitydomains.models.AppAttrRenderingMetadata.Widget.Textarea,
          datatype: "EXAMPLE-datatype-Value",
          section: identitydomains.models.AppAttrRenderingMetadata.Section.General,
          order: 10,
          required: true,
          regexp: "EXAMPLE-regexp-Value",
          readOnly: false,
          visible: true,
          minLength: 954,
          maxLength: 840,
          minSize: 784,
          maxSize: 963
        }
      ],
      basedOnTemplate: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value",
        lastModified: "EXAMPLE-lastModified-Value",
        wellKnownId: "ocid1.test.oc1..<unique_ID>EXAMPLE-wellKnownId-Value"
      },
      grantedAppRoles: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          type: identitydomains.models.AppGrantedAppRoles.Type.Indirect,
          display: "EXAMPLE-display-Value",
          appId: "ocid1.test.oc1..<unique_ID>EXAMPLE-appId-Value",
          appName: "EXAMPLE-appName-Value",
          adminRole: true,
          legacyGroupName: "EXAMPLE-legacyGroupName-Value",
          readOnly: true
        }
      ],
      samlServiceProvider: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value"
      },
      allowedScopes: [
        {
          fqs: "EXAMPLE-fqs-Value",
          idOfDefiningApp: "EXAMPLE-idOfDefiningApp-Value",
          readOnly: true
        }
      ],
      certificates: [
        {
          certAlias: "EXAMPLE-certAlias-Value",
          sha1Thumbprint: "EXAMPLE-sha1Thumbprint-Value",
          kid: "EXAMPLE-kid-Value",
          x5t: "EXAMPLE-x5t-Value",
          x509Base64Certificate: "EXAMPLE-x509Base64Certificate-Value"
        }
      ],
      aliasApps: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          display: "EXAMPLE-display-Value",
          description: "EXAMPLE-description-Value"
        }
      ],
      asOPCService: {
        value: "EXAMPLE-value-Value",
        ref: "EXAMPLE-$ref-Value"
      },
      adminRoles: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          display: "EXAMPLE-display-Value",
          description: "EXAMPLE-description-Value"
        }
      ],
      userRoles: [
        {
          value: "EXAMPLE-value-Value",
          ref: "EXAMPLE-$ref-Value",
          display: "EXAMPLE-display-Value",
          description: "EXAMPLE-description-Value"
        }
      ],
      scopes: [
        {
          value: "EXAMPLE-value-Value",
          fqs: "EXAMPLE-fqs-Value",
          description: "EXAMPLE-description-Value",
          displayName: "EXAMPLE-displayName-Value",
          requiresConsent: true,
          readOnly: true
        }
      ]
    };

    const putAppRequest: identitydomains.requests.PutAppRequest = {
      appId: "ocid1.test.oc1..<unique_ID>EXAMPLE-appId-Value",
      authorization: "EXAMPLE-authorization-Value",
      resourceTypeSchemaVersion: "EXAMPLE-resourceTypeSchemaVersion-Value",
      attributes: "EXAMPLE-attributes-Value",
      attributeSets: [identitydomains.models.AttributeSets.Never],
      app: app,
      ifMatch: "EXAMPLE-ifMatch-Value",
      opcRetryToken: "EXAMPLE-opcRetryToken-Value"
    };

    // Send request to the Client.
    const putAppResponse = await client.putApp(putAppRequest);
  } catch (error) {
    console.log("putApp Failed with error  " + error);
  }
})();