@ibm-cloud/platform-services
Version:
Node.js client library for IBM Cloud Platform Services
684 lines (683 loc) • 29.4 kB
TypeScript
/**
* (C) Copyright IBM Corp. 2022.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/// <reference types="node" />
/// <reference types="node" />
import { IncomingHttpHeaders, OutgoingHttpHeaders } from 'http';
import { BaseService, UserOptions, FileWithMetadata } from 'ibm-cloud-sdk-core';
/**
* Case management API for creating cases, getting case statuses, adding comments to a case, adding and removing users
* from a case watchlist, downloading and adding attachments, and more.
*
* API Version: 1.0.0
*/
declare class CaseManagementV1 extends BaseService {
static DEFAULT_SERVICE_URL: string;
static DEFAULT_SERVICE_NAME: string;
/*************************
* Factory method
************************/
/**
* Constructs an instance of CaseManagementV1 with passed in options and external configuration.
*
* @param {UserOptions} [options] - The parameters to send to the service.
* @param {string} [options.serviceName] - The name of the service to configure
* @param {Authenticator} [options.authenticator] - The Authenticator object used to authenticate requests to the service
* @param {string} [options.serviceUrl] - The URL for the service
* @returns {CaseManagementV1}
*/
static newInstance(options: UserOptions): CaseManagementV1;
/**
* Construct a CaseManagementV1 object.
*
* @param {Object} options - Options for the service.
* @param {string} [options.serviceUrl] - The base url to use when contacting the service. The base url may differ between IBM Cloud regions.
* @param {OutgoingHttpHeaders} [options.headers] - Default headers that shall be included with every request to the service.
* @param {Authenticator} options.authenticator - The Authenticator object used to authenticate requests to the service
* @constructor
* @returns {CaseManagementV1}
*/
constructor(options: UserOptions);
/*************************
* default
************************/
/**
* Get cases in account.
*
* Get cases in the account that are specified by the content of the IAM token.
*
* @param {Object} [params] - The parameters to send to the service.
* @param {number} [params.offset] - Number of cases that are skipped.
* @param {number} [params.limit] - Number of cases that are returned.
* @param {string} [params.search] - String that a case might contain.
* @param {string} [params.sort] - Sort field and direction. If omitted, default to descending of updated date. Prefix
* "~" signifies sort in descending.
* @param {string[]} [params.status] - Case status filter.
* @param {string[]} [params.fields] - Selected fields of interest instead of all of the case information.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.CaseList>>}
*/
getCases(params?: CaseManagementV1.GetCasesParams): Promise<CaseManagementV1.Response<CaseManagementV1.CaseList>>;
/**
* Create a case.
*
* Create a support case to resolve issues in your account.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.type - Case type.
* @param {string} params.subject - Short description used to identify the case.
* @param {string} params.description - Detailed description of the issue.
* @param {number} [params.severity] - Severity of the case. Smaller values mean higher severity.
* @param {CasePayloadEu} [params.eu] - Specify if the case should be treated as EU regulated. Only one of the
* following properties is required. Call EU support utility endpoint to determine which property must be specified
* for your account.
* @param {Offering} [params.offering] - Offering details.
* @param {ResourcePayload[]} [params.resources] - List of resources to attach to case. If you attach Classic IaaS
* devices, use the type and id fields if the Cloud Resource Name (CRN) is unavailable. Otherwise, pass the resource
* CRN. The resource list must be consistent with the value that is selected for the resource offering.
* @param {User[]} [params.watchlist] - Array of user IDs to add to the watchlist.
* @param {string} [params.invoiceNumber] - Invoice number of "Billing and Invoice" case type.
* @param {boolean} [params.slaCreditRequest] - Flag to indicate if case is for an Service Level Agreement (SLA)
* credit request.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Case>>}
*/
createCase(params: CaseManagementV1.CreateCaseParams): Promise<CaseManagementV1.Response<CaseManagementV1.Case>>;
/**
* Get a case in account.
*
* View a case in the account that is specified by the case number.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {string[]} [params.fields] - Selected fields of interest instead of all of the case information.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Case>>}
*/
getCase(params: CaseManagementV1.GetCaseParams): Promise<CaseManagementV1.Response<CaseManagementV1.Case>>;
/**
* Update case status.
*
* Mark the case as resolved or unresolved, or accept the provided resolution.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {StatusPayload} params.statusPayload -
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Case>>}
*/
updateCaseStatus(params: CaseManagementV1.UpdateCaseStatusParams): Promise<CaseManagementV1.Response<CaseManagementV1.Case>>;
/**
* Add comment to case.
*
* Add a comment to a case to be viewed by a support engineer.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {string} params.comment - Comment to add to the case.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Comment>>}
*/
addComment(params: CaseManagementV1.AddCommentParams): Promise<CaseManagementV1.Response<CaseManagementV1.Comment>>;
/**
* Add users to watchlist of case.
*
* Add users to the watchlist of case. By adding a user to the watchlist of the case, you are granting them read and
* write permissions, so the user can view the case, receive updates, and make updates to the case. Note that the user
* must be in the account to be added to the watchlist.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {User[]} [params.watchlist] - Array of user ID objects.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.WatchlistAddResponse>>}
*/
addWatchlist(params: CaseManagementV1.AddWatchlistParams): Promise<CaseManagementV1.Response<CaseManagementV1.WatchlistAddResponse>>;
/**
* Remove users from watchlist of case.
*
* Remove users from the watchlist of a case if you don't want them to view the case, receive updates, or make updates
* to the case.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {User[]} [params.watchlist] - Array of user ID objects.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Watchlist>>}
*/
removeWatchlist(params: CaseManagementV1.RemoveWatchlistParams): Promise<CaseManagementV1.Response<CaseManagementV1.Watchlist>>;
/**
* Add a resource to case.
*
* Add a resource to case by specifying the Cloud Resource Name (CRN), or id and type if attaching a class iaaS
* resource.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {string} [params.crn] - Cloud Resource Name of the resource.
* @param {string} [params.type] - Only used to attach Classic IaaS devices that have no CRN.
* @param {number} [params.id] - Deprecated: Only used to attach Classic IaaS devices that have no CRN. Id of Classic
* IaaS device. This is deprecated in favor of the crn field.
* @param {string} [params.note] - A note about this resource.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Resource>>}
*/
addResource(params: CaseManagementV1.AddResourceParams): Promise<CaseManagementV1.Response<CaseManagementV1.Resource>>;
/**
* Add attachments to a support case.
*
* You can add attachments to a case to provide more information for the support team about the issue that you're
* experiencing.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {FileWithMetadata[]} params.file - file of supported types, 8MB in size limit.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.Attachment>>}
*/
uploadFile(params: CaseManagementV1.UploadFileParams): Promise<CaseManagementV1.Response<CaseManagementV1.Attachment>>;
/**
* Download an attachment.
*
* Download an attachment from a case.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {string} params.fileId - Unique identifier of a file.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<NodeJS.ReadableStream>>}
*/
downloadFile(params: CaseManagementV1.DownloadFileParams): Promise<CaseManagementV1.Response<NodeJS.ReadableStream>>;
/**
* Remove attachment from case.
*
* Remove an attachment from a case.
*
* @param {Object} params - The parameters to send to the service.
* @param {string} params.caseNumber - Unique identifier of a case.
* @param {string} params.fileId - Unique identifier of a file.
* @param {OutgoingHttpHeaders} [params.headers] - Custom request headers
* @returns {Promise<CaseManagementV1.Response<CaseManagementV1.AttachmentList>>}
*/
deleteFile(params: CaseManagementV1.DeleteFileParams): Promise<CaseManagementV1.Response<CaseManagementV1.AttachmentList>>;
}
/*************************
* interfaces
************************/
declare namespace CaseManagementV1 {
/** An operation response. */
interface Response<T = any> {
result: T;
status: number;
statusText: string;
headers: IncomingHttpHeaders;
}
/** The callback for a service request. */
type Callback<T> = (error: any, response?: Response<T>) => void;
/** The body of a service request that returns no response data. */
interface EmptyObject {
}
/** A standard JS object, defined to avoid the limitations of `Object` and `object` */
interface JsonObject {
[]: any;
}
/*************************
* request interfaces
************************/
/** Parameters for the `getCases` operation. */
interface GetCasesParams {
/** Number of cases that are skipped. */
offset?: number;
/** Number of cases that are returned. */
limit?: number;
/** String that a case might contain. */
search?: string;
/** Sort field and direction. If omitted, default to descending of updated date. Prefix "~" signifies sort in
* descending.
*/
sort?: string;
/** Case status filter. */
status?: GetCasesConstants.Status[] | string[];
/** Selected fields of interest instead of all of the case information. */
fields?: GetCasesConstants.Fields[] | string[];
headers?: OutgoingHttpHeaders;
}
/** Constants for the `getCases` operation. */
namespace GetCasesConstants {
/** Case status filter. */
enum Status {
NEW = "new",
IN_PROGRESS = "in_progress",
WAITING_ON_CLIENT = "waiting_on_client",
RESOLUTION_PROVIDED = "resolution_provided",
RESOLVED = "resolved",
CLOSED = "closed"
}
/** Selected fields of interest instead of all of the case information. */
enum Fields {
NUMBER = "number",
SHORT_DESCRIPTION = "short_description",
DESCRIPTION = "description",
CREATED_AT = "created_at",
CREATED_BY = "created_by",
UPDATED_AT = "updated_at",
UPDATED_BY = "updated_by",
CONTACT = "contact",
CONTACT_TYPE = "contact_type",
STATUS = "status",
SEVERITY = "severity",
SUPPORT_TIER = "support_tier",
RESOLUTION = "resolution",
CLOSE_NOTES = "close_notes",
INVOICE_NUMBER = "invoice_number",
AGENT_CLOSE_ONLY = "agent_close_only",
EU = "eu",
WATCHLIST = "watchlist",
ATTACHMENTS = "attachments",
RESOURCES = "resources",
COMMENTS = "comments",
OFFERING = "offering"
}
}
/** Parameters for the `createCase` operation. */
interface CreateCaseParams {
/** Case type. */
type: CreateCaseConstants.Type | string;
/** Short description used to identify the case. */
subject: string;
/** Detailed description of the issue. */
description: string;
/** Severity of the case. Smaller values mean higher severity. */
severity?: number;
/** Specify if the case should be treated as EU regulated. Only one of the following properties is required.
* Call EU support utility endpoint to determine which property must be specified for your account.
*/
eu?: CasePayloadEu;
/** Offering details. */
offering?: Offering;
/** List of resources to attach to case. If you attach Classic IaaS devices, use the type and id fields if the
* Cloud Resource Name (CRN) is unavailable. Otherwise, pass the resource CRN. The resource list must be consistent
* with the value that is selected for the resource offering.
*/
resources?: ResourcePayload[];
/** Array of user IDs to add to the watchlist. */
watchlist?: User[];
/** Invoice number of "Billing and Invoice" case type. */
invoiceNumber?: string;
/** Flag to indicate if case is for an Service Level Agreement (SLA) credit request. */
slaCreditRequest?: boolean;
headers?: OutgoingHttpHeaders;
}
/** Constants for the `createCase` operation. */
namespace CreateCaseConstants {
/** Case type. */
enum Type {
TECHNICAL = "technical",
ACCOUNT_AND_ACCESS = "account_and_access",
BILLING_AND_INVOICE = "billing_and_invoice",
SALES = "sales"
}
}
/** Parameters for the `getCase` operation. */
interface GetCaseParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Selected fields of interest instead of all of the case information. */
fields?: GetCaseConstants.Fields[] | string[];
headers?: OutgoingHttpHeaders;
}
/** Constants for the `getCase` operation. */
namespace GetCaseConstants {
/** Selected fields of interest instead of all of the case information. */
enum Fields {
NUMBER = "number",
SHORT_DESCRIPTION = "short_description",
DESCRIPTION = "description",
CREATED_AT = "created_at",
CREATED_BY = "created_by",
UPDATED_AT = "updated_at",
UPDATED_BY = "updated_by",
CONTACT = "contact",
CONTACT_TYPE = "contact_type",
STATUS = "status",
SEVERITY = "severity",
SUPPORT_TIER = "support_tier",
RESOLUTION = "resolution",
CLOSE_NOTES = "close_notes",
INVOICE_NUMBER = "invoice_number",
AGENT_CLOSE_ONLY = "agent_close_only",
EU = "eu",
WATCHLIST = "watchlist",
ATTACHMENTS = "attachments",
RESOURCES = "resources",
COMMENTS = "comments",
OFFERING = "offering"
}
}
/** Parameters for the `updateCaseStatus` operation. */
interface UpdateCaseStatusParams {
/** Unique identifier of a case. */
caseNumber: string;
statusPayload: StatusPayload;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `addComment` operation. */
interface AddCommentParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Comment to add to the case. */
comment: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `addWatchlist` operation. */
interface AddWatchlistParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Array of user ID objects. */
watchlist?: User[];
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `removeWatchlist` operation. */
interface RemoveWatchlistParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Array of user ID objects. */
watchlist?: User[];
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `addResource` operation. */
interface AddResourceParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Cloud Resource Name of the resource. */
crn?: string;
/** Only used to attach Classic IaaS devices that have no CRN. */
type?: string;
/** Deprecated: Only used to attach Classic IaaS devices that have no CRN. Id of Classic IaaS device. This is
* deprecated in favor of the crn field.
*/
id?: number;
/** A note about this resource. */
note?: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `uploadFile` operation. */
interface UploadFileParams {
/** Unique identifier of a case. */
caseNumber: string;
/** file of supported types, 8MB in size limit. */
file: FileWithMetadata[];
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `downloadFile` operation. */
interface DownloadFileParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Unique identifier of a file. */
fileId: string;
headers?: OutgoingHttpHeaders;
}
/** Parameters for the `deleteFile` operation. */
interface DeleteFileParams {
/** Unique identifier of a case. */
caseNumber: string;
/** Unique identifier of a file. */
fileId: string;
headers?: OutgoingHttpHeaders;
}
/*************************
* model interfaces
************************/
/** Details of an attachment. */
interface Attachment {
/** Unique identifier of the attachment in database. */
id?: string;
/** Name of the attachment. */
filename?: string;
/** Size of the attachment in bytes. */
size_in_bytes?: number;
/** Date time of uploading in UTC. */
created_at?: string;
/** URL of the attachment used to download. */
url?: string;
}
/** List of attachments in the case. */
interface AttachmentList {
/** New attachments array. */
attachments?: Attachment[];
}
/** The support case. */
interface Case {
/** Identifying number of a created case. */
number?: string;
/** Short description of what the case is about. */
short_description?: string;
/** Full description of what the case is about. */
description?: string;
/** Date and time of case creation in UTC. */
created_at?: string;
/** User info in a case. */
created_by?: User;
/** Date and time of the last update on the case in UTC. */
updated_at?: string;
/** User info in a case. */
updated_by?: User;
/** Name of the console to interact with the contact. */
contact_type?: string;
/** User info in a case. */
contact?: User;
/** Status type of the case. */
status?: string;
/** Severity level of the case. */
severity?: number;
/** Support tier of the account. */
support_tier?: string;
/** Standard reasons of resolving case. */
resolution?: string;
/** Notes of case closing. */
close_notes?: string;
/** EU support. */
eu?: CaseEu;
/** List of users in the case watchlist. */
watchlist?: User[];
/** List of files that are attached to the case. */
attachments?: Attachment[];
/** Offering details. */
offering?: Offering;
/** List of attached resources. */
resources?: Resource[];
/** List of comments and updates that are sorted in chronological order. */
comments?: Comment[];
}
/** EU support. */
interface CaseEu {
/** Identifying whether the case has EU Support. */
support?: boolean;
/** Information about the data center. */
data_center?: string;
}
/** Response of a GET /cases request. */
interface CaseList {
/** Total number of cases that satisfy the query. */
total_count?: number;
/** Container for URL pointer to related pages of cases. */
first?: PaginationLink;
/** Container for URL pointer to related pages of cases. */
next?: PaginationLink;
/** Container for URL pointer to related pages of cases. */
previous?: PaginationLink;
/** Container for URL pointer to related pages of cases. */
last?: PaginationLink;
/** List of cases. */
cases?: Case[];
}
/** Specify if the case should be treated as EU regulated. Only one of the following properties is required. Call EU support utility endpoint to determine which property must be specified for your account. */
interface CasePayloadEu {
/** indicating whether the case is EU supported. */
supported?: boolean;
/** If EU supported utility endpoint specifies data center, then pass the data center id to mark a case as EU
* supported.
*/
data_center?: number;
}
/** A comment in a case. */
interface Comment {
/** The comment. */
value?: string;
/** Date time when comment was added in UTC. */
added_at?: string;
/** User info in a case. */
added_by?: User;
}
/** Offering details. */
interface Offering {
/** Name of the offering. */
name: string;
/** Offering type. */
type: OfferingType;
}
/** Offering type. */
interface OfferingType {
/** Offering type group. "crn_service_name" is preferred over "category" as the latter is legacy and will be
* deprecated in the future.
*/
group: string;
/** CRN service name of the offering. */
key: string;
/** Optional. Platform kind of the offering. */
kind?: string;
/** Offering id in the catalog. This alone is enough to identify the offering. */
id?: string;
}
/** Container for URL pointer to related pages of cases. */
interface PaginationLink {
/** URL to related pages of cases. */
href?: string;
}
/** A resource record of a case. */
interface Resource {
/** ID of the resource. */
crn?: string;
/** Name of the resource. */
name?: string;
/** Type of resource. */
type?: string;
/** URL of resource. */
url?: string;
/** Note about resource. */
note?: string;
}
/** Payload to add a resource to a case. */
interface ResourcePayload {
/** Cloud Resource Name of the resource. */
crn?: string;
/** Only used to attach Classic IaaS devices that have no CRN. */
type?: string;
/** Deprecated: Only used to attach Classic IaaS devices that have no CRN. Id of Classic IaaS device. This is
* deprecated in favor of the crn field.
*/
id?: number;
/** A note about this resource. */
note?: string;
}
/** Payload to update status of the case. */
interface StatusPayload {
/** action to perform on the case. */
action: string;
}
/** User info in a case. */
interface User {
/** Full name of the user. */
name?: string;
/** the ID realm. */
realm: string;
/** unique user ID in the realm specified by the type. */
user_id: string;
}
/** Payload to add/remove users to/from the case watchlist. */
interface Watchlist {
/** Array of user ID objects. */
watchlist?: User[];
}
/** Response of a request when adding to watchlist. */
interface WatchlistAddResponse {
/** List of added user. */
added?: User[];
/** List of failed to add user. */
failed?: User[];
}
/** Payload to accept the proposed resolution of the case. */
interface AcceptPayload extends StatusPayload {
/** Comment about accepting the proposed resolution. */
comment?: string;
}
/** Payload to resolve the case. */
interface ResolvePayload extends StatusPayload {
/** comment of resolution. */
comment?: string;
/** * 1: Client error
* * 2: Defect found with Component/Service
* * 3: Documentation Error
* * 4: Solution found in forums
* * 5: Solution found in public Documentation
* * 6: Solution no longer required
* * 7: Solution provided by IBM outside of support case
* * 8: Solution provided by IBM support engineer.
*/
resolution_code: number;
}
/** Payload to unresolve the case. */
interface UnresolvePayload extends StatusPayload {
/** Comment why the case should be unresolved. */
comment: string;
}
/*************************
* pager classes
************************/
/**
* GetCasesPager can be used to simplify the use of getCases().
*/
class GetCasesPager {
protected _hasNext: boolean;
protected pageContext: any;
protected client: CaseManagementV1;
protected params: CaseManagementV1.GetCasesParams;
/**
* Construct a GetCasesPager object.
*
* @param {CaseManagementV1} client - The service client instance used to invoke getCases()
* @param {Object} [params] - The parameters to be passed to getCases()
* @constructor
* @returns {GetCasesPager}
*/
constructor(client: CaseManagementV1, params?: CaseManagementV1.GetCasesParams);
/**
* Returns true if there are potentially more results to be retrieved by invoking getNext().
* @returns {boolean}
*/
hasNext(): boolean;
/**
* Returns the next page of results by invoking getCases().
* @returns {Promise<CaseManagementV1.Case[]>}
*/
getNext(): Promise<CaseManagementV1.Case[]>;
/**
* Returns all results by invoking getCases() repeatedly until all pages of results have been retrieved.
* @returns {Promise<CaseManagementV1.Case[]>}
*/
getAll(): Promise<CaseManagementV1.Case[]>;
}
}
export = CaseManagementV1;